up to build-chromium. we will see how that goes
This commit is contained in:
parent
4545e5ee73
commit
722626cf1e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
archive
|
||||
aur-ungoogled-chromium
|
||||
cache
|
||||
chromium-patches
|
||||
chromium-downloads
|
||||
chromium-launcher
|
||||
chromium-src**
|
||||
|
55
aur-patches/REVERT-roll-src-third_party-ffmpeg-m106.patch
Normal file
55
aur-patches/REVERT-roll-src-third_party-ffmpeg-m106.patch
Normal file
@ -0,0 +1,55 @@
|
||||
From ded379824f5de39357b6b1894578101aba5cdf05 Mon Sep 17 00:00:00 2001
|
||||
From: Eugene Zemtsov <eugene@chromium.org>
|
||||
Date: Fri, 29 Jul 2022 04:41:04 +0000
|
||||
Subject: [PATCH] Roll src/third_party/ffmpeg/ 880df5ede..b71ecd02b (279
|
||||
commits)
|
||||
|
||||
https://chromium.googlesource.com/chromium/third_party/ffmpeg.git/+log/880df5ede50a..b71ecd02b479
|
||||
|
||||
$ git log 880df5ede..b71ecd02b --date=short --no-merges --format='%ad %ae %s'
|
||||
2022-07-27 eugene Roll for M106
|
||||
2022-07-25 andreas.rheinhardt avcodec/x86/pngdsp: Remove obsolete ff_add_bytes_l2_mmx()
|
||||
2022-07-22 andreas.rheinhardt avcodec/hevcdec: Output MD5-message in one piece
|
||||
2022-07-24 epirat07 configure: properly require libx264 if enabled
|
||||
2022-07-24 zane avformat/argo_cvg: expose loop/reverb/checksum via metadata
|
||||
(...)
|
||||
2022-05-03 leo.izen avcodec/libjxldec: properly tag output colorspace
|
||||
2022-06-25 ffmpeg avfilter/Makefile: always make colorspace.o
|
||||
2022-03-02 brad avutil/ppc/cpu: Use proper header for OpenBSD PPC CPU detection
|
||||
2022-06-24 jamrial avformat/http: include version.h
|
||||
2022-05-16 mbonda-at-nvidia.com AV1 VDPAU hwaccel Decode support
|
||||
|
||||
Created with:
|
||||
roll-dep src/third_party/ffmpeg
|
||||
|
||||
ffmpeg usage fix:
|
||||
Switch from AVFrame::pkt_duration to AVFrame::duration,
|
||||
AVFrame::pkt_duration is deprecated
|
||||
|
||||
Bug: 1344646
|
||||
Change-Id: Iaa3abf48ef81dae6d282bca8f0fa2a8dffeeba25
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3788638
|
||||
Reviewed-by: Will Cassella <cassew@chromium.org>
|
||||
Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#1029623}
|
||||
---
|
||||
media/filters/audio_file_reader.cc | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/media/filters/audio_file_reader.cc b/media/filters/audio_file_reader.cc
|
||||
index e1be5aa9a5b..951c003956f 100644
|
||||
--- a/media/filters/audio_file_reader.cc
|
||||
+++ b/media/filters/audio_file_reader.cc
|
||||
@@ -243,10 +243,10 @@ bool AudioFileReader::OnNewFrame(
|
||||
// silence from being output. In the case where we are also discarding some
|
||||
// portion of the packet (as indicated by a negative pts), we further want to
|
||||
// adjust the duration downward by however much exists before zero.
|
||||
- if (audio_codec_ == AudioCodec::kAAC && frame->pkt_duration) {
|
||||
+ if (audio_codec_ == AudioCodec::kAAC && frame->duration) {
|
||||
const base::TimeDelta pkt_duration = ConvertFromTimeBase(
|
||||
glue_->format_context()->streams[stream_index_]->time_base,
|
||||
- frame->pkt_duration + std::min(static_cast<int64_t>(0), frame->pts));
|
||||
+ frame->duration + std::min(static_cast<int64_t>(0), frame->pts));
|
||||
const base::TimeDelta frame_duration =
|
||||
base::Seconds(frames_read / static_cast<double>(sample_rate_));
|
||||
|
38
aur-patches/angle-wayland-include-protocol.patch
Normal file
38
aur-patches/angle-wayland-include-protocol.patch
Normal file
@ -0,0 +1,38 @@
|
||||
diff -upr third_party/angle.orig/BUILD.gn third_party/angle/BUILD.gn
|
||||
--- third_party/angle.orig/BUILD.gn 2022-08-17 19:38:11.000000000 +0000
|
||||
+++ third_party/angle/BUILD.gn 2022-08-18 11:04:09.061751111 +0000
|
||||
@@ -489,6 +489,12 @@ config("angle_vulkan_wayland_config") {
|
||||
if (angle_enable_vulkan && angle_use_wayland &&
|
||||
defined(vulkan_wayland_include_dirs)) {
|
||||
include_dirs = vulkan_wayland_include_dirs
|
||||
+ } else if (angle_enable_vulkan && angle_use_wayland) {
|
||||
+ include_dirs = [
|
||||
+ "$wayland_gn_dir/src/src",
|
||||
+ "$wayland_gn_dir/include/src",
|
||||
+ "$wayland_gn_dir/include/protocol",
|
||||
+ ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1073,6 +1079,7 @@ if (angle_use_wayland) {
|
||||
include_dirs = [
|
||||
"$wayland_dir/egl",
|
||||
"$wayland_dir/src",
|
||||
+ "$wayland_gn_dir/include/protocol",
|
||||
]
|
||||
}
|
||||
|
||||
diff -upr third_party/angle.orig/src/third_party/volk/BUILD.gn third_party/angle/src/third_party/volk/BUILD.gn
|
||||
--- third_party/angle.orig/src/third_party/volk/BUILD.gn 2022-08-17 19:38:12.000000000 +0000
|
||||
+++ third_party/angle/src/third_party/volk/BUILD.gn 2022-08-18 11:04:36.499828006 +0000
|
||||
@@ -21,6 +21,9 @@ source_set("volk") {
|
||||
configs += [ "$angle_root:angle_no_cfi_icall" ]
|
||||
public_deps = [ "$angle_vulkan_headers_dir:vulkan_headers" ]
|
||||
if (angle_use_wayland) {
|
||||
- include_dirs = [ "$wayland_dir/src" ]
|
||||
+ include_dirs = [
|
||||
+ "$wayland_dir/src",
|
||||
+ "$wayland_gn_dir/include/protocol",
|
||||
+ ]
|
||||
}
|
||||
}
|
128
aur-patches/ozone-add-va-api-support-to-wayland.patch
Normal file
128
aur-patches/ozone-add-va-api-support-to-wayland.patch
Normal file
@ -0,0 +1,128 @@
|
||||
From: Maksim Sisov <msisov@igalia.com>
|
||||
Date: Wed, 20 Jan 2021 09:50:22 +0200
|
||||
Subject: [PATCH] ozone/wayland: add VA-API support.
|
||||
|
||||
This patch ads VA-API support utilizing old VA-API path used for
|
||||
ChromeOS, which can be buggy on some devices (currently tested
|
||||
on Intel Gen8 and Gen9 with Gen8 having some minor bugs).
|
||||
|
||||
It's known that a new VA-API is being developed atm and once it's ready,
|
||||
we will switch to a new path, which should be more stable.
|
||||
|
||||
Upstream-Status: Inappropriate
|
||||
|
||||
The patch is based on the old va-api path. ChromeOS
|
||||
team is working on the new path, which will be also employed
|
||||
by Wayland later.
|
||||
|
||||
---
|
||||
diff --git a/media/gpu/vaapi/vaapi_picture_factory.cc b/media/gpu/vaapi/vaapi_picture_factory.cc
|
||||
index 62e3a42..bde9c2d 100644
|
||||
--- a/media/gpu/vaapi/vaapi_picture_factory.cc
|
||||
+++ b/media/gpu/vaapi/vaapi_picture_factory.cc
|
||||
@@ -105,7 +105,7 @@ uint32_t VaapiPictureFactory::GetGLTextureTarget() {
|
||||
}
|
||||
|
||||
gfx::BufferFormat VaapiPictureFactory::GetBufferFormat() {
|
||||
-#if BUILDFLAG(USE_VAAPI_X11)
|
||||
+#if BUILDFLAG(IS_LINUX)
|
||||
return gfx::BufferFormat::RGBX_8888;
|
||||
#else
|
||||
return gfx::BufferFormat::YUV_420_BIPLANAR;
|
||||
diff --git a/media/gpu/vaapi/vaapi_picture_native_pixmap.cc b/media/gpu/vaapi/vaapi_picture_native_pixmap.cc
|
||||
index 941f24c..a9c8035 100644
|
||||
--- a/media/gpu/vaapi/vaapi_picture_native_pixmap.cc
|
||||
+++ b/media/gpu/vaapi/vaapi_picture_native_pixmap.cc
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "media/gpu/vaapi/vaapi_picture_native_pixmap.h"
|
||||
|
||||
+#include "media/gpu/macros.h"
|
||||
#include "media/gpu/vaapi/va_surface.h"
|
||||
#include "media/gpu/vaapi/vaapi_wrapper.h"
|
||||
#include "ui/gfx/buffer_format_util.h"
|
||||
@@ -40,7 +41,21 @@ VaapiPictureNativePixmap::~VaapiPictureNativePixmap() = default;
|
||||
bool VaapiPictureNativePixmap::DownloadFromSurface(
|
||||
scoped_refptr<VASurface> va_surface) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
- return vaapi_wrapper_->BlitSurface(*va_surface, *va_surface_);
|
||||
+ if (!vaapi_wrapper_->SyncSurface(va_surface->id())) {
|
||||
+ VLOGF(1) << "Cannot sync VPP input surface";
|
||||
+ return false;
|
||||
+ }
|
||||
+ if (!vaapi_wrapper_->BlitSurface(*va_surface, *va_surface_)) {
|
||||
+ VLOGF(1) << "Cannot convert decoded image into output buffer";
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Sync target surface since the buffer is returning to client.
|
||||
+ if (!vaapi_wrapper_->SyncSurface(va_surface_->id())) {
|
||||
+ VLOGF(1) << "Cannot sync VPP output surface";
|
||||
+ return false;
|
||||
+ }
|
||||
+ return true;
|
||||
}
|
||||
|
||||
bool VaapiPictureNativePixmap::AllowOverlay() const {
|
||||
diff --git a/media/gpu/vaapi/vaapi_video_decode_accelerator.cc b/media/gpu/vaapi/vaapi_video_decode_accelerator.cc
|
||||
index bf791d8..9e394eb 100644
|
||||
--- a/media/gpu/vaapi/vaapi_video_decode_accelerator.cc
|
||||
+++ b/media/gpu/vaapi/vaapi_video_decode_accelerator.cc
|
||||
@@ -560,12 +560,12 @@ void VaapiVideoDecodeAccelerator::InitiateSurfaceSetChange(
|
||||
requested_visible_rect_ = visible_rect;
|
||||
if (buffer_allocation_mode_ == BufferAllocationMode::kSuperReduced) {
|
||||
// Add one to the reference frames for the one being currently egressed.
|
||||
- requested_num_reference_frames_ = num_reference_frames + 1;
|
||||
+ requested_num_reference_frames_ = num_reference_frames + 4;
|
||||
requested_num_pics_ = num_pics - num_reference_frames;
|
||||
} else if (buffer_allocation_mode_ == BufferAllocationMode::kReduced) {
|
||||
// Add one to the reference frames for the one being currently egressed,
|
||||
// and an extra allocation for both |client_| and |decoder_|.
|
||||
- requested_num_reference_frames_ = num_reference_frames + 2;
|
||||
+ requested_num_reference_frames_ = num_reference_frames + 5;
|
||||
requested_num_pics_ = num_pics - num_reference_frames + 1;
|
||||
} else {
|
||||
requested_num_reference_frames_ = 0;
|
||||
diff --git a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc
|
||||
index 35378d1..68969d2 100644
|
||||
--- a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc
|
||||
+++ b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.cc
|
||||
@@ -32,7 +32,9 @@ GbmPixmapWayland::GbmPixmapWayland(WaylandBufferManagerGpu* buffer_manager)
|
||||
buffer_id_(buffer_manager->AllocateBufferID()) {}
|
||||
|
||||
GbmPixmapWayland::~GbmPixmapWayland() {
|
||||
- if (created_wl_buffer_)
|
||||
+ // gfx::BufferUsage::SCANOUT_VDA_WRITE doesn't result in creation of
|
||||
+ // wl_buffers.
|
||||
+ if (created_wl_buffer_ && usage_ != gfx::BufferUsage::SCANOUT_VDA_WRITE)
|
||||
buffer_manager_->DestroyBuffer(buffer_id_);
|
||||
}
|
||||
|
||||
diff --git a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h
|
||||
index 9e8b2fa..9918508 100644
|
||||
--- a/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h
|
||||
+++ b/ui/ozone/platform/wayland/gpu/gbm_pixmap_wayland.h
|
||||
@@ -92,6 +92,9 @@ class GbmPixmapWayland : public gfx::NativePixmap {
|
||||
|
||||
// Says a wl_buffer has been created and must removed.
|
||||
bool created_wl_buffer_ = false;
|
||||
+
|
||||
+ // Tells the usage of this pixmap.
|
||||
+ gfx::BufferUsage usage_ = gfx::BufferUsage::SCANOUT;
|
||||
};
|
||||
|
||||
} // namespace ui
|
||||
diff --git a/ui/ozone/platform/wayland/ozone_platform_wayland.cc b/ui/ozone/platform/wayland/ozone_platform_wayland.cc
|
||||
index c13bd3a..04fa160 100644
|
||||
--- a/ui/ozone/platform/wayland/ozone_platform_wayland.cc
|
||||
+++ b/ui/ozone/platform/wayland/ozone_platform_wayland.cc
|
||||
@@ -297,6 +297,9 @@ class OzonePlatformWayland : public OzonePlatform,
|
||||
properties->supports_global_screen_coordinates =
|
||||
features::IsWaylandScreenCoordinatesEnabled();
|
||||
|
||||
+ // Let the media know this platform supports va-api.
|
||||
+ properties->supports_vaapi = true;
|
||||
+
|
||||
initialised = true;
|
||||
}
|
||||
|
39
aur-patches/remove-main-main10-profile-limit.patch
Normal file
39
aur-patches/remove-main-main10-profile-limit.patch
Normal file
@ -0,0 +1,39 @@
|
||||
diff --git a/media/base/supported_types.cc b/media/base/supported_types.cc
|
||||
index c2efcdb..cc28d84 100644
|
||||
--- a/media/base/supported_types.cc
|
||||
+++ b/media/base/supported_types.cc
|
||||
@@ -205,34 +205,7 @@ bool IsHevcProfileSupported(const VideoType& type) {
|
||||
return false;
|
||||
|
||||
#if BUILDFLAG(ENABLE_PLATFORM_HEVC)
|
||||
-#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)
|
||||
-#if BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
- // TODO(b/171813538): For Lacros, the supplemental profile cache will be
|
||||
- // asking lacros-gpu, but we will be doing decoding in ash-gpu. Until the
|
||||
- // codec detection is plumbed through to ash-gpu we can do this extra check
|
||||
- // for HEVC support.
|
||||
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||
- switches::kLacrosEnablePlatformHevc)) {
|
||||
- return true;
|
||||
- }
|
||||
-#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
- return GetSupplementalProfileCache()->IsProfileSupported(type.profile);
|
||||
-#elif BUILDFLAG(IS_MAC)
|
||||
- if (__builtin_available(macOS 11.0, *))
|
||||
- return base::FeatureList::IsEnabled(kPlatformHEVCDecoderSupport) &&
|
||||
- (type.profile == HEVCPROFILE_MAIN ||
|
||||
- type.profile == HEVCPROFILE_MAIN10 ||
|
||||
- type.profile == HEVCPROFILE_MAIN_STILL_PICTURE ||
|
||||
- type.profile == HEVCPROFILE_REXT);
|
||||
- return false;
|
||||
-#elif BUILDFLAG(IS_ANDROID)
|
||||
- // Technically android 5.0 mandates support for only HEVC main profile,
|
||||
- // however some platforms (like chromecast) have had more profiles supported
|
||||
- // so we'll see what happens if we just enable them all.
|
||||
- return base::FeatureList::IsEnabled(kPlatformHEVCDecoderSupport);
|
||||
-#else
|
||||
return true;
|
||||
-#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)
|
||||
#else
|
||||
return false;
|
||||
#endif // BUILDFLAG(ENABLE_PLATFORM_HEVC)
|
@ -1,18 +0,0 @@
|
||||
--- chromium-102.0.5005.61/build/config/compiler/BUILD.gn.orig 2022-05-19 10:35:52.991415777 +0000
|
||||
+++ chromium-102.0.5005.61/build/config/compiler/BUILD.gn 2022-05-19 10:36:11.102017131 +0000
|
||||
@@ -1538,15 +1538,6 @@ config("default_warnings") {
|
||||
cflags += [ "-Wno-deprecated-non-prototype" ]
|
||||
}
|
||||
|
||||
- if (!is_nacl && !(is_chromeos ||
|
||||
- default_toolchain == "//build/toolchain/cros:target")) {
|
||||
- # TODO(https://crbug.com/1316298): Re-enable once test failure is figured out
|
||||
- cflags += [
|
||||
- "-Xclang",
|
||||
- "-no-opaque-pointers",
|
||||
- ]
|
||||
- }
|
||||
-
|
||||
if (is_fuchsia) {
|
||||
# TODO(https://bugs.chromium.org/p/fuchsia/issues/detail?id=77383)
|
||||
cflags += [ "-Wno-deprecated-copy" ]
|
@ -1,238 +0,0 @@
|
||||
From 144479ad7b4287bee4067f95e4218f614798a865 Mon Sep 17 00:00:00 2001
|
||||
From: Stephan Hartmann <stha09@googlemail.com>
|
||||
Date: Sun, 16 Jan 2022 19:15:26 +0000
|
||||
Subject: [PATCH] sql: make VirtualCursor standard layout type
|
||||
|
||||
sql::recover::VirtualCursor needs to be a standard layout type, but
|
||||
has members of type std::unique_ptr. However, std::unique_ptr is not
|
||||
guaranteed to be standard layout. Compiling with clang combined with
|
||||
gcc-11 libstdc++ fails because of this.
|
||||
|
||||
Bug: 1189788
|
||||
Change-Id: Ia6dc388cc5ef1c0f2afc75f8ca45b9f12687ca9c
|
||||
---
|
||||
sql/recover_module/btree.cc | 18 ++++++++++++------
|
||||
sql/recover_module/btree.h | 21 +++++++++++++++------
|
||||
sql/recover_module/cursor.cc | 24 ++++++++++++------------
|
||||
sql/recover_module/cursor.h | 2 +-
|
||||
sql/recover_module/pager.cc | 5 ++---
|
||||
sql/recover_module/pager.h | 6 +++---
|
||||
6 files changed, 45 insertions(+), 31 deletions(-)
|
||||
|
||||
diff --git a/sql/recover_module/btree.cc b/sql/recover_module/btree.cc
|
||||
index cc9420e5c05..f12d8fa32a2 100644
|
||||
--- a/sql/recover_module/btree.cc
|
||||
+++ b/sql/recover_module/btree.cc
|
||||
@@ -136,16 +136,22 @@ static_assert(std::is_trivially_destructible<LeafPageDecoder>::value,
|
||||
"Move the destructor to the .cc file if it's non-trival");
|
||||
#endif // !DCHECK_IS_ON()
|
||||
|
||||
-LeafPageDecoder::LeafPageDecoder(DatabasePageReader* db_reader) noexcept
|
||||
- : page_id_(db_reader->page_id()),
|
||||
- db_reader_(db_reader),
|
||||
- cell_count_(ComputeCellCount(db_reader)),
|
||||
- next_read_index_(0),
|
||||
- last_record_size_(0) {
|
||||
+LeafPageDecoder::LeafPageDecoder() noexcept = default;
|
||||
+
|
||||
+void LeafPageDecoder::Initialize(DatabasePageReader* db_reader) {
|
||||
+ page_id_ = db_reader->page_id();
|
||||
+ db_reader_ = db_reader;
|
||||
+ cell_count_ = ComputeCellCount(db_reader);
|
||||
+ next_read_index_ = 0;
|
||||
+ last_record_size_ = 0;
|
||||
DCHECK(IsOnValidPage(db_reader));
|
||||
DCHECK(DatabasePageReader::IsValidPageId(page_id_));
|
||||
}
|
||||
|
||||
+void LeafPageDecoder::Reset() {
|
||||
+ db_reader_ = nullptr;
|
||||
+}
|
||||
+
|
||||
bool LeafPageDecoder::TryAdvance() {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
DCHECK(CanAdvance());
|
||||
diff --git a/sql/recover_module/btree.h b/sql/recover_module/btree.h
|
||||
index eaa087a5c52..df0e0c937c0 100644
|
||||
--- a/sql/recover_module/btree.h
|
||||
+++ b/sql/recover_module/btree.h
|
||||
@@ -101,9 +101,7 @@ class LeafPageDecoder {
|
||||
public:
|
||||
// Creates a decoder for a DatabasePageReader's last read page.
|
||||
//
|
||||
- // |db_reader| must have been used to read an inner page of a table B-tree.
|
||||
- // |db_reader| must outlive this instance.
|
||||
- explicit LeafPageDecoder(DatabasePageReader* db_reader) noexcept;
|
||||
+ LeafPageDecoder() noexcept;
|
||||
~LeafPageDecoder() noexcept = default;
|
||||
|
||||
LeafPageDecoder(const LeafPageDecoder&) = delete;
|
||||
@@ -151,6 +149,17 @@ class LeafPageDecoder {
|
||||
// read as long as CanAdvance() returns true.
|
||||
bool TryAdvance();
|
||||
|
||||
+ // Initialize with DatabasePageReader
|
||||
+ // |db_reader| must have been used to read an inner page of a table B-tree.
|
||||
+ // |db_reader| must outlive this instance.
|
||||
+ void Initialize(DatabasePageReader* db_reader);
|
||||
+
|
||||
+ // Reset internal DatabasePageReader
|
||||
+ void Reset();
|
||||
+
|
||||
+ // True if DatabasePageReader is valid
|
||||
+ bool IsValid() { return (db_reader_ != nullptr); }
|
||||
+
|
||||
// True if the given reader may point to an inner page in a table B-tree.
|
||||
//
|
||||
// The last ReadPage() call on |db_reader| must have succeeded.
|
||||
@@ -164,14 +173,14 @@ class LeafPageDecoder {
|
||||
static int ComputeCellCount(DatabasePageReader* db_reader);
|
||||
|
||||
// The number of the B-tree page this reader is reading.
|
||||
- const int64_t page_id_;
|
||||
+ int64_t page_id_;
|
||||
// Used to read the tree page.
|
||||
//
|
||||
// Raw pointer usage is acceptable because this instance's owner is expected
|
||||
// to ensure that the DatabasePageReader outlives this.
|
||||
- DatabasePageReader* const db_reader_;
|
||||
+ DatabasePageReader* db_reader_;
|
||||
// Caches the ComputeCellCount() value for this reader's page.
|
||||
- const int cell_count_ = ComputeCellCount(db_reader_);
|
||||
+ int cell_count_;
|
||||
|
||||
// The reader's cursor state.
|
||||
//
|
||||
diff --git a/sql/recover_module/cursor.cc b/sql/recover_module/cursor.cc
|
||||
index 4f827edf1b4..240de4999fe 100644
|
||||
--- a/sql/recover_module/cursor.cc
|
||||
+++ b/sql/recover_module/cursor.cc
|
||||
@@ -28,7 +28,7 @@ VirtualCursor::~VirtualCursor() {
|
||||
int VirtualCursor::First() {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
inner_decoders_.clear();
|
||||
- leaf_decoder_ = nullptr;
|
||||
+ leaf_decoder_.Reset();
|
||||
|
||||
AppendPageDecoder(table_->root_page_id());
|
||||
return Next();
|
||||
@@ -38,18 +38,18 @@ int VirtualCursor::Next() {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
record_reader_.Reset();
|
||||
|
||||
- while (!inner_decoders_.empty() || leaf_decoder_.get()) {
|
||||
- if (leaf_decoder_.get()) {
|
||||
- if (!leaf_decoder_->CanAdvance()) {
|
||||
+ while (!inner_decoders_.empty() || leaf_decoder_.IsValid()) {
|
||||
+ if (leaf_decoder_.IsValid()) {
|
||||
+ if (!leaf_decoder_.CanAdvance()) {
|
||||
// The leaf has been exhausted. Remove it from the DFS stack.
|
||||
- leaf_decoder_ = nullptr;
|
||||
+ leaf_decoder_.Reset();
|
||||
continue;
|
||||
}
|
||||
- if (!leaf_decoder_->TryAdvance())
|
||||
+ if (!leaf_decoder_.TryAdvance())
|
||||
continue;
|
||||
|
||||
- if (!payload_reader_.Initialize(leaf_decoder_->last_record_size(),
|
||||
- leaf_decoder_->last_record_offset())) {
|
||||
+ if (!payload_reader_.Initialize(leaf_decoder_.last_record_size(),
|
||||
+ leaf_decoder_.last_record_offset())) {
|
||||
continue;
|
||||
}
|
||||
if (!record_reader_.Initialize())
|
||||
@@ -101,13 +101,13 @@ int VirtualCursor::ReadColumn(int column_index,
|
||||
int64_t VirtualCursor::RowId() {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
DCHECK(record_reader_.IsInitialized());
|
||||
- DCHECK(leaf_decoder_.get());
|
||||
- return leaf_decoder_->last_record_rowid();
|
||||
+ DCHECK(leaf_decoder_.IsValid());
|
||||
+ return leaf_decoder_.last_record_rowid();
|
||||
}
|
||||
|
||||
void VirtualCursor::AppendPageDecoder(int page_id) {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
- DCHECK(leaf_decoder_.get() == nullptr)
|
||||
+ DCHECK(!leaf_decoder_.IsValid())
|
||||
<< __func__
|
||||
<< " must only be called when the current path has no leaf decoder";
|
||||
|
||||
@@ -115,7 +115,7 @@ void VirtualCursor::AppendPageDecoder(int page_id) {
|
||||
return;
|
||||
|
||||
if (LeafPageDecoder::IsOnValidPage(&db_reader_)) {
|
||||
- leaf_decoder_ = std::make_unique<LeafPageDecoder>(&db_reader_);
|
||||
+ leaf_decoder_.Initialize(&db_reader_);
|
||||
return;
|
||||
}
|
||||
|
||||
diff --git a/sql/recover_module/cursor.h b/sql/recover_module/cursor.h
|
||||
index 845b7852648..cc4e85f83f9 100644
|
||||
--- a/sql/recover_module/cursor.h
|
||||
+++ b/sql/recover_module/cursor.h
|
||||
@@ -130,7 +130,7 @@ class VirtualCursor {
|
||||
std::vector<std::unique_ptr<InnerPageDecoder>> inner_decoders_;
|
||||
|
||||
// Decodes the leaf page containing records.
|
||||
- std::unique_ptr<LeafPageDecoder> leaf_decoder_;
|
||||
+ LeafPageDecoder leaf_decoder_;
|
||||
|
||||
SEQUENCE_CHECKER(sequence_checker_);
|
||||
};
|
||||
diff --git a/sql/recover_module/pager.cc b/sql/recover_module/pager.cc
|
||||
index 58e75de2704..69d98cef98d 100644
|
||||
--- a/sql/recover_module/pager.cc
|
||||
+++ b/sql/recover_module/pager.cc
|
||||
@@ -23,8 +23,7 @@ static_assert(DatabasePageReader::kMaxPageId <= std::numeric_limits<int>::max(),
|
||||
"ints are not appropriate for representing page IDs");
|
||||
|
||||
DatabasePageReader::DatabasePageReader(VirtualTable* table)
|
||||
- : page_data_(std::make_unique<uint8_t[]>(table->page_size())),
|
||||
- table_(table) {
|
||||
+ : page_data_(table->page_size()), table_(table) {
|
||||
DCHECK(table != nullptr);
|
||||
DCHECK(IsValidPageSize(table->page_size()));
|
||||
}
|
||||
@@ -58,7 +57,7 @@ int DatabasePageReader::ReadPage(int page_id) {
|
||||
"The |read_offset| computation above may overflow");
|
||||
|
||||
int sqlite_status =
|
||||
- RawRead(sqlite_file, read_size, read_offset, page_data_.get());
|
||||
+ RawRead(sqlite_file, read_size, read_offset, page_data_.data());
|
||||
|
||||
// |page_id_| needs to be set to kInvalidPageId if the read failed.
|
||||
// Otherwise, future ReadPage() calls with the previous |page_id_| value
|
||||
diff --git a/sql/recover_module/pager.h b/sql/recover_module/pager.h
|
||||
index 07cac3cb989..d08f0932fab 100644
|
||||
--- a/sql/recover_module/pager.h
|
||||
+++ b/sql/recover_module/pager.h
|
||||
@@ -6,8 +6,8 @@
|
||||
#define SQL_RECOVER_MODULE_PAGER_H_
|
||||
|
||||
#include <cstdint>
|
||||
-#include <memory>
|
||||
#include <ostream>
|
||||
+#include <vector>
|
||||
|
||||
#include "base/check_op.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
@@ -72,7 +72,7 @@ class DatabasePageReader {
|
||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||
DCHECK_NE(page_id_, kInvalidPageId)
|
||||
<< "Successful ReadPage() required before accessing pager state";
|
||||
- return page_data_.get();
|
||||
+ return page_data_.data();
|
||||
}
|
||||
|
||||
// The number of bytes in the page read by the last ReadPage() call.
|
||||
@@ -139,7 +139,7 @@ class DatabasePageReader {
|
||||
int page_id_ = kInvalidPageId;
|
||||
// Stores the bytes of the last page successfully read by ReadPage().
|
||||
// The content is undefined if the last call to ReadPage() did not succeed.
|
||||
- const std::unique_ptr<uint8_t[]> page_data_;
|
||||
+ std::vector<uint8_t> page_data_;
|
||||
// Raw pointer usage is acceptable because this instance's owner is expected
|
||||
// to ensure that the VirtualTable outlives this.
|
||||
const raw_ptr<VirtualTable> table_;
|
@ -0,0 +1,38 @@
|
||||
From ed8d931e35f81d8566835a579caf7d61368f85b7 Mon Sep 17 00:00:00 2001
|
||||
From: Evangelos Foutras <evangelos@foutrelis.com>
|
||||
Date: Tue, 27 Sep 2022 22:20:41 +0000
|
||||
Subject: [PATCH] unbundle/jsoncpp: avoid CFI faults with is_cfi=true
|
||||
|
||||
Ensure jsoncpp symbols have public visibility and are thus excluded from
|
||||
CFI checks and whole-program optimization. This is achieved by defining
|
||||
JSON_DLL_BUILD which in turn causes json/config.h to define JSON_API as
|
||||
__attribute__((visibility("default"))). The latter macro is used to tag
|
||||
jsoncpp classes and namespace functions throughout jsoncpp's headers.
|
||||
|
||||
BUG=1365218
|
||||
|
||||
Change-Id: I56277737b7d9ecaeb5e17c8d21a2e55f3d5d5bc9
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3919652
|
||||
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
|
||||
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#1052077}
|
||||
---
|
||||
build/linux/unbundle/jsoncpp.gn | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/build/linux/unbundle/jsoncpp.gn b/build/linux/unbundle/jsoncpp.gn
|
||||
index 544f9d13c9..e84a0ef27a 100644
|
||||
--- a/build/linux/unbundle/jsoncpp.gn
|
||||
+++ b/build/linux/unbundle/jsoncpp.gn
|
||||
@@ -3,6 +3,11 @@ import("//build/shim_headers.gni")
|
||||
|
||||
pkg_config("jsoncpp_config") {
|
||||
packages = [ "jsoncpp" ]
|
||||
+
|
||||
+ # Defining JSON_DLL_BUILD applies public visibility to jsoncpp classes
|
||||
+ # thus deactivating CFI checks for them. This avoids CFI violations in
|
||||
+ # virtual calls to system jsoncpp library (https://crbug.com/1365218).
|
||||
+ defines = [ "JSON_DLL_BUILD" ]
|
||||
}
|
||||
|
||||
shim_headers("jsoncpp_shim") {
|
@ -1,22 +0,0 @@
|
||||
--- a/ui/gl/gl_image_native_pixmap.cc 2020-05-18 11:40:06.000000000 -0700
|
||||
+++ b/ui/gl/gl_image_native_pixmap.cc 2020-05-22 02:07:16.007770442 -0700
|
||||
@@ -288,6 +288,8 @@
|
||||
std::move(scoped_fd));
|
||||
}
|
||||
|
||||
+ handle.planes[0].size = size_.GetArea();
|
||||
+
|
||||
return handle;
|
||||
#endif // !defined(OS_FUCHSIA)
|
||||
}
|
||||
--- a/gpu/command_buffer/service/error_state.cc 2020-05-18 11:39:22.000000000 -0700
|
||||
+++ b/gpu/command_buffer/service/error_state.cc 2020-05-22 13:43:09.181180388 -0700
|
||||
@@ -115,6 +115,8 @@
|
||||
// buffer.
|
||||
error = GL_NO_ERROR;
|
||||
}
|
||||
+ if (error == GL_INVALID_ENUM)
|
||||
+ error = GL_NO_ERROR;
|
||||
return error;
|
||||
}
|
||||
|
54
makefile
54
makefile
@ -1,6 +1,19 @@
|
||||
# Build requires gn and ninja
|
||||
# also clang, clang++, ar, nm
|
||||
|
||||
update-repos:
|
||||
# launcher
|
||||
cd ungoogled-chromium && git pull
|
||||
# installer from AUR (for patch/build reference)
|
||||
cd aur-ungoogled-chromium && git pull
|
||||
# extra patches (used by aur-ungoogled-chromium)
|
||||
cd chromium-patches && git pull
|
||||
|
||||
update-aur-patches:
|
||||
rm -rf aur-patches
|
||||
mkdir aur-patches
|
||||
cp aur-ungoogled-chromium/*.patch aur-patches
|
||||
|
||||
# ungoogled-chromium way
|
||||
retrieve:
|
||||
mkdir -p chromium-downloads
|
||||
@ -19,33 +32,42 @@ checkout:
|
||||
apply-aur-mods:
|
||||
cd chromium-src && ../aur-mods.sh
|
||||
|
||||
## MANUALLY ##
|
||||
# Copy the "patch" lines from aur-ungoogled-chromium/PKGBUILD into the following target
|
||||
# add cd chromium-src && before each line
|
||||
# rename "../patches" to "../chromium-patches"
|
||||
# rename "../" to "../aur-patches"
|
||||
apply-aur-patches:
|
||||
# Use the --oauth2-client-id= and --oauth2-client-secret= switches for
|
||||
# setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at
|
||||
# runtime -- this allows signing into Chromium without baked-in values
|
||||
cd chromium-src && patch -Np1 -i ../aur-patches/use-oauth2-client-switches-as-default.patch
|
||||
|
||||
# Remove '-Xclang -no-opaque-pointers' flag not supported by our clang
|
||||
cd chromium-src && patch -Np1 -i ../aur-patches/remove-no-opaque-pointers-flag.patch
|
||||
|
||||
# Upstream fixes
|
||||
cd chromium-src && patch -Np1 -i ../aur-patches/unbundle-jsoncpp-avoid-CFI-faults-with-is_cfi-true.patch
|
||||
|
||||
# Revert kGlobalMediaControlsCastStartStop enabled by default
|
||||
# https://crbug.com/1314342
|
||||
cd chromium-src && patch -Rp1 -F3 -i ../aur-patches/enable-GlobalMediaControlsCastStartStop.patch
|
||||
cd chromium-src && patch -Rp1 -F3 -i ../aur-patches/REVERT-enable-GlobalMediaControlsCastStartStop.patch
|
||||
|
||||
# https://chromium-review.googlesource.com/c/chromium/src/+/3488058
|
||||
#archived cd chromium-src && patch -Np1 -i ../aur-patches/chromium-libxml-unbundle.patch
|
||||
|
||||
# Revert ffmpeg roll requiring new channel layout API support
|
||||
# https://crbug.com/1325301
|
||||
cd chromium-src && patch -Rp1 -i ../aur-patches/roll-src-third_party-ffmpeg.patch
|
||||
cd chromium-src && patch -Rp1 -i ../aur-patches/REVERT-roll-src-third_party-ffmpeg-m102.patch
|
||||
# Revert switch from AVFrame::pkt_duration to AVFrame::duration
|
||||
cd chromium-src && patch -Rp1 -i ../aur-patches/REVERT-roll-src-third_party-ffmpeg-m106.patch
|
||||
|
||||
# https://chromium-review.googlesource.com/c/chromium/src/+/2862724
|
||||
cd chromium-src && patch -Np1 -i ../aur-patches/sql-make-VirtualCursor-standard-layout-type.patch
|
||||
# https://crbug.com/angleproject/7582
|
||||
cd chromium-src && patch -Np0 -i ../aur-patches/angle-wayland-include-protocol.patch
|
||||
|
||||
# Wayland/EGL regression (crbug #1071528 #1071550)
|
||||
cd chromium-src && patch -Np1 -i ../aur-patches/wayland-egl.patch
|
||||
# Fixes for building with libstdc++ instead of libc++
|
||||
cd chromium-src && patch -Np1 -i ../chromium-patches/chromium-103-VirtualCursor-std-layout.patch
|
||||
cd chromium-src && patch -Np1 -i ../chromium-patches/chromium-106-AutofillPopupControllerImpl-namespace.patch
|
||||
|
||||
# Enable vaapi on wayland
|
||||
cd chromium-src && patch -Np1 -i ../aur-patches/ozone-add-va-api-support-to-wayland.patch
|
||||
|
||||
# Remove HEVC profile limits
|
||||
cd chromium-src && patch -Np1 -i ../aur-patches/remove-main-main10-profile-limit.patch
|
||||
|
||||
# Ungoogled Chromium Steps
|
||||
prune-binaries:
|
||||
@ -55,8 +77,16 @@ apply-ungoogle-patches:
|
||||
./ungoogled-chromium/utils/patches.py apply chromium-src ./ungoogled-chromium/patches
|
||||
|
||||
apply-michael-patches:
|
||||
cd chromium-src && git init
|
||||
cd chromium-src && git add chrome
|
||||
cd chromium-src && git commit -m 'chrome'
|
||||
cd chromium-src && patch -Np1 -i ../michael-patches/michael-customizations.patch
|
||||
|
||||
# only needed if patches need updates i.e. hunks failed
|
||||
update-michael-patches:
|
||||
cd chromium-src && git diff -p > ../michael-patches/michael-customizations.patch
|
||||
|
||||
# may warn/info about "path has no substitutions" a few (10-20) times
|
||||
subst-domains:
|
||||
mkdir -p chromium-src/cache
|
||||
./ungoogled-chromium/utils/domain_substitution.py apply \
|
||||
|
@ -0,0 +1,156 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/browser/ui/tabs/tab_menu_model.h"
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/i18n/rtl.h"
|
||||
#include "base/metrics/user_metrics.h"
|
||||
#include "build/build_config.h"
|
||||
#include "chrome/app/vector_icons/vector_icons.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/send_tab_to_self/send_tab_to_self_util.h"
|
||||
#include "chrome/browser/ui/tabs/existing_tab_group_sub_menu_model.h"
|
||||
#include "chrome/browser/ui/tabs/existing_window_sub_menu_model.h"
|
||||
#include "chrome/browser/ui/tabs/tab_menu_model_delegate.h"
|
||||
#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
||||
#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
|
||||
#include "chrome/browser/ui/tabs/tab_utils.h"
|
||||
#include "chrome/browser/ui/ui_features.h"
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "components/feed/feed_feature_list.h"
|
||||
#include "components/reading_list/features/reading_list_switches.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
|
||||
using base::UserMetricsAction;
|
||||
|
||||
TabMenuModel::TabMenuModel(ui::SimpleMenuModel::Delegate* delegate,
|
||||
TabMenuModelDelegate* tab_menu_model_delegate,
|
||||
TabStripModel* tab_strip,
|
||||
int index)
|
||||
: ui::SimpleMenuModel(delegate),
|
||||
tab_menu_model_delegate_(tab_menu_model_delegate) {
|
||||
Build(tab_strip, index);
|
||||
}
|
||||
|
||||
TabMenuModel::~TabMenuModel() = default;
|
||||
|
||||
void TabMenuModel::Build(TabStripModel* tab_strip, int index) {
|
||||
std::vector<int> indices;
|
||||
if (tab_strip->IsTabSelected(index)) {
|
||||
const ui::ListSelectionModel::SelectedIndices& sel =
|
||||
tab_strip->selection_model().selected_indices();
|
||||
indices = std::vector<int>(sel.begin(), sel.end());
|
||||
} else {
|
||||
indices = {index};
|
||||
}
|
||||
|
||||
int num_tabs = indices.size();
|
||||
AddItemWithStringId(TabStripModel::CommandNewTabToRight,
|
||||
base::i18n::IsRTL() ? IDS_TAB_CXMENU_NEWTABTOLEFT
|
||||
: IDS_TAB_CXMENU_NEWTABTORIGHT);
|
||||
// Add to Reading List
|
||||
// if (!tab_strip->profile()->IsGuestSession()) {
|
||||
// AddItem(
|
||||
// TabStripModel::CommandAddToReadLater,
|
||||
// l10n_util::GetPluralStringFUTF16(IDS_TAB_CXMENU_READ_LATER, num_tabs));
|
||||
// SetEnabledAt(GetItemCount() - 1,
|
||||
// tab_strip->IsReadLaterSupportedForAny(indices));
|
||||
// }
|
||||
// Change Tab Group
|
||||
// if (ExistingTabGroupSubMenuModel::ShouldShowSubmenu(
|
||||
// tab_strip, index, tab_menu_model_delegate_)) {
|
||||
// // Create submenu with existing groups
|
||||
// add_to_existing_group_submenu_ =
|
||||
// std::make_unique<ExistingTabGroupSubMenuModel>(
|
||||
// delegate(), tab_menu_model_delegate_, tab_strip, index);
|
||||
// AddSubMenu(TabStripModel::CommandAddToExistingGroup,
|
||||
// l10n_util::GetPluralStringFUTF16(IDS_TAB_CXMENU_ADD_TAB_TO_GROUP,
|
||||
// num_tabs),
|
||||
// add_to_existing_group_submenu_.get());
|
||||
// if (base::FeatureList::IsEnabled(features::kTabGroupsNewBadgePromo))
|
||||
// SetIsNewFeatureAt(GetItemCount() - 1, true);
|
||||
// } else {
|
||||
// AddItem(TabStripModel::CommandAddToNewGroup,
|
||||
// l10n_util::GetPluralStringFUTF16(
|
||||
// IDS_TAB_CXMENU_ADD_TAB_TO_NEW_GROUP, num_tabs));
|
||||
// SetElementIdentifierAt(GetItemCount() - 1, kAddToNewGroupItemIdentifier);
|
||||
// if (base::FeatureList::IsEnabled(features::kTabGroupsNewBadgePromo))
|
||||
// SetIsNewFeatureAt(GetItemCount() - 1, true);
|
||||
// }
|
||||
|
||||
// for (const auto& selection : indices) {
|
||||
// if (tab_strip->GetTabGroupForTab(selection).has_value()) {
|
||||
// AddItemWithStringId(TabStripModel::CommandRemoveFromGroup,
|
||||
// IDS_TAB_CXMENU_REMOVE_TAB_FROM_GROUP);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// New Window / Move to other Window
|
||||
if (ExistingWindowSubMenuModel::ShouldShowSubmenu(tab_strip->profile())) {
|
||||
// Create submenu with existing windows
|
||||
add_to_existing_window_submenu_ = ExistingWindowSubMenuModel::Create(
|
||||
delegate(), tab_menu_model_delegate_, tab_strip, index);
|
||||
AddSubMenu(TabStripModel::CommandMoveToExistingWindow,
|
||||
l10n_util::GetPluralStringFUTF16(
|
||||
IDS_TAB_CXMENU_MOVETOANOTHERWINDOW, num_tabs),
|
||||
add_to_existing_window_submenu_.get());
|
||||
} else {
|
||||
AddItem(TabStripModel::CommandMoveTabsToNewWindow,
|
||||
l10n_util::GetPluralStringFUTF16(
|
||||
IDS_TAB_CXMENU_MOVE_TABS_TO_NEW_WINDOW, num_tabs));
|
||||
}
|
||||
|
||||
AddSeparator(ui::NORMAL_SEPARATOR);
|
||||
// AddItemWithStringId(TabStripModel::CommandCloseTab, IDS_TAB_CXMENU_CLOSETAB);
|
||||
AddItemWithStringId(TabStripModel::CommandCloseOtherTabs,
|
||||
IDS_TAB_CXMENU_CLOSEOTHERTABS);
|
||||
AddItemWithStringId(TabStripModel::CommandCloseTabsToRight,
|
||||
base::i18n::IsRTL() ? IDS_TAB_CXMENU_CLOSETABSTOLEFT
|
||||
: IDS_TAB_CXMENU_CLOSETABSTORIGHT);
|
||||
|
||||
AddSeparator(ui::NORMAL_SEPARATOR);
|
||||
// AddItemWithStringId(TabStripModel::CommandReload, IDS_TAB_CXMENU_RELOAD);
|
||||
// AddItemWithStringId(TabStripModel::CommandDuplicate,
|
||||
// IDS_TAB_CXMENU_DUPLICATE);
|
||||
bool will_pin = tab_strip->WillContextMenuPin(index);
|
||||
AddItemWithStringId(
|
||||
TabStripModel::CommandTogglePinned,
|
||||
will_pin ? IDS_TAB_CXMENU_PIN_TAB : IDS_TAB_CXMENU_UNPIN_TAB);
|
||||
const bool will_mute = !chrome::AreAllSitesMuted(*tab_strip, indices);
|
||||
AddItem(TabStripModel::CommandToggleSiteMuted,
|
||||
will_mute ? l10n_util::GetPluralStringFUTF16(
|
||||
IDS_TAB_CXMENU_SOUND_MUTE_SITE, num_tabs)
|
||||
: l10n_util::GetPluralStringFUTF16(
|
||||
IDS_TAB_CXMENU_SOUND_UNMUTE_SITE, num_tabs));
|
||||
if (base::FeatureList::IsEnabled(feed::kWebUiFeed)) {
|
||||
const TabWebFeedFollowState follow_state =
|
||||
chrome::GetAggregatedFollowStateOfAllSites(*tab_strip, indices);
|
||||
if (follow_state == TabWebFeedFollowState::kNotFollowed) {
|
||||
AddItemWithStringId(TabStripModel::CommandFollowSite,
|
||||
IDS_TAB_CXMENU_FOLLOW_SITE);
|
||||
} else if (follow_state == TabWebFeedFollowState::kFollowed) {
|
||||
AddItemWithStringId(TabStripModel::CommandUnfollowSite,
|
||||
IDS_TAB_CXMENU_UNFOLLOW_SITE);
|
||||
}
|
||||
}
|
||||
if (send_tab_to_self::ShouldDisplayEntryPoint(
|
||||
tab_strip->GetWebContentsAt(index))) {
|
||||
AddSeparator(ui::NORMAL_SEPARATOR);
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
AddItem(TabStripModel::CommandSendTabToSelf,
|
||||
l10n_util::GetStringUTF16(IDS_CONTEXT_MENU_SEND_TAB_TO_SELF));
|
||||
#else
|
||||
AddItemWithIcon(
|
||||
TabStripModel::CommandSendTabToSelf,
|
||||
l10n_util::GetStringUTF16(IDS_CONTEXT_MENU_SEND_TAB_TO_SELF),
|
||||
ui::ImageModel::FromVectorIcon(kLaptopAndSmartphoneIcon));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(TabMenuModel,
|
||||
kAddToNewGroupItemIdentifier);
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,959 @@
|
||||
// Copyright 2013 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/i18n/number_formatting.h"
|
||||
#include "base/metrics/user_metrics.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "build/build_config.h"
|
||||
#include "build/chromeos_buildflags.h"
|
||||
#include "chrome/app/chrome_command_ids.h"
|
||||
#include "chrome/browser/apps/intent_helper/intent_picker_features.h"
|
||||
#include "chrome/browser/command_updater.h"
|
||||
#include "chrome/browser/download/bubble/download_bubble_prefs.h"
|
||||
#include "chrome/browser/media/router/media_router_feature.h"
|
||||
#include "chrome/browser/profiles/profile.h"
|
||||
#include "chrome/browser/profiles/profiles_state.h"
|
||||
#include "chrome/browser/share/share_features.h"
|
||||
#include "chrome/browser/themes/theme_properties.h"
|
||||
#include "chrome/browser/ui/browser.h"
|
||||
#include "chrome/browser/ui/browser_command_controller.h"
|
||||
#include "chrome/browser/ui/browser_commands.h"
|
||||
#include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
|
||||
#include "chrome/browser/ui/browser_tabstrip.h"
|
||||
#include "chrome/browser/ui/browser_window.h"
|
||||
#include "chrome/browser/ui/color/chrome_color_id.h"
|
||||
#include "chrome/browser/ui/global_error/global_error_service.h"
|
||||
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
|
||||
#include "chrome/browser/ui/intent_picker_tab_helper.h"
|
||||
#include "chrome/browser/ui/layout_constants.h"
|
||||
#include "chrome/browser/ui/side_search/side_search_utils.h"
|
||||
#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
||||
#include "chrome/browser/ui/toolbar/chrome_labs_prefs.h"
|
||||
#include "chrome/browser/ui/ui_features.h"
|
||||
#include "chrome/browser/ui/view_ids.h"
|
||||
#include "chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h"
|
||||
#include "chrome/browser/ui/views/download/bubble/download_toolbar_button_view.h"
|
||||
#include "chrome/browser/ui/views/extensions/extension_popup.h"
|
||||
#include "chrome/browser/ui/views/extensions/extensions_toolbar_button.h"
|
||||
#include "chrome/browser/ui/views/extensions/extensions_toolbar_container.h"
|
||||
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
|
||||
#include "chrome/browser/ui/views/frame/browser_view.h"
|
||||
#include "chrome/browser/ui/views/frame/top_container_background.h"
|
||||
#include "chrome/browser/ui/views/global_media_controls/media_toolbar_button_contextual_menu.h"
|
||||
#include "chrome/browser/ui/views/global_media_controls/media_toolbar_button_view.h"
|
||||
#include "chrome/browser/ui/views/location_bar/intent_chip_button.h"
|
||||
#include "chrome/browser/ui/views/location_bar/star_view.h"
|
||||
#include "chrome/browser/ui/views/media_router/cast_toolbar_button.h"
|
||||
#include "chrome/browser/ui/views/page_action/page_action_icon_container.h"
|
||||
#include "chrome/browser/ui/views/page_action/page_action_icon_controller.h"
|
||||
#include "chrome/browser/ui/views/send_tab_to_self/send_tab_to_self_toolbar_icon_view.h"
|
||||
#include "chrome/browser/ui/views/side_search/side_search_browser_controller.h"
|
||||
#include "chrome/browser/ui/views/tabs/tab_strip.h"
|
||||
#include "chrome/browser/ui/views/toolbar/app_menu.h"
|
||||
#include "chrome/browser/ui/views/toolbar/back_forward_button.h"
|
||||
#include "chrome/browser/ui/views/toolbar/browser_app_menu_button.h"
|
||||
#include "chrome/browser/ui/views/toolbar/chrome_labs_bubble_view_model.h"
|
||||
#include "chrome/browser/ui/views/toolbar/chrome_labs_button.h"
|
||||
#include "chrome/browser/ui/views/toolbar/chrome_labs_utils.h"
|
||||
#include "chrome/browser/ui/views/toolbar/home_button.h"
|
||||
#include "chrome/browser/ui/views/toolbar/reload_button.h"
|
||||
#include "chrome/browser/ui/views/toolbar/side_panel_toolbar_button.h"
|
||||
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
|
||||
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
|
||||
#include "chrome/browser/upgrade_detector/upgrade_detector.h"
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "chrome/common/pref_names.h"
|
||||
#include "chrome/grit/chromium_strings.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
#include "chrome/grit/theme_resources.h"
|
||||
#include "components/autofill/core/common/autofill_payments_features.h"
|
||||
#include "components/omnibox/browser/omnibox_view.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
#include "components/safe_browsing/core/common/features.h"
|
||||
#include "components/send_tab_to_self/features.h"
|
||||
#include "components/signin/public/base/signin_buildflags.h"
|
||||
#include "components/strings/grit/components_strings.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "media/base/media_switches.h"
|
||||
#include "ui/accessibility/ax_node_data.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||
#include "ui/base/theme_provider.h"
|
||||
#include "ui/base/window_open_disposition.h"
|
||||
#include "ui/color/color_id.h"
|
||||
#include "ui/color/color_provider.h"
|
||||
#include "ui/compositor/layer.h"
|
||||
#include "ui/gfx/canvas.h"
|
||||
#include "ui/gfx/image/canvas_image_source.h"
|
||||
#include "ui/gfx/paint_vector_icon.h"
|
||||
#include "ui/gfx/scoped_canvas.h"
|
||||
#include "ui/views/accessibility/view_accessibility.h"
|
||||
#include "ui/views/cascading_property.h"
|
||||
#include "ui/views/layout/fill_layout.h"
|
||||
#include "ui/views/layout/flex_layout.h"
|
||||
#include "ui/views/view_class_properties.h"
|
||||
#include "ui/views/widget/tooltip_manager.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
#include "ui/views/window/non_client_view.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
|
||||
#include "chrome/browser/recovery/recovery_install_global_error_factory.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "chrome/browser/ui/views/critical_notification_bubble_view.h"
|
||||
#endif
|
||||
|
||||
#if !BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
#include "chrome/browser/ui/bookmarks/bookmark_bubble_sign_in_delegate.h"
|
||||
#include "chrome/browser/ui/dialogs/outdated_upgrade_bubble.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_WEBUI_TAB_STRIP)
|
||||
#include "chrome/browser/ui/views/frame/webui_tab_strip_container_view.h"
|
||||
#endif // BUILDFLAG(ENABLE_WEBUI_TAB_STRIP)
|
||||
|
||||
#if defined(USE_AURA)
|
||||
#include "ui/aura/window_occlusion_tracker.h"
|
||||
#endif
|
||||
|
||||
using base::UserMetricsAction;
|
||||
using content::WebContents;
|
||||
|
||||
namespace {
|
||||
|
||||
// Gets the display mode for a given browser.
|
||||
ToolbarView::DisplayMode GetDisplayMode(Browser* browser) {
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
if (browser->is_type_custom_tab())
|
||||
return ToolbarView::DisplayMode::CUSTOM_TAB;
|
||||
#endif
|
||||
|
||||
// Checked in this order because even tabbed PWAs use the CUSTOM_TAB
|
||||
// display mode.
|
||||
if (web_app::AppBrowserController::IsWebApp(browser))
|
||||
return ToolbarView::DisplayMode::CUSTOM_TAB;
|
||||
|
||||
if (browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP))
|
||||
return ToolbarView::DisplayMode::NORMAL;
|
||||
|
||||
return ToolbarView::DisplayMode::LOCATION;
|
||||
}
|
||||
|
||||
auto& GetViewCommandMap() {
|
||||
static constexpr auto kViewCommandMap = base::MakeFixedFlatMap<int, int>(
|
||||
{{VIEW_ID_BACK_BUTTON, IDC_BACK},
|
||||
{VIEW_ID_FORWARD_BUTTON, IDC_FORWARD},
|
||||
{VIEW_ID_HOME_BUTTON, IDC_HOME},
|
||||
{VIEW_ID_RELOAD_BUTTON, IDC_RELOAD},
|
||||
{VIEW_ID_AVATAR_BUTTON, IDC_SHOW_AVATAR_MENU}});
|
||||
return kViewCommandMap;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ToolbarView, public:
|
||||
|
||||
ToolbarView::ToolbarView(Browser* browser, BrowserView* browser_view)
|
||||
: AnimationDelegateViews(this),
|
||||
browser_(browser),
|
||||
browser_view_(browser_view),
|
||||
app_menu_icon_controller_(browser->profile(), this),
|
||||
display_mode_(GetDisplayMode(browser)) {
|
||||
SetID(VIEW_ID_TOOLBAR);
|
||||
|
||||
UpgradeDetector::GetInstance()->AddObserver(this);
|
||||
|
||||
if (display_mode_ == DisplayMode::NORMAL) {
|
||||
SetBackground(std::make_unique<TopContainerBackground>(browser_view));
|
||||
|
||||
for (const auto& view_and_command : GetViewCommandMap())
|
||||
chrome::AddCommandObserver(browser_, view_and_command.second, this);
|
||||
}
|
||||
views::SetCascadingColorProviderColor(this, views::kCascadingBackgroundColor,
|
||||
kColorToolbar);
|
||||
}
|
||||
|
||||
ToolbarView::~ToolbarView() {
|
||||
UpgradeDetector::GetInstance()->RemoveObserver(this);
|
||||
|
||||
if (display_mode_ != DisplayMode::NORMAL)
|
||||
return;
|
||||
|
||||
for (const auto& view_and_command : GetViewCommandMap())
|
||||
chrome::RemoveCommandObserver(browser_, view_and_command.second, this);
|
||||
}
|
||||
|
||||
void ToolbarView::Init() {
|
||||
#if defined(USE_AURA)
|
||||
// Avoid generating too many occlusion tracking calculation events before this
|
||||
// function returns. The occlusion status will be computed only once once this
|
||||
// function returns.
|
||||
// See crbug.com/1183894#c2
|
||||
aura::WindowOcclusionTracker::ScopedPause pause_occlusion;
|
||||
#endif
|
||||
auto location_bar = std::make_unique<LocationBarView>(
|
||||
browser_, browser_->profile(), browser_->command_controller(), this,
|
||||
display_mode_ != DisplayMode::NORMAL);
|
||||
// Make sure the toolbar shows by default.
|
||||
size_animation_.Reset(1);
|
||||
|
||||
if (display_mode_ != DisplayMode::NORMAL) {
|
||||
location_bar_ = AddChildView(std::move(location_bar));
|
||||
location_bar_->Init();
|
||||
|
||||
if (display_mode_ == DisplayMode::CUSTOM_TAB) {
|
||||
custom_tab_bar_ =
|
||||
AddChildView(std::make_unique<CustomTabBarView>(browser_view_, this));
|
||||
}
|
||||
|
||||
SetLayoutManager(std::make_unique<views::FillLayout>());
|
||||
initialized_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const auto callback = [](Browser* browser, int command,
|
||||
const ui::Event& event) {
|
||||
chrome::ExecuteCommandWithDisposition(
|
||||
browser, command, ui::DispositionFromEventFlags(event.flags()));
|
||||
};
|
||||
|
||||
std::unique_ptr<ToolbarButton> back = std::make_unique<BackForwardButton>(
|
||||
BackForwardButton::Direction::kBack,
|
||||
base::BindRepeating(callback, browser_, IDC_BACK), browser_);
|
||||
|
||||
std::unique_ptr<ToolbarButton> forward = std::make_unique<BackForwardButton>(
|
||||
BackForwardButton::Direction::kForward,
|
||||
base::BindRepeating(callback, browser_, IDC_FORWARD), browser_);
|
||||
|
||||
std::unique_ptr<ReloadButton> reload =
|
||||
std::make_unique<ReloadButton>(browser_->command_controller());
|
||||
|
||||
PrefService* const prefs = browser_->profile()->GetPrefs();
|
||||
std::unique_ptr<HomeButton> home = std::make_unique<HomeButton>(
|
||||
base::BindRepeating(callback, browser_, IDC_HOME), prefs);
|
||||
|
||||
std::unique_ptr<ExtensionsToolbarContainer> extensions_container;
|
||||
|
||||
// Do not create the extensions or browser actions container if it is a guest
|
||||
// profile (only regular and incognito profiles host extensions).
|
||||
if (!browser_->profile()->IsGuestSession()) {
|
||||
extensions_container =
|
||||
std::make_unique<ExtensionsToolbarContainer>(browser_);
|
||||
}
|
||||
std::unique_ptr<media_router::CastToolbarButton> cast;
|
||||
if (media_router::MediaRouterEnabled(browser_->profile()))
|
||||
cast = media_router::CastToolbarButton::Create(browser_);
|
||||
|
||||
std::unique_ptr<MediaToolbarButtonView> media_button;
|
||||
if (base::FeatureList::IsEnabled(media::kGlobalMediaControls)) {
|
||||
media_button = std::make_unique<MediaToolbarButtonView>(
|
||||
browser_view_, MediaToolbarButtonContextualMenu::Create(browser_));
|
||||
}
|
||||
|
||||
std::unique_ptr<DownloadToolbarButtonView> download_button;
|
||||
if (download::IsDownloadBubbleEnabled(browser_->profile())) {
|
||||
download_button =
|
||||
std::make_unique<DownloadToolbarButtonView>(browser_view_);
|
||||
}
|
||||
|
||||
std::unique_ptr<send_tab_to_self::SendTabToSelfToolbarIconView>
|
||||
send_tab_to_self_button;
|
||||
if (!browser_->profile()->IsOffTheRecord()) {
|
||||
send_tab_to_self_button =
|
||||
std::make_unique<send_tab_to_self::SendTabToSelfToolbarIconView>(
|
||||
browser_view_);
|
||||
}
|
||||
|
||||
std::unique_ptr<SidePanelToolbarButton> side_panel_button;
|
||||
if (browser_view_->right_aligned_side_panel()) {
|
||||
side_panel_button = std::make_unique<SidePanelToolbarButton>(browser_);
|
||||
}
|
||||
|
||||
// Always add children in order from left to right, for accessibility.
|
||||
back_ = AddChildView(std::move(back));
|
||||
forward_ = AddChildView(std::move(forward));
|
||||
reload_ = AddChildView(std::move(reload));
|
||||
home_ = AddChildView(std::move(home));
|
||||
|
||||
// The side search button (if enabled) should sit between the location bar and
|
||||
// the other navigation buttons.
|
||||
if (browser_view_->side_search_controller() &&
|
||||
!side_search::IsDSESupportEnabled(browser_->profile())) {
|
||||
left_side_panel_button_ = AddChildView(
|
||||
browser_view_->side_search_controller()->CreateToolbarButton());
|
||||
}
|
||||
|
||||
location_bar_ = AddChildView(std::move(location_bar));
|
||||
|
||||
if (extensions_container)
|
||||
extensions_container_ = AddChildView(std::move(extensions_container));
|
||||
|
||||
if (base::FeatureList::IsEnabled(features::kChromeLabs)) {
|
||||
chrome_labs_model_ = std::make_unique<ChromeLabsBubbleViewModel>();
|
||||
UpdateChromeLabsNewBadgePrefs(browser_->profile(),
|
||||
chrome_labs_model_.get());
|
||||
if (ChromeLabsButton::ShouldShowButton(chrome_labs_model_.get(),
|
||||
browser_->profile())) {
|
||||
chrome_labs_button_ = AddChildView(std::make_unique<ChromeLabsButton>(
|
||||
browser_view_, chrome_labs_model_.get()));
|
||||
|
||||
show_chrome_labs_button_.Init(
|
||||
chrome_labs_prefs::kBrowserLabsEnabled, prefs,
|
||||
base::BindRepeating(&ToolbarView::OnChromeLabsPrefChanged,
|
||||
base::Unretained(this)));
|
||||
// Set the visibility for the button based on initial enterprise policy
|
||||
// value. Only call OnChromeLabsPrefChanged if there is a change from the
|
||||
// initial value.
|
||||
chrome_labs_button_->SetVisible(show_chrome_labs_button_.GetValue());
|
||||
}
|
||||
}
|
||||
|
||||
if (cast)
|
||||
cast_ = AddChildView(std::move(cast));
|
||||
|
||||
if (media_button)
|
||||
media_button_ = AddChildView(std::move(media_button));
|
||||
|
||||
if (download_button)
|
||||
download_button_ = AddChildView(std::move(download_button));
|
||||
|
||||
if (send_tab_to_self_button)
|
||||
send_tab_to_self_button_ = AddChildView(std::move(send_tab_to_self_button));
|
||||
|
||||
// if (side_panel_button)
|
||||
// side_panel_button_ = AddChildView(std::move(side_panel_button));
|
||||
|
||||
avatar_ = AddChildView(std::make_unique<AvatarToolbarButton>(browser_view_));
|
||||
|
||||
const base::CommandLine& command_line =
|
||||
*base::CommandLine::ForCurrentProcess();
|
||||
const std::string flag_value =
|
||||
command_line.GetSwitchValueASCII("show-avatar-button");
|
||||
|
||||
bool in_incognito_or_guest_mode = browser_->profile()->IsOffTheRecord() ||
|
||||
browser_->profile()->IsGuestSession();
|
||||
|
||||
bool show_avatar_toolbar_button = true;
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// ChromeOS only badges Incognito and Guest icons in the browser window.
|
||||
show_avatar_toolbar_button = in_incognito_or_guest_mode;
|
||||
#elif BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
show_avatar_toolbar_button = !profiles::IsPublicSession();
|
||||
#endif
|
||||
|
||||
if (flag_value == "always")
|
||||
show_avatar_toolbar_button = true;
|
||||
else if (flag_value == "incognito-and-guest")
|
||||
show_avatar_toolbar_button = in_incognito_or_guest_mode;
|
||||
else if (flag_value == "never")
|
||||
show_avatar_toolbar_button = false;
|
||||
|
||||
// Always disable avatar / account icon
|
||||
avatar_->SetVisible(false);
|
||||
|
||||
auto app_menu_button = std::make_unique<BrowserAppMenuButton>(this);
|
||||
app_menu_button->SetFlipCanvasOnPaintForRTLUI(true);
|
||||
app_menu_button->SetAccessibleName(
|
||||
l10n_util::GetStringUTF16(IDS_ACCNAME_APP));
|
||||
app_menu_button->SetTooltipText(
|
||||
l10n_util::GetStringUTF16(IDS_APPMENU_TOOLTIP));
|
||||
app_menu_button->SetID(VIEW_ID_APP_MENU);
|
||||
app_menu_button_ = AddChildView(std::move(app_menu_button));
|
||||
|
||||
LoadImages();
|
||||
|
||||
// Start global error services now so we set the icon on the menu correctly.
|
||||
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
|
||||
RecoveryInstallGlobalErrorFactory::GetForProfile(browser_->profile());
|
||||
#endif // BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
|
||||
|
||||
// Set the button icon based on the system state. Do this after
|
||||
// |app_menu_button_| has been added as a bubble may be shown that needs
|
||||
// the widget (widget found by way of app_menu_button_->GetWidget()).
|
||||
app_menu_icon_controller_.UpdateDelegate();
|
||||
|
||||
location_bar_->Init();
|
||||
|
||||
show_home_button_.Init(
|
||||
prefs::kShowHomeButton, prefs,
|
||||
base::BindRepeating(&ToolbarView::OnShowHomeButtonChanged,
|
||||
base::Unretained(this)));
|
||||
|
||||
home_->SetVisible(show_home_button_.GetValue());
|
||||
|
||||
InitLayout();
|
||||
|
||||
for (auto* button : std::array<views::Button*, 5>{back_, forward_, reload_,
|
||||
home_, avatar_}) {
|
||||
if (button)
|
||||
button->set_tag(GetViewCommandMap().at(button->GetID()));
|
||||
}
|
||||
|
||||
initialized_ = true;
|
||||
}
|
||||
|
||||
void ToolbarView::AnimationEnded(const gfx::Animation* animation) {
|
||||
if (animation->GetCurrentValue() == 0)
|
||||
SetToolbarVisibility(false);
|
||||
browser()->window()->ToolbarSizeChanged(/*is_animating=*/false);
|
||||
}
|
||||
|
||||
void ToolbarView::AnimationProgressed(const gfx::Animation* animation) {
|
||||
browser()->window()->ToolbarSizeChanged(/*is_animating=*/true);
|
||||
}
|
||||
|
||||
void ToolbarView::Update(WebContents* tab) {
|
||||
if (location_bar_)
|
||||
location_bar_->Update(tab);
|
||||
|
||||
if (extensions_container_)
|
||||
extensions_container_->UpdateAllIcons();
|
||||
|
||||
if (reload_)
|
||||
reload_->SetMenuEnabled(chrome::IsDebuggerAttachedToCurrentTab(browser_));
|
||||
}
|
||||
|
||||
void ToolbarView::SetToolbarVisibility(bool visible) {
|
||||
SetVisible(visible);
|
||||
views::View* bar = display_mode_ == DisplayMode::CUSTOM_TAB
|
||||
? static_cast<views::View*>(custom_tab_bar_)
|
||||
: static_cast<views::View*>(location_bar_);
|
||||
|
||||
bar->SetVisible(visible);
|
||||
}
|
||||
|
||||
void ToolbarView::UpdateCustomTabBarVisibility(bool visible, bool animate) {
|
||||
DCHECK_EQ(display_mode_, DisplayMode::CUSTOM_TAB);
|
||||
|
||||
if (!animate) {
|
||||
size_animation_.Reset(visible ? 1.0 : 0.0);
|
||||
SetToolbarVisibility(visible);
|
||||
browser()->window()->ToolbarSizeChanged(/*is_animating=*/false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (visible) {
|
||||
SetToolbarVisibility(true);
|
||||
size_animation_.Show();
|
||||
} else {
|
||||
size_animation_.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
void ToolbarView::UpdateForWebUITabStrip() {
|
||||
#if BUILDFLAG(ENABLE_WEBUI_TAB_STRIP)
|
||||
if (browser_view_->webui_tab_strip() && app_menu_button_) {
|
||||
const size_t insertion_index = GetIndexOf(app_menu_button_).value();
|
||||
AddChildViewAt(browser_view_->webui_tab_strip()->CreateNewTabButton(),
|
||||
insertion_index);
|
||||
AddChildViewAt(browser_view_->webui_tab_strip()->CreateTabCounter(),
|
||||
insertion_index);
|
||||
LoadImages();
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_WEBUI_TAB_STRIP)
|
||||
}
|
||||
|
||||
void ToolbarView::ResetTabState(WebContents* tab) {
|
||||
if (location_bar_)
|
||||
location_bar_->ResetTabState(tab);
|
||||
}
|
||||
|
||||
void ToolbarView::SetPaneFocusAndFocusAppMenu() {
|
||||
if (app_menu_button_)
|
||||
SetPaneFocus(app_menu_button_);
|
||||
}
|
||||
|
||||
bool ToolbarView::GetAppMenuFocused() const {
|
||||
return app_menu_button_ && app_menu_button_->HasFocus();
|
||||
}
|
||||
|
||||
void ToolbarView::ShowIntentPickerBubble(
|
||||
std::vector<IntentPickerBubbleView::AppInfo> app_info,
|
||||
bool show_stay_in_chrome,
|
||||
bool show_remember_selection,
|
||||
IntentPickerBubbleView::BubbleType bubble_type,
|
||||
const absl::optional<url::Origin>& initiating_origin,
|
||||
IntentPickerResponse callback) {
|
||||
views::Button* highlighted_button = nullptr;
|
||||
if (bubble_type == IntentPickerBubbleView::BubbleType::kClickToCall) {
|
||||
highlighted_button =
|
||||
|
||||
GetPageActionIconView(PageActionIconType::kClickToCall);
|
||||
} else if (apps::features::LinkCapturingUiUpdateEnabled()) {
|
||||
highlighted_button = GetIntentChipButton();
|
||||
} else {
|
||||
highlighted_button =
|
||||
GetPageActionIconView(PageActionIconType::kIntentPicker);
|
||||
}
|
||||
|
||||
if (!highlighted_button)
|
||||
return;
|
||||
|
||||
IntentPickerBubbleView::ShowBubble(
|
||||
location_bar(), highlighted_button, bubble_type, GetWebContents(),
|
||||
std::move(app_info), show_stay_in_chrome, show_remember_selection,
|
||||
initiating_origin, std::move(callback));
|
||||
}
|
||||
|
||||
void ToolbarView::ShowBookmarkBubble(
|
||||
const GURL& url,
|
||||
bool already_bookmarked,
|
||||
bookmarks::BookmarkBubbleObserver* observer) {
|
||||
views::View* const anchor_view = location_bar();
|
||||
PageActionIconView* const bookmark_star_icon =
|
||||
GetPageActionIconView(PageActionIconType::kBookmarkStar);
|
||||
|
||||
std::unique_ptr<BubbleSyncPromoDelegate> delegate;
|
||||
Profile* profile = browser_->profile();
|
||||
#if !BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
delegate = std::make_unique<BookmarkBubbleSignInDelegate>(profile);
|
||||
#endif
|
||||
BookmarkBubbleView::ShowBubble(anchor_view, bookmark_star_icon, observer,
|
||||
std::move(delegate), profile, url,
|
||||
already_bookmarked);
|
||||
}
|
||||
|
||||
ExtensionsToolbarButton* ToolbarView::GetExtensionsButton() const {
|
||||
return extensions_container_->GetExtensionsButton();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ToolbarView, LocationBarView::Delegate implementation:
|
||||
|
||||
WebContents* ToolbarView::GetWebContents() {
|
||||
return browser_->tab_strip_model()->GetActiveWebContents();
|
||||
}
|
||||
|
||||
LocationBarModel* ToolbarView::GetLocationBarModel() {
|
||||
return browser_->location_bar_model();
|
||||
}
|
||||
|
||||
const LocationBarModel* ToolbarView::GetLocationBarModel() const {
|
||||
return browser_->location_bar_model();
|
||||
}
|
||||
|
||||
ContentSettingBubbleModelDelegate*
|
||||
ToolbarView::GetContentSettingBubbleModelDelegate() {
|
||||
return browser_->content_setting_bubble_model_delegate();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ToolbarView, CommandObserver implementation:
|
||||
|
||||
void ToolbarView::EnabledStateChangedForCommand(int id, bool enabled) {
|
||||
DCHECK(display_mode_ == DisplayMode::NORMAL);
|
||||
const std::array<views::Button*, 5> kButtons{back_, forward_, reload_, home_,
|
||||
avatar_};
|
||||
auto* button = *base::ranges::find(kButtons, id, &views::Button::tag);
|
||||
DCHECK(button);
|
||||
button->SetEnabled(enabled);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ToolbarView, UpgradeObserver implementation:
|
||||
void ToolbarView::OnOutdatedInstall() {
|
||||
ShowOutdatedInstallNotification(true);
|
||||
}
|
||||
|
||||
void ToolbarView::OnOutdatedInstallNoAutoUpdate() {
|
||||
ShowOutdatedInstallNotification(false);
|
||||
}
|
||||
|
||||
void ToolbarView::OnCriticalUpgradeInstalled() {
|
||||
ShowCriticalNotification();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ToolbarView, ui::AcceleratorProvider implementation:
|
||||
|
||||
bool ToolbarView::GetAcceleratorForCommandId(
|
||||
int command_id,
|
||||
ui::Accelerator* accelerator) const {
|
||||
return GetWidget()->GetAccelerator(command_id, accelerator);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ToolbarView, views::View overrides:
|
||||
|
||||
gfx::Size ToolbarView::CalculatePreferredSize() const {
|
||||
gfx::Size size;
|
||||
switch (display_mode_) {
|
||||
case DisplayMode::CUSTOM_TAB:
|
||||
size = custom_tab_bar_->GetPreferredSize();
|
||||
break;
|
||||
case DisplayMode::LOCATION:
|
||||
size = location_bar_->GetPreferredSize();
|
||||
break;
|
||||
case DisplayMode::NORMAL:
|
||||
size = View::CalculatePreferredSize();
|
||||
// Because there are odd cases where something causes one of the views in
|
||||
// the toolbar to report an unreasonable height (see crbug.com/985909), we
|
||||
// cap the height at the size of known child views (location bar and back
|
||||
// button) plus margins.
|
||||
// TODO(crbug.com/1033627): Figure out why the height reports incorrectly
|
||||
// on some installations.
|
||||
if (layout_manager_ && location_bar_->GetVisible()) {
|
||||
const int max_height =
|
||||
std::max(location_bar_->GetPreferredSize().height(),
|
||||
back_->GetPreferredSize().height()) +
|
||||
layout_manager_->interior_margin().height();
|
||||
size.SetToMin({size.width(), max_height});
|
||||
}
|
||||
}
|
||||
size.set_height(size.height() * size_animation_.GetCurrentValue());
|
||||
return size;
|
||||
}
|
||||
|
||||
gfx::Size ToolbarView::GetMinimumSize() const {
|
||||
gfx::Size size;
|
||||
switch (display_mode_) {
|
||||
case DisplayMode::CUSTOM_TAB:
|
||||
size = custom_tab_bar_->GetMinimumSize();
|
||||
break;
|
||||
case DisplayMode::LOCATION:
|
||||
size = location_bar_->GetMinimumSize();
|
||||
break;
|
||||
case DisplayMode::NORMAL:
|
||||
size = View::GetMinimumSize();
|
||||
// Because there are odd cases where something causes one of the views in
|
||||
// the toolbar to report an unreasonable height (see crbug.com/985909), we
|
||||
// cap the height at the size of known child views (location bar and back
|
||||
// button) plus margins.
|
||||
// TODO(crbug.com/1033627): Figure out why the height reports incorrectly
|
||||
// on some installations.
|
||||
if (layout_manager_ && location_bar_->GetVisible()) {
|
||||
const int max_height =
|
||||
std::max(location_bar_->GetMinimumSize().height(),
|
||||
back_->GetMinimumSize().height()) +
|
||||
layout_manager_->interior_margin().height();
|
||||
size.SetToMin({size.width(), max_height});
|
||||
}
|
||||
}
|
||||
size.set_height(size.height() * size_animation_.GetCurrentValue());
|
||||
return size;
|
||||
}
|
||||
|
||||
void ToolbarView::Layout() {
|
||||
// If we have not been initialized yet just do nothing.
|
||||
if (!initialized_)
|
||||
return;
|
||||
|
||||
if (display_mode_ == DisplayMode::CUSTOM_TAB) {
|
||||
custom_tab_bar_->SetBounds(0, 0, width(),
|
||||
custom_tab_bar_->GetPreferredSize().height());
|
||||
location_bar_->SetVisible(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (display_mode_ == DisplayMode::LOCATION) {
|
||||
location_bar_->SetBounds(0, 0, width(),
|
||||
location_bar_->GetPreferredSize().height());
|
||||
return;
|
||||
}
|
||||
|
||||
LayoutCommon();
|
||||
|
||||
// Call super implementation to ensure layout manager and child layouts
|
||||
// happen.
|
||||
AccessiblePaneView::Layout();
|
||||
}
|
||||
|
||||
void ToolbarView::OnThemeChanged() {
|
||||
views::AccessiblePaneView::OnThemeChanged();
|
||||
if (!initialized_)
|
||||
return;
|
||||
|
||||
if (display_mode_ == DisplayMode::NORMAL)
|
||||
LoadImages();
|
||||
|
||||
SchedulePaint();
|
||||
}
|
||||
|
||||
bool ToolbarView::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
||||
const views::View* focused_view = focus_manager()->GetFocusedView();
|
||||
if (focused_view && (focused_view->GetID() == VIEW_ID_OMNIBOX))
|
||||
return false; // Let the omnibox handle all accelerator events.
|
||||
return AccessiblePaneView::AcceleratorPressed(accelerator);
|
||||
}
|
||||
|
||||
void ToolbarView::ChildPreferredSizeChanged(views::View* child) {
|
||||
InvalidateLayout();
|
||||
if (size() != GetPreferredSize())
|
||||
PreferredSizeChanged();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// ToolbarView, private:
|
||||
|
||||
// Override this so that when the user presses F6 to rotate toolbar panes,
|
||||
// the location bar gets focus, not the first control in the toolbar - and
|
||||
// also so that it selects all content in the location bar.
|
||||
views::View* ToolbarView::GetDefaultFocusableChild() {
|
||||
return location_bar_;
|
||||
}
|
||||
|
||||
void ToolbarView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
|
||||
node_data->role = ax::mojom::Role::kToolbar;
|
||||
}
|
||||
|
||||
void ToolbarView::InitLayout() {
|
||||
const int default_margin = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING);
|
||||
// TODO(dfried): rename this constant.
|
||||
const int location_bar_margin = GetLayoutConstant(TOOLBAR_STANDARD_SPACING);
|
||||
const views::FlexSpecification account_container_flex_rule =
|
||||
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToMinimum,
|
||||
views::MaximumFlexSizeRule::kPreferred)
|
||||
.WithOrder(1);
|
||||
const views::FlexSpecification location_bar_flex_rule =
|
||||
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToMinimum,
|
||||
views::MaximumFlexSizeRule::kUnbounded)
|
||||
.WithOrder(2);
|
||||
constexpr int kExtensionsFlexOrder = 3;
|
||||
|
||||
layout_manager_ = SetLayoutManager(std::make_unique<views::FlexLayout>());
|
||||
|
||||
layout_manager_->SetOrientation(views::LayoutOrientation::kHorizontal)
|
||||
.SetCrossAxisAlignment(views::LayoutAlignment::kCenter)
|
||||
.SetCollapseMargins(true)
|
||||
.SetDefault(views::kMarginsKey, gfx::Insets::VH(0, default_margin));
|
||||
|
||||
location_bar_->SetProperty(views::kFlexBehaviorKey, location_bar_flex_rule);
|
||||
location_bar_->SetProperty(views::kMarginsKey,
|
||||
gfx::Insets::VH(0, location_bar_margin));
|
||||
|
||||
if (extensions_container_) {
|
||||
const views::FlexSpecification extensions_flex_rule =
|
||||
views::FlexSpecification(
|
||||
extensions_container_->GetAnimatingLayoutManager()
|
||||
->GetDefaultFlexRule())
|
||||
.WithOrder(kExtensionsFlexOrder);
|
||||
|
||||
extensions_container_->SetProperty(views::kFlexBehaviorKey,
|
||||
extensions_flex_rule);
|
||||
}
|
||||
|
||||
LayoutCommon();
|
||||
}
|
||||
|
||||
void ToolbarView::LayoutCommon() {
|
||||
DCHECK(display_mode_ == DisplayMode::NORMAL);
|
||||
|
||||
const gfx::Insets interior_margin =
|
||||
GetLayoutInsets(browser_view_->webui_tab_strip()
|
||||
? LayoutInset::WEBUI_TAB_STRIP_TOOLBAR_INTERIOR_MARGIN
|
||||
: LayoutInset::TOOLBAR_INTERIOR_MARGIN);
|
||||
layout_manager_->SetInteriorMargin(interior_margin);
|
||||
|
||||
// Extend buttons to the window edge if we're either in a maximized or
|
||||
// fullscreen window. This makes the buttons easier to hit, see Fitts' law.
|
||||
const bool extend_buttons_to_edge =
|
||||
browser_->window() &&
|
||||
(browser_->window()->IsMaximized() || browser_->window()->IsFullscreen());
|
||||
back_->SetLeadingMargin(extend_buttons_to_edge ? interior_margin.left() : 0);
|
||||
app_menu_button_->SetTrailingMargin(
|
||||
extend_buttons_to_edge ? interior_margin.right() : 0);
|
||||
|
||||
// Cast button visibility is controlled externally.
|
||||
}
|
||||
|
||||
// AppMenuIconController::Delegate:
|
||||
void ToolbarView::UpdateTypeAndSeverity(
|
||||
AppMenuIconController::TypeAndSeverity type_and_severity) {
|
||||
// There's no app menu in tabless windows.
|
||||
if (!app_menu_button_)
|
||||
return;
|
||||
|
||||
std::u16string accname_app = l10n_util::GetStringUTF16(IDS_ACCNAME_APP);
|
||||
if (type_and_severity.type ==
|
||||
AppMenuIconController::IconType::UPGRADE_NOTIFICATION) {
|
||||
accname_app = l10n_util::GetStringFUTF16(
|
||||
IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app);
|
||||
}
|
||||
app_menu_button_->SetAccessibleName(accname_app);
|
||||
app_menu_button_->SetTypeAndSeverity(type_and_severity);
|
||||
}
|
||||
|
||||
SkColor ToolbarView::GetDefaultColorForSeverity(
|
||||
AppMenuIconController::Severity severity) const {
|
||||
ui::ColorId color_id;
|
||||
switch (severity) {
|
||||
case AppMenuIconController::Severity::NONE:
|
||||
return GetColorProvider()->GetColor(kColorToolbarButtonIcon);
|
||||
case AppMenuIconController::Severity::LOW:
|
||||
color_id = ui::kColorAlertLowSeverity;
|
||||
break;
|
||||
case AppMenuIconController::Severity::MEDIUM:
|
||||
color_id = ui::kColorAlertMediumSeverity;
|
||||
break;
|
||||
case AppMenuIconController::Severity::HIGH:
|
||||
color_id = ui::kColorAlertHighSeverity;
|
||||
break;
|
||||
}
|
||||
return GetColorProvider()->GetColor(color_id);
|
||||
}
|
||||
|
||||
ExtensionsToolbarContainer* ToolbarView::GetExtensionsToolbarContainer() {
|
||||
return extensions_container_;
|
||||
}
|
||||
|
||||
gfx::Size ToolbarView::GetToolbarButtonSize() const {
|
||||
const int size = GetLayoutConstant(LayoutConstant::TOOLBAR_BUTTON_HEIGHT);
|
||||
return gfx::Size(size, size);
|
||||
}
|
||||
|
||||
views::View* ToolbarView::GetDefaultExtensionDialogAnchorView() {
|
||||
if (extensions_container_)
|
||||
return extensions_container_->GetExtensionsButton();
|
||||
return GetAppMenuButton();
|
||||
}
|
||||
|
||||
PageActionIconView* ToolbarView::GetPageActionIconView(
|
||||
PageActionIconType type) {
|
||||
return location_bar()->page_action_icon_controller()->GetIconView(type);
|
||||
}
|
||||
|
||||
AppMenuButton* ToolbarView::GetAppMenuButton() {
|
||||
if (app_menu_button_)
|
||||
return app_menu_button_;
|
||||
|
||||
return custom_tab_bar_ ? custom_tab_bar_->custom_tab_menu_button() : nullptr;
|
||||
}
|
||||
|
||||
gfx::Rect ToolbarView::GetFindBarBoundingBox(int contents_bottom) {
|
||||
if (!browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR))
|
||||
return gfx::Rect();
|
||||
|
||||
if (!location_bar_->IsDrawn())
|
||||
return gfx::Rect();
|
||||
|
||||
gfx::Rect bounds =
|
||||
location_bar_->ConvertRectToWidget(location_bar_->GetLocalBounds());
|
||||
return gfx::Rect(bounds.x(), bounds.bottom(), bounds.width(),
|
||||
contents_bottom - bounds.bottom());
|
||||
}
|
||||
|
||||
void ToolbarView::FocusToolbar() {
|
||||
SetPaneFocus(nullptr);
|
||||
}
|
||||
|
||||
views::AccessiblePaneView* ToolbarView::GetAsAccessiblePaneView() {
|
||||
return this;
|
||||
}
|
||||
|
||||
views::View* ToolbarView::GetAnchorView(PageActionIconType type) {
|
||||
return location_bar_;
|
||||
}
|
||||
|
||||
void ToolbarView::ZoomChangedForActiveTab(bool can_show_bubble) {
|
||||
location_bar_->page_action_icon_controller()->ZoomChangedForActiveTab(
|
||||
can_show_bubble);
|
||||
}
|
||||
|
||||
SidePanelToolbarButton* ToolbarView::GetSidePanelButton() {
|
||||
return side_panel_button_;
|
||||
}
|
||||
|
||||
AvatarToolbarButton* ToolbarView::GetAvatarToolbarButton() {
|
||||
if (avatar_)
|
||||
return avatar_;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ToolbarButton* ToolbarView::GetBackButton() {
|
||||
return back_;
|
||||
}
|
||||
|
||||
ReloadButton* ToolbarView::GetReloadButton() {
|
||||
return reload_;
|
||||
}
|
||||
|
||||
IntentChipButton* ToolbarView::GetIntentChipButton() {
|
||||
return location_bar()->intent_chip();
|
||||
}
|
||||
|
||||
BrowserRootView::DropIndex ToolbarView::GetDropIndex(
|
||||
const ui::DropTargetEvent& event) {
|
||||
return {browser_->tab_strip_model()->active_index(), false};
|
||||
}
|
||||
|
||||
BrowserRootView::DropTarget* ToolbarView::GetDropTarget(
|
||||
gfx::Point loc_in_local_coords) {
|
||||
return HitTestPoint(loc_in_local_coords) ? this : nullptr;
|
||||
}
|
||||
|
||||
views::View* ToolbarView::GetViewForDrop() {
|
||||
return this;
|
||||
}
|
||||
|
||||
void ToolbarView::OnChromeLabsPrefChanged() {
|
||||
chrome_labs_button_->SetVisible(show_chrome_labs_button_.GetValue());
|
||||
GetViewAccessibility().AnnounceText(l10n_util::GetStringUTF16(
|
||||
chrome_labs_button_->GetVisible()
|
||||
? IDS_ACCESSIBLE_TEXT_CHROMELABS_BUTTON_ADDED_BY_ENTERPRISE_POLICY
|
||||
: IDS_ACCESSIBLE_TEXT_CHROMELABS_BUTTON_REMOVED_BY_ENTERPRISE_POLICY));
|
||||
}
|
||||
|
||||
void ToolbarView::LoadImages() {
|
||||
DCHECK_EQ(display_mode_, DisplayMode::NORMAL);
|
||||
|
||||
if (extensions_container_)
|
||||
extensions_container_->UpdateAllIcons();
|
||||
}
|
||||
|
||||
void ToolbarView::ShowCriticalNotification() {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
views::BubbleDialogDelegateView::CreateBubble(
|
||||
new CriticalNotificationBubbleView(app_menu_button_))
|
||||
->Show();
|
||||
#endif
|
||||
}
|
||||
|
||||
void ToolbarView::ShowOutdatedInstallNotification(bool auto_update_enabled) {
|
||||
#if !BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// TODO(pbos): Can this move outside ToolbarView completely?
|
||||
ShowOutdatedUpgradeBubble(browser_, auto_update_enabled);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ToolbarView::OnShowHomeButtonChanged() {
|
||||
home_->SetVisible(show_home_button_.GetValue());
|
||||
Layout();
|
||||
SchedulePaint();
|
||||
}
|
||||
|
||||
void ToolbarView::OnTouchUiChanged() {
|
||||
if (display_mode_ == DisplayMode::NORMAL) {
|
||||
// Update the internal margins for touch layout.
|
||||
// TODO(dfried): I think we can do better than this by making the touch UI
|
||||
// code cleaner.
|
||||
const int default_margin = GetLayoutConstant(TOOLBAR_ELEMENT_PADDING);
|
||||
const int location_bar_margin = GetLayoutConstant(TOOLBAR_STANDARD_SPACING);
|
||||
layout_manager_->SetDefault(views::kMarginsKey,
|
||||
gfx::Insets::VH(0, default_margin));
|
||||
location_bar_->SetProperty(views::kMarginsKey,
|
||||
gfx::Insets::VH(0, location_bar_margin));
|
||||
|
||||
LoadImages();
|
||||
PreferredSizeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
BEGIN_METADATA(ToolbarView, views::AccessiblePaneView)
|
||||
ADD_READONLY_PROPERTY_METADATA(bool, AppMenuFocused)
|
||||
END_METADATA
|
@ -1,30 +1,24 @@
|
||||
diff --git a/chrome/browser/ui/tabs/tab_menu_model.cc b/chrome/browser/ui/tabs/tab_menu_model.cc
|
||||
index 08b078d90..a2cdc60be 100644
|
||||
index 8d557554..a5afac82 100644
|
||||
--- a/chrome/browser/ui/tabs/tab_menu_model.cc
|
||||
+++ b/chrome/browser/ui/tabs/tab_menu_model.cc
|
||||
@@ -49,47 +49,51 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) {
|
||||
}
|
||||
|
||||
int num_tabs = indices.size();
|
||||
+ // New Tab
|
||||
@@ -51,42 +51,45 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) {
|
||||
AddItemWithStringId(TabStripModel::CommandNewTabToRight,
|
||||
base::i18n::IsRTL() ? IDS_TAB_CXMENU_NEWTABTOLEFT
|
||||
: IDS_TAB_CXMENU_NEWTABTORIGHT);
|
||||
- if (reading_list::switches::IsReadingListEnabled() &&
|
||||
- !tab_strip->profile()->IsGuestSession()) {
|
||||
- if (!tab_strip->profile()->IsGuestSession()) {
|
||||
- AddItem(
|
||||
- TabStripModel::CommandAddToReadLater,
|
||||
- l10n_util::GetPluralStringFUTF16(IDS_TAB_CXMENU_READ_LATER, num_tabs));
|
||||
- SetEnabledAt(GetItemCount() - 1,
|
||||
- tab_strip->IsReadLaterSupportedForAny(indices));
|
||||
- if (base::FeatureList::IsEnabled(features::kReadLaterNewBadgePromo))
|
||||
- SetIsNewFeatureAt(GetItemCount() - 1, true);
|
||||
- }
|
||||
- if (ExistingTabGroupSubMenuModel::ShouldShowSubmenu(tab_strip, index)) {
|
||||
- if (ExistingTabGroupSubMenuModel::ShouldShowSubmenu(
|
||||
- tab_strip, index, tab_menu_model_delegate_)) {
|
||||
- // Create submenu with existing groups
|
||||
- add_to_existing_group_submenu_ =
|
||||
- std::make_unique<ExistingTabGroupSubMenuModel>(delegate(), tab_strip,
|
||||
- index);
|
||||
- std::make_unique<ExistingTabGroupSubMenuModel>(
|
||||
- delegate(), tab_menu_model_delegate_, tab_strip, index);
|
||||
- AddSubMenu(TabStripModel::CommandAddToExistingGroup,
|
||||
- l10n_util::GetPluralStringFUTF16(IDS_TAB_CXMENU_ADD_TAB_TO_GROUP,
|
||||
- num_tabs),
|
||||
@ -39,31 +33,21 @@ index 08b078d90..a2cdc60be 100644
|
||||
- if (base::FeatureList::IsEnabled(features::kTabGroupsNewBadgePromo))
|
||||
- SetIsNewFeatureAt(GetItemCount() - 1, true);
|
||||
- }
|
||||
-
|
||||
- for (const auto& selection : indices) {
|
||||
- if (tab_strip->GetTabGroupForTab(selection).has_value()) {
|
||||
- AddItemWithStringId(TabStripModel::CommandRemoveFromGroup,
|
||||
- IDS_TAB_CXMENU_REMOVE_TAB_FROM_GROUP);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ // Add to reading list (removed)
|
||||
+ // if (reading_list::switches::IsReadingListEnabled() &&
|
||||
+ // !tab_strip->profile()->IsGuestSession()) {
|
||||
+ // Add to Reading List
|
||||
+ // if (!tab_strip->profile()->IsGuestSession()) {
|
||||
+ // AddItem(
|
||||
+ // TabStripModel::CommandAddToReadLater,
|
||||
+ // l10n_util::GetPluralStringFUTF16(IDS_TAB_CXMENU_READ_LATER, num_tabs));
|
||||
+ // SetEnabledAt(GetItemCount() - 1,
|
||||
+ // tab_strip->IsReadLaterSupportedForAny(indices));
|
||||
+ // if (base::FeatureList::IsEnabled(features::kReadLaterNewBadgePromo))
|
||||
+ // SetIsNewFeatureAt(GetItemCount() - 1, true);
|
||||
+ // }
|
||||
+ // Change tab group (removed)
|
||||
+ // if (ExistingTabGroupSubMenuModel::ShouldShowSubmenu(tab_strip, index)) {
|
||||
+ // Change Tab Group
|
||||
+ // if (ExistingTabGroupSubMenuModel::ShouldShowSubmenu(
|
||||
+ // tab_strip, index, tab_menu_model_delegate_)) {
|
||||
+ // // Create submenu with existing groups
|
||||
+ // add_to_existing_group_submenu_ =
|
||||
+ // std::make_unique<ExistingTabGroupSubMenuModel>(delegate(), tab_strip,
|
||||
+ // index);
|
||||
+ // std::make_unique<ExistingTabGroupSubMenuModel>(
|
||||
+ // delegate(), tab_menu_model_delegate_, tab_strip, index);
|
||||
+ // AddSubMenu(TabStripModel::CommandAddToExistingGroup,
|
||||
+ // l10n_util::GetPluralStringFUTF16(IDS_TAB_CXMENU_ADD_TAB_TO_GROUP,
|
||||
+ // num_tabs),
|
||||
@ -78,7 +62,14 @@ index 08b078d90..a2cdc60be 100644
|
||||
+ // if (base::FeatureList::IsEnabled(features::kTabGroupsNewBadgePromo))
|
||||
+ // SetIsNewFeatureAt(GetItemCount() - 1, true);
|
||||
+ // }
|
||||
+ //
|
||||
|
||||
- for (const auto& selection : indices) {
|
||||
- if (tab_strip->GetTabGroupForTab(selection).has_value()) {
|
||||
- AddItemWithStringId(TabStripModel::CommandRemoveFromGroup,
|
||||
- IDS_TAB_CXMENU_REMOVE_TAB_FROM_GROUP);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
+ // for (const auto& selection : indices) {
|
||||
+ // if (tab_strip->GetTabGroupForTab(selection).has_value()) {
|
||||
+ // AddItemWithStringId(TabStripModel::CommandRemoveFromGroup,
|
||||
@ -87,11 +78,11 @@ index 08b078d90..a2cdc60be 100644
|
||||
+ // }
|
||||
+ // }
|
||||
|
||||
+ // New Window / Move to other window
|
||||
+ // New Window / Move to other Window
|
||||
if (ExistingWindowSubMenuModel::ShouldShowSubmenu(tab_strip->profile())) {
|
||||
// Create submenu with existing windows
|
||||
add_to_existing_window_submenu_ = ExistingWindowSubMenuModel::Create(
|
||||
@@ -105,9 +109,17 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) {
|
||||
@@ -102,9 +105,17 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) {
|
||||
}
|
||||
|
||||
AddSeparator(ui::NORMAL_SEPARATOR);
|
||||
@ -112,9 +103,9 @@ index 08b078d90..a2cdc60be 100644
|
||||
bool will_pin = tab_strip->WillContextMenuPin(index);
|
||||
AddItemWithStringId(
|
||||
TabStripModel::CommandTogglePinned,
|
||||
@@ -159,14 +171,6 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) {
|
||||
@@ -139,14 +150,6 @@ void TabMenuModel::Build(TabStripModel* tab_strip, int index) {
|
||||
ui::ImageModel::FromVectorIcon(kLaptopAndSmartphoneIcon));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
-
|
||||
- AddSeparator(ui::NORMAL_SEPARATOR);
|
||||
@ -128,7 +119,7 @@ index 08b078d90..a2cdc60be 100644
|
||||
|
||||
DEFINE_CLASS_ELEMENT_IDENTIFIER_VALUE(TabMenuModel,
|
||||
diff --git a/chrome/browser/ui/views/frame/tab_strip_region_view.cc b/chrome/browser/ui/views/frame/tab_strip_region_view.cc
|
||||
index 1e741368e..fac2b5f51 100644
|
||||
index 5ecd2cb5..5e71050d 100644
|
||||
--- a/chrome/browser/ui/views/frame/tab_strip_region_view.cc
|
||||
+++ b/chrome/browser/ui/views/frame/tab_strip_region_view.cc
|
||||
@@ -142,7 +142,8 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr<TabStrip> tab_strip) {
|
||||
@ -142,71 +133,47 @@ index 1e741368e..fac2b5f51 100644
|
||||
tab_search_button->SetTooltipText(
|
||||
l10n_util::GetStringUTF16(IDS_TOOLTIP_TAB_SEARCH));
|
||||
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
|
||||
index 03e8c0fb9..2acc440b1 100644
|
||||
index 25792a74..0939f1e7 100644
|
||||
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
|
||||
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
|
||||
@@ -354,14 +354,15 @@ void LocationBarView::Init() {
|
||||
params.types_enabled.push_back(PageActionIconType::kSaveAutofillAddress);
|
||||
}
|
||||
@@ -339,10 +339,11 @@ void LocationBarView::Init() {
|
||||
// final mocks.
|
||||
params.types_enabled.push_back(PageActionIconType::kSaveAutofillAddress);
|
||||
}
|
||||
- if (browser_) {
|
||||
-#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
- params.types_enabled.push_back(PageActionIconType::kSharingHub);
|
||||
-#else
|
||||
- if (sharing_hub::SharingHubOmniboxEnabled(profile_) && !is_popup_mode_)
|
||||
- if (sharing_hub::HasPageAction(profile_, is_popup_mode_))
|
||||
- params.types_enabled.push_back(PageActionIconType::kSharingHub);
|
||||
-#endif
|
||||
- }
|
||||
+ // Remove sharing hub icon
|
||||
+// if (browser_) {
|
||||
+// #if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
+// params.types_enabled.push_back(PageActionIconType::kSharingHub);
|
||||
+// #else
|
||||
+// if (sharing_hub::SharingHubOmniboxEnabled(profile_) && !is_popup_mode_)
|
||||
+// params.types_enabled.push_back(PageActionIconType::kSharingHub);
|
||||
+// #endif
|
||||
+// }
|
||||
+ // Remove sharing hub icon
|
||||
+ // if (browser_) {
|
||||
+ // if (sharing_hub::HasPageAction(profile_, is_popup_mode_))
|
||||
+ // params.types_enabled.push_back(PageActionIconType::kSharingHub);
|
||||
+ // }
|
||||
if (browser_ && !is_popup_mode_)
|
||||
params.types_enabled.push_back(PageActionIconType::kBookmarkStar);
|
||||
|
||||
diff --git a/chrome/browser/ui/views/toolbar/toolbar_view.cc b/chrome/browser/ui/views/toolbar/toolbar_view.cc
|
||||
index 76fce2124..cfe392364 100644
|
||||
index dade217a..bf25de0b 100644
|
||||
--- a/chrome/browser/ui/views/toolbar/toolbar_view.cc
|
||||
+++ b/chrome/browser/ui/views/toolbar/toolbar_view.cc
|
||||
@@ -378,20 +378,22 @@ void ToolbarView::Init() {
|
||||
@@ -335,8 +335,8 @@ void ToolbarView::Init() {
|
||||
if (send_tab_to_self_button)
|
||||
send_tab_to_self_button_ = AddChildView(std::move(send_tab_to_self_button));
|
||||
|
||||
- if (side_panel_button)
|
||||
- side_panel_button_ = AddChildView(std::move(side_panel_button));
|
||||
-
|
||||
- if (toolbar_account_icon_container) {
|
||||
- toolbar_account_icon_container_ =
|
||||
- AddChildView(std::move(toolbar_account_icon_container));
|
||||
- avatar_ = toolbar_account_icon_container_->avatar_button();
|
||||
- } else {
|
||||
- // TODO(crbug.com/932818): Remove this once the
|
||||
- // |kAutofillEnableToolbarStatusChip| is fully launched.
|
||||
- avatar_ =
|
||||
- AddChildView(std::make_unique<AvatarToolbarButton>(browser_view_));
|
||||
- avatar_->SetVisible(show_avatar_toolbar_button);
|
||||
- }
|
||||
+ // Remove side panel
|
||||
+ // if (side_panel_button)
|
||||
+ // side_panel_button_ = AddChildView(std::move(side_panel_button));
|
||||
+
|
||||
+ // Remove toolbar
|
||||
+ // if (toolbar_account_icon_container) {
|
||||
+ // toolbar_account_icon_container_ =
|
||||
+ // AddChildView(std::move(toolbar_account_icon_container));
|
||||
+ // avatar_ = toolbar_account_icon_container_->avatar_button();
|
||||
+ // } else {
|
||||
+ // // TODO(crbug.com/932818): Remove this once the
|
||||
+ // // |kAutofillEnableToolbarStatusChip| is fully launched.
|
||||
+ // avatar_ =
|
||||
+ // AddChildView(std::make_unique<AvatarToolbarButton>(browser_view_));
|
||||
+ // avatar_->SetVisible(show_avatar_toolbar_button);
|
||||
+ // }
|
||||
|
||||
avatar_ = AddChildView(std::make_unique<AvatarToolbarButton>(browser_view_));
|
||||
|
||||
@@ -363,7 +363,8 @@ void ToolbarView::Init() {
|
||||
else if (flag_value == "never")
|
||||
show_avatar_toolbar_button = false;
|
||||
|
||||
- avatar_->SetVisible(show_avatar_toolbar_button);
|
||||
+ // Always disable avatar / account icon
|
||||
+ avatar_->SetVisible(false);
|
||||
|
||||
auto app_menu_button = std::make_unique<BrowserAppMenuButton>(this);
|
||||
app_menu_button->SetFlipCanvasOnPaintForRTLUI(true);
|
||||
|
Loading…
Reference in New Issue
Block a user