2021-04-11 22:10:11 +02:00
|
|
|
diff --git chrome/browser/ui/browser_command_controller.cc chrome/browser/ui/browser_command_controller.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
index c1f28ebc372df..275657f54c517 100644
|
2021-04-11 22:10:11 +02:00
|
|
|
--- chrome/browser/ui/browser_command_controller.cc
|
|
|
|
+++ chrome/browser/ui/browser_command_controller.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -395,6 +395,7 @@ bool BrowserCommandController::ExecuteCommandWithDisposition(
|
2021-04-11 22:10:11 +02:00
|
|
|
// choose to not implement CommandUpdaterDelegate inside this class and
|
|
|
|
// therefore command_updater_ doesn't have the delegate set).
|
2023-01-30 18:43:54 +01:00
|
|
|
if (!SupportsCommand(id) || !IsCommandEnabled(id)) {
|
2021-04-11 22:10:11 +02:00
|
|
|
+ LOG(WARNING) << "Invalid/disabled command " << id;
|
|
|
|
return false;
|
2023-01-30 18:43:54 +01:00
|
|
|
}
|
2021-04-11 22:10:11 +02:00
|
|
|
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -411,6 +412,13 @@ bool BrowserCommandController::ExecuteCommandWithDisposition(
|
2022-03-22 19:31:30 +01:00
|
|
|
DCHECK(command_updater_.IsCommandEnabled(id))
|
|
|
|
<< "Invalid/disabled command " << id;
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (browser_->cef_delegate() &&
|
|
|
|
+ browser_->cef_delegate()->HandleCommand(id, disposition)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
// The order of commands in this switch statement must match the function
|
|
|
|
// declaration order in browser.h!
|
|
|
|
switch (id) {
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -1102,11 +1110,13 @@ void BrowserCommandController::TabRestoreServiceLoaded(
|
2021-04-11 22:10:11 +02:00
|
|
|
// BrowserCommandController, private:
|
|
|
|
|
|
|
|
bool BrowserCommandController::IsShowingMainUI() {
|
|
|
|
- return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
|
|
|
|
+ return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP) ||
|
|
|
|
+ browser_->toolbar_overridden();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserCommandController::IsShowingLocationBar() {
|
|
|
|
- return browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR);
|
|
|
|
+ return browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR) ||
|
|
|
|
+ browser_->toolbar_overridden();
|
|
|
|
}
|
|
|
|
|
2022-02-21 23:23:40 +01:00
|
|
|
bool BrowserCommandController::IsWebAppOrCustomTab() const {
|
2023-03-07 00:21:57 +01:00
|
|
|
diff --git chrome/browser/ui/toolbar/app_menu_model.cc chrome/browser/ui/toolbar/app_menu_model.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
index f6c50fc75faf8..30b0f9fa68554 100644
|
2023-03-07 00:21:57 +01:00
|
|
|
--- chrome/browser/ui/toolbar/app_menu_model.cc
|
|
|
|
+++ chrome/browser/ui/toolbar/app_menu_model.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -192,6 +192,57 @@ void SetCommandIcon(ui::SimpleMenuModel* model,
|
|
|
|
}
|
2023-03-07 00:21:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+using IsVisibleCallback = base::RepeatingCallback<bool(int)>;
|
|
|
|
+
|
|
|
|
+void FilterMenuModel(ui::SimpleMenuModel* model,
|
|
|
|
+ const IsVisibleCallback& is_visible) {
|
|
|
|
+ absl::optional<size_t> last_separator;
|
|
|
|
+ size_t visible_ct = 0;
|
|
|
|
+ for (size_t i = 0; i < model->GetItemCount(); ++i) {
|
|
|
|
+ const auto type = model->GetTypeAt(i);
|
|
|
|
+ if (type == ui::MenuModel::TYPE_SEPARATOR) {
|
|
|
|
+ if (last_separator) {
|
|
|
|
+ // Remove multiple separators in a row. Prefer to remove a NORMAL
|
|
|
|
+ // separator if possible (as compared to zoom/edit controls which use
|
|
|
|
+ // UPPER/LOWER separators).
|
|
|
|
+ if (model->GetSeparatorTypeAt(*last_separator) ==
|
|
|
|
+ ui::NORMAL_SEPARATOR) {
|
|
|
|
+ model->RemoveItemAt(*last_separator);
|
|
|
|
+ i--;
|
|
|
|
+ last_separator = i;
|
|
|
|
+ } else {
|
|
|
|
+ model->RemoveItemAt(i);
|
|
|
|
+ i--;
|
|
|
|
+ }
|
|
|
|
+ } else if (visible_ct == 0) {
|
|
|
|
+ // Remove leading separator.
|
|
|
|
+ model->RemoveItemAt(i);
|
|
|
|
+ i--;
|
|
|
|
+ } else {
|
|
|
|
+ last_separator = i;
|
|
|
|
+ }
|
|
|
|
+ visible_ct = 0;
|
|
|
|
+ } else if (is_visible.Run(model->GetCommandIdAt(i))) {
|
|
|
|
+ last_separator = absl::nullopt;
|
|
|
|
+ visible_ct++;
|
|
|
|
+
|
|
|
|
+ if (type == ui::MenuModel::TYPE_SUBMENU) {
|
|
|
|
+ // Filter sub-menu.
|
|
|
|
+ auto sub_model =
|
|
|
|
+ static_cast<ui::SimpleMenuModel*>(model->GetSubmenuModelAt(i));
|
|
|
|
+ FilterMenuModel(sub_model, is_visible);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (last_separator) {
|
|
|
|
+ // Remove trailing separator.
|
|
|
|
+ model->RemoveItemAt(*last_separator);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+#endif // BUILDFLAG(ENABLE_CEF)
|
|
|
|
+
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -960,7 +1011,7 @@ bool AppMenuModel::IsCommandIdChecked(int command_id) const {
|
2023-03-07 00:21:57 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
-bool AppMenuModel::IsCommandIdEnabled(int command_id) const {
|
|
|
|
+bool AppMenuModel::IsCommandIdEnabledInternal(int command_id) const {
|
|
|
|
GlobalError* error =
|
|
|
|
GlobalErrorServiceFactory::GetForProfile(browser_->profile())
|
|
|
|
->GetGlobalErrorByMenuItemCommandID(command_id);
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -975,7 +1026,7 @@ bool AppMenuModel::IsCommandIdEnabled(int command_id) const {
|
2023-03-07 00:21:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-bool AppMenuModel::IsCommandIdVisible(int command_id) const {
|
|
|
|
+bool AppMenuModel::IsCommandIdVisibleInternal(int command_id) const {
|
|
|
|
switch (command_id) {
|
|
|
|
case IDC_PIN_TO_START_SCREEN:
|
|
|
|
return false;
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -998,6 +1049,34 @@ bool AppMenuModel::IsCommandIdVisible(int command_id) const {
|
2023-03-07 00:21:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+bool AppMenuModel::IsCommandIdEnabled(int command_id) const {
|
|
|
|
+ if (!IsCommandIdEnabledInternal(command_id)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (browser_->cef_delegate()) {
|
|
|
|
+ return browser_->cef_delegate()->IsAppMenuItemEnabled(command_id);
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool AppMenuModel::IsCommandIdVisible(int command_id) const {
|
|
|
|
+ if (!IsCommandIdVisibleInternal(command_id)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (browser_->cef_delegate()) {
|
|
|
|
+ return browser_->cef_delegate()->IsAppMenuItemVisible(command_id);
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
bool AppMenuModel::IsCommandIdAlerted(int command_id) const {
|
|
|
|
if ((command_id == IDC_RECENT_TABS_MENU) ||
|
|
|
|
(command_id == AppMenuModel::kMinRecentTabsCommandId)) {
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -1148,11 +1227,15 @@ void AppMenuModel::Build() {
|
2023-04-26 21:55:59 +02:00
|
|
|
}
|
2023-03-07 00:21:57 +01:00
|
|
|
}
|
|
|
|
|
2023-04-26 21:55:59 +02:00
|
|
|
- AddSeparator(features::IsChromeRefresh2023() ? ui::NORMAL_SEPARATOR
|
|
|
|
- : ui::LOWER_SEPARATOR);
|
2023-03-07 00:21:57 +01:00
|
|
|
- CreateZoomMenu();
|
2023-04-26 21:55:59 +02:00
|
|
|
- AddSeparator(features::IsChromeRefresh2023() ? ui::NORMAL_SEPARATOR
|
|
|
|
- : ui::UPPER_SEPARATOR);
|
2023-03-07 00:21:57 +01:00
|
|
|
+ if (IsCommandIdVisible(IDC_ZOOM_MENU)) {
|
2023-04-26 21:55:59 +02:00
|
|
|
+ AddSeparator(features::IsChromeRefresh2023() ? ui::NORMAL_SEPARATOR
|
|
|
|
+ : ui::LOWER_SEPARATOR);
|
2023-03-07 00:21:57 +01:00
|
|
|
+ CreateZoomMenu();
|
2023-04-26 21:55:59 +02:00
|
|
|
+ AddSeparator(features::IsChromeRefresh2023() ? ui::NORMAL_SEPARATOR
|
|
|
|
+ : ui::UPPER_SEPARATOR);
|
2023-03-07 00:21:57 +01:00
|
|
|
+ } else {
|
|
|
|
+ AddSeparator(ui::NORMAL_SEPARATOR);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
AddItemWithStringId(IDC_PRINT, IDS_PRINT);
|
|
|
|
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -1243,9 +1326,13 @@ void AppMenuModel::Build() {
|
2023-03-07 00:21:57 +01:00
|
|
|
kMoreToolsMenuItem);
|
|
|
|
|
2023-04-26 21:55:59 +02:00
|
|
|
if (!features::IsChromeRefresh2023()) {
|
|
|
|
- AddSeparator(ui::LOWER_SEPARATOR);
|
|
|
|
- CreateCutCopyPasteMenu();
|
|
|
|
- AddSeparator(ui::UPPER_SEPARATOR);
|
|
|
|
+ if (IsCommandIdVisible(IDC_EDIT_MENU)) {
|
|
|
|
+ AddSeparator(ui::LOWER_SEPARATOR);
|
|
|
|
+ CreateCutCopyPasteMenu();
|
|
|
|
+ AddSeparator(ui::UPPER_SEPARATOR);
|
|
|
|
+ } else {
|
|
|
|
+ AddSeparator(ui::NORMAL_SEPARATOR);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!features::IsChromeRefresh2023()) {
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -1327,6 +1414,11 @@ void AppMenuModel::Build() {
|
|
|
|
SetCommandIcon(this, IDC_EXIT, kExitMenuIcon);
|
2023-03-07 00:21:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ FilterMenuModel(this, base::BindRepeating(&AppMenuModel::IsCommandIdVisible,
|
|
|
|
+ base::Unretained(this)));
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
uma_action_recorded_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git chrome/browser/ui/toolbar/app_menu_model.h chrome/browser/ui/toolbar/app_menu_model.h
|
2023-05-30 10:55:32 +02:00
|
|
|
index 8648fccbe4a2e..386dee69b5eff 100644
|
2023-03-07 00:21:57 +01:00
|
|
|
--- chrome/browser/ui/toolbar/app_menu_model.h
|
|
|
|
+++ chrome/browser/ui/toolbar/app_menu_model.h
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -258,6 +258,9 @@ class AppMenuModel : public ui::SimpleMenuModel,
|
2023-03-07 00:21:57 +01:00
|
|
|
// Appends a zoom menu (without separators).
|
|
|
|
void CreateZoomMenu();
|
|
|
|
|
|
|
|
+ bool IsCommandIdEnabledInternal(int command_id) const;
|
|
|
|
+ bool IsCommandIdVisibleInternal(int command_id) const;
|
|
|
|
+
|
|
|
|
private:
|
2023-04-26 21:55:59 +02:00
|
|
|
// Adds actionable global error menu items to the menu.
|
|
|
|
// Examples: Extension permissions and sign in errors.
|
2023-04-12 20:34:39 +02:00
|
|
|
diff --git chrome/browser/ui/views/find_bar_host.cc chrome/browser/ui/views/find_bar_host.cc
|
2023-04-26 21:55:59 +02:00
|
|
|
index 59024587ef6b7..0c30aa71768cf 100644
|
2023-04-12 20:34:39 +02:00
|
|
|
--- chrome/browser/ui/views/find_bar_host.cc
|
|
|
|
+++ chrome/browser/ui/views/find_bar_host.cc
|
|
|
|
@@ -412,6 +412,12 @@ void FindBarHost::GetWidgetBounds(gfx::Rect* bounds) {
|
|
|
|
// The BrowserView does Layout for the components that we care about
|
|
|
|
// positioning relative to, so we ask it to tell us where we should go.
|
|
|
|
*bounds = browser_view()->GetFindBarBoundingBox();
|
|
|
|
+
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (browser_view()->browser() && browser_view()->browser()->cef_delegate()) {
|
|
|
|
+ browser_view()->browser()->cef_delegate()->UpdateFindBarBoundingBox(bounds);
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void FindBarHost::RegisterAccelerators() {
|
2021-02-18 02:58:25 +01:00
|
|
|
diff --git chrome/browser/ui/views/frame/browser_frame.cc chrome/browser/ui/views/frame/browser_frame.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
index 24b85357b90b8..67e1bacb8d518 100644
|
2021-02-18 02:58:25 +01:00
|
|
|
--- chrome/browser/ui/views/frame/browser_frame.cc
|
|
|
|
+++ chrome/browser/ui/views/frame/browser_frame.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -75,15 +75,23 @@ bool IsUsingLinuxSystemTheme(Profile* profile) {
|
2021-02-18 02:58:25 +01:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// BrowserFrame, public:
|
|
|
|
|
|
|
|
+BrowserFrame::BrowserFrame() : BrowserFrame(nullptr) {}
|
|
|
|
+
|
|
|
|
BrowserFrame::BrowserFrame(BrowserView* browser_view)
|
|
|
|
: native_browser_frame_(nullptr),
|
|
|
|
root_view_(nullptr),
|
|
|
|
browser_frame_view_(nullptr),
|
|
|
|
- browser_view_(browser_view) {
|
|
|
|
- browser_view_->set_frame(this);
|
|
|
|
+ browser_view_(nullptr) {
|
|
|
|
set_is_secondary_widget(false);
|
|
|
|
// Don't focus anything on creation, selecting a tab will set the focus.
|
|
|
|
set_focus_on_creation(false);
|
|
|
|
+ if (browser_view)
|
|
|
|
+ InitBrowserView(browser_view);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void BrowserFrame::InitBrowserView(BrowserView* browser_view) {
|
|
|
|
+ browser_view_ = browser_view;
|
|
|
|
+ browser_view_->set_frame(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
BrowserFrame::~BrowserFrame() {}
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -178,6 +186,12 @@ void BrowserFrame::LayoutWebAppWindowTitle(
|
2021-02-18 02:58:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int BrowserFrame::GetTopInset() const {
|
|
|
|
+ if (!browser_frame_view_) {
|
|
|
|
+ // With CEF the browser may already be part of a larger Views layout. Zero
|
|
|
|
+ // out the adjustment in BrowserView::GetTopInsetInBrowserView() so that
|
|
|
|
+ // the browser isn't shifted to the top of the window.
|
|
|
|
+ return browser_view_->y();
|
|
|
|
+ }
|
|
|
|
return browser_frame_view_->GetTopInset(false);
|
|
|
|
}
|
|
|
|
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -194,6 +208,8 @@ BrowserNonClientFrameView* BrowserFrame::GetFrameView() const {
|
2022-08-09 21:42:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserFrame::UseCustomFrame() const {
|
|
|
|
+ if (!native_browser_frame_)
|
|
|
|
+ return true;
|
|
|
|
return native_browser_frame_->UseCustomFrame();
|
|
|
|
}
|
|
|
|
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -207,20 +223,30 @@ bool BrowserFrame::ShouldDrawFrameHeader() const {
|
2022-03-23 01:42:03 +01:00
|
|
|
|
|
|
|
void BrowserFrame::GetWindowPlacement(gfx::Rect* bounds,
|
|
|
|
ui::WindowShowState* show_state) const {
|
|
|
|
+ if (!native_browser_frame_) {
|
|
|
|
+ *show_state = ui::SHOW_STATE_DEFAULT;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
return native_browser_frame_->GetWindowPlacement(bounds, show_state);
|
|
|
|
}
|
2021-02-18 02:58:25 +01:00
|
|
|
|
|
|
|
content::KeyboardEventProcessingResult BrowserFrame::PreHandleKeyboardEvent(
|
|
|
|
const content::NativeWebKeyboardEvent& event) {
|
|
|
|
+ if (!native_browser_frame_)
|
|
|
|
+ return content::KeyboardEventProcessingResult::NOT_HANDLED;
|
|
|
|
return native_browser_frame_->PreHandleKeyboardEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserFrame::HandleKeyboardEvent(
|
|
|
|
const content::NativeWebKeyboardEvent& event) {
|
|
|
|
+ if (!native_browser_frame_)
|
|
|
|
+ return false;
|
|
|
|
return native_browser_frame_->HandleKeyboardEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserFrame::OnBrowserViewInitViewsComplete() {
|
|
|
|
+ if (!browser_frame_view_)
|
|
|
|
+ return;
|
|
|
|
browser_frame_view_->OnBrowserViewInitViewsComplete();
|
|
|
|
}
|
|
|
|
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -300,6 +326,8 @@ BrowserFrame::GetCustomTheme() const {
|
2022-04-08 22:48:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserFrame::OnNativeWidgetWorkspaceChanged() {
|
|
|
|
+ if (!browser_view_)
|
|
|
|
+ return;
|
|
|
|
chrome::SaveWindowWorkspace(browser_view_->browser(), GetWorkspace());
|
|
|
|
chrome::SaveWindowVisibleOnAllWorkspaces(browser_view_->browser(),
|
|
|
|
IsVisibleOnAllWorkspaces());
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -411,6 +439,8 @@ void BrowserFrame::OnNativeThemeUpdated(ui::NativeTheme* observed_theme) {
|
2022-03-26 02:12:30 +01:00
|
|
|
|
|
|
|
ui::ColorProviderManager::Key BrowserFrame::GetColorProviderKey() const {
|
|
|
|
auto key = Widget::GetColorProviderKey();
|
|
|
|
+ if (!browser_view_)
|
|
|
|
+ return key;
|
2022-07-21 19:26:10 +02:00
|
|
|
key.frame_type = UseCustomFrame()
|
|
|
|
? ui::ColorProviderManager::FrameType::kChromium
|
|
|
|
: ui::ColorProviderManager::FrameType::kNative;
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -420,6 +450,9 @@ ui::ColorProviderManager::Key BrowserFrame::GetColorProviderKey() const {
|
2023-04-04 20:00:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
absl::optional<SkColor> BrowserFrame::GetUserColor() const {
|
|
|
|
+ if (!browser_view_) {
|
|
|
|
+ return absl::nullopt;
|
|
|
|
+ }
|
|
|
|
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
|
|
|
// ChromeOS SystemWebApps use the OS theme all the time.
|
|
|
|
if (ash::IsSystemWebApp(browser_view_->browser())) {
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -533,5 +566,8 @@ bool BrowserFrame::RegenerateFrameOnThemeChange(
|
2022-11-15 18:50:53 +01:00
|
|
|
}
|
|
|
|
|
2023-05-30 10:55:32 +02:00
|
|
|
bool BrowserFrame::IsIncognitoBrowser() const {
|
|
|
|
+ if (!browser_view_) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
2023-01-30 18:43:54 +01:00
|
|
|
return browser_view_->browser()->profile()->IsIncognitoProfile();
|
2022-11-15 18:50:53 +01:00
|
|
|
}
|
2021-02-18 02:58:25 +01:00
|
|
|
diff --git chrome/browser/ui/views/frame/browser_frame.h chrome/browser/ui/views/frame/browser_frame.h
|
2023-05-30 10:55:32 +02:00
|
|
|
index 795f057fedc51..54b08509919af 100644
|
2021-02-18 02:58:25 +01:00
|
|
|
--- chrome/browser/ui/views/frame/browser_frame.h
|
|
|
|
+++ chrome/browser/ui/views/frame/browser_frame.h
|
2023-04-04 20:00:13 +02:00
|
|
|
@@ -61,7 +61,9 @@ enum class TabDragKind {
|
2021-02-18 02:58:25 +01:00
|
|
|
// This is a virtual interface that allows system specific browser frames.
|
|
|
|
class BrowserFrame : public views::Widget, public views::ContextMenuController {
|
|
|
|
public:
|
|
|
|
+ BrowserFrame();
|
|
|
|
explicit BrowserFrame(BrowserView* browser_view);
|
|
|
|
+ void InitBrowserView(BrowserView* browser_view);
|
|
|
|
|
2021-10-19 00:17:16 +02:00
|
|
|
BrowserFrame(const BrowserFrame&) = delete;
|
|
|
|
BrowserFrame& operator=(const BrowserFrame&) = delete;
|
2021-02-18 02:58:25 +01:00
|
|
|
diff --git chrome/browser/ui/views/frame/browser_view.cc chrome/browser/ui/views/frame/browser_view.cc
|
2023-06-06 11:03:15 +02:00
|
|
|
index 39a1660cae03a..0faf50eb14298 100644
|
2021-02-18 02:58:25 +01:00
|
|
|
--- chrome/browser/ui/views/frame/browser_view.cc
|
|
|
|
+++ chrome/browser/ui/views/frame/browser_view.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -314,11 +314,10 @@ using content::NativeWebKeyboardEvent;
|
2022-06-17 15:28:55 +02:00
|
|
|
using content::WebContents;
|
2021-08-28 03:55:15 +02:00
|
|
|
using web_modal::WebContentsModalDialogHost;
|
|
|
|
|
|
|
|
-namespace {
|
|
|
|
+// static
|
|
|
|
+const char BrowserView::kBrowserViewKey[] = "__BROWSER_VIEW__";
|
|
|
|
|
|
|
|
-// The name of a key to store on the window handle so that other code can
|
|
|
|
-// locate this object using just the handle.
|
|
|
|
-const char* const kBrowserViewKey = "__BROWSER_VIEW__";
|
|
|
|
+namespace {
|
|
|
|
|
|
|
|
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
|
|
|
// UMA histograms that record animation smoothness for tab loading animation.
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -789,11 +788,22 @@ class BrowserView::AccessibilityModeObserver : public ui::AXModeObserver {
|
2021-03-04 23:36:57 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// BrowserView, public:
|
2021-02-18 02:58:25 +01:00
|
|
|
|
|
|
|
+BrowserView::BrowserView() : BrowserView(nullptr) {}
|
|
|
|
+
|
|
|
|
BrowserView::BrowserView(std::unique_ptr<Browser> browser)
|
|
|
|
: views::ClientView(nullptr, nullptr),
|
|
|
|
- browser_(std::move(browser)),
|
|
|
|
accessibility_mode_observer_(
|
|
|
|
std::make_unique<AccessibilityModeObserver>(this)) {
|
|
|
|
+ if (browser)
|
|
|
|
+ InitBrowser(std::move(browser));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void BrowserView::InitBrowser(std::unique_ptr<Browser> browser) {
|
|
|
|
+ DCHECK(!browser_);
|
|
|
|
+ browser_ = std::move(browser);
|
|
|
|
+
|
2022-09-26 21:30:45 +02:00
|
|
|
+ immersive_mode_controller_ = chrome::CreateImmersiveModeController(this);
|
2021-02-18 02:58:25 +01:00
|
|
|
+
|
2022-03-26 02:12:30 +01:00
|
|
|
SetShowIcon(
|
|
|
|
::ShouldShowWindowIcon(browser_.get(), AppUsesWindowControlsOverlay()));
|
2021-03-04 23:36:57 +01:00
|
|
|
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -837,7 +847,6 @@ BrowserView::BrowserView(std::unique_ptr<Browser> browser)
|
2021-03-04 23:36:57 +01:00
|
|
|
}
|
2021-02-18 02:58:25 +01:00
|
|
|
|
|
|
|
browser_->tab_strip_model()->AddObserver(this);
|
2022-09-26 21:30:45 +02:00
|
|
|
- immersive_mode_controller_ = chrome::CreateImmersiveModeController(this);
|
2021-02-18 02:58:25 +01:00
|
|
|
|
|
|
|
// Top container holds tab strip region and toolbar and lives at the front of
|
|
|
|
// the view hierarchy.
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -893,8 +902,15 @@ BrowserView::BrowserView(std::unique_ptr<Browser> browser)
|
2021-04-11 22:10:11 +02:00
|
|
|
contents_container->SetLayoutManager(std::make_unique<ContentsLayoutManager>(
|
|
|
|
devtools_web_view_, contents_web_view_));
|
|
|
|
|
|
|
|
- toolbar_ = top_container_->AddChildView(
|
|
|
|
- std::make_unique<ToolbarView>(browser_.get(), this));
|
|
|
|
+ toolbar_ = OverrideCreateToolbar(browser_.get(), this);
|
|
|
|
+ if (!toolbar_) {
|
2021-07-23 18:40:13 +02:00
|
|
|
+ toolbar_ = new ToolbarView(browser_.get(), this, absl::nullopt);
|
2021-04-11 22:10:11 +02:00
|
|
|
+ } else {
|
|
|
|
+ browser_->set_toolbar_overridden(true);
|
|
|
|
+ // Update state that depends on the above flag.
|
|
|
|
+ browser_->command_controller()->FullscreenStateChanged();
|
|
|
|
+ }
|
2021-12-16 23:35:54 +01:00
|
|
|
+ top_container_->AddChildView(base::WrapUnique(toolbar_.get()));
|
2021-04-11 22:10:11 +02:00
|
|
|
|
|
|
|
contents_separator_ =
|
|
|
|
top_container_->AddChildView(std::make_unique<ContentsSeparator>());
|
2023-06-06 11:03:15 +02:00
|
|
|
@@ -1087,12 +1103,14 @@ gfx::Size BrowserView::GetWebAppFrameToolbarPreferredSize() const {
|
|
|
|
|
|
|
|
#if BUILDFLAG(IS_MAC)
|
|
|
|
bool BrowserView::UsesImmersiveFullscreenMode() const {
|
|
|
|
+ if (!base::FeatureList::IsEnabled(features::kImmersiveFullscreen)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
const bool is_pwa =
|
|
|
|
base::FeatureList::IsEnabled(features::kImmersiveFullscreenPWAs) &&
|
|
|
|
GetIsWebAppType();
|
|
|
|
const bool is_tabbed_window = GetSupportsTabStrip();
|
|
|
|
- return base::FeatureList::IsEnabled(features::kImmersiveFullscreen) &&
|
|
|
|
- (is_pwa || is_tabbed_window);
|
|
|
|
+ return is_pwa || is_tabbed_window;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserView::UsesImmersiveFullscreenTabbedMode() const {
|
|
|
|
@@ -1817,6 +1835,8 @@ bool BrowserView::ShouldHideUIForFullscreen() const {
|
2021-02-18 02:58:25 +01:00
|
|
|
if (immersive_mode_controller_->IsEnabled())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
+ if (!frame_->GetFrameView())
|
|
|
|
+ return false;
|
|
|
|
return frame_->GetFrameView()->ShouldHideTopUIForFullscreen();
|
|
|
|
}
|
|
|
|
|
2023-06-06 11:03:15 +02:00
|
|
|
@@ -2722,7 +2742,8 @@ DownloadShelf* BrowserView::GetDownloadShelf() {
|
2022-10-17 19:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DownloadBubbleUIController* BrowserView::GetDownloadBubbleUIController() {
|
|
|
|
- DCHECK(toolbar_button_provider_);
|
|
|
|
+ if (!toolbar_button_provider_)
|
|
|
|
+ return nullptr;
|
|
|
|
if (auto* download_button = toolbar_button_provider_->GetDownloadButton())
|
|
|
|
return download_button->bubble_controller();
|
|
|
|
return nullptr;
|
2023-06-06 11:03:15 +02:00
|
|
|
@@ -3222,7 +3243,8 @@ void BrowserView::ReparentTopContainerForEndOfImmersive() {
|
2022-08-23 03:37:40 +02:00
|
|
|
if (top_container()->parent() == this)
|
|
|
|
return;
|
2021-02-18 02:58:25 +01:00
|
|
|
|
|
|
|
- overlay_view_->SetVisible(false);
|
|
|
|
+ if (overlay_view_)
|
|
|
|
+ overlay_view_->SetVisible(false);
|
|
|
|
top_container()->DestroyLayer();
|
|
|
|
AddChildViewAt(top_container(), 0);
|
|
|
|
EnsureFocusOrder();
|
2023-06-06 11:03:15 +02:00
|
|
|
@@ -3776,8 +3798,10 @@ void BrowserView::Layout() {
|
2021-04-11 22:10:11 +02:00
|
|
|
|
2021-02-18 02:58:25 +01:00
|
|
|
// TODO(jamescook): Why was this in the middle of layout code?
|
|
|
|
toolbar_->location_bar()->omnibox_view()->SetFocusBehavior(
|
2021-04-11 22:10:11 +02:00
|
|
|
- IsToolbarVisible() ? FocusBehavior::ALWAYS : FocusBehavior::NEVER);
|
2021-02-18 02:58:25 +01:00
|
|
|
- frame()->GetFrameView()->UpdateMinimumSize();
|
2021-04-11 22:10:11 +02:00
|
|
|
+ (IsToolbarVisible() || browser_->toolbar_overridden()) ?
|
|
|
|
+ FocusBehavior::ALWAYS : FocusBehavior::NEVER);
|
2021-02-18 02:58:25 +01:00
|
|
|
+ if (frame()->GetFrameView())
|
|
|
|
+ frame()->GetFrameView()->UpdateMinimumSize();
|
|
|
|
|
|
|
|
// Some of the situations when the BrowserView is laid out are:
|
|
|
|
// - Enter/exit immersive fullscreen mode.
|
2023-06-06 11:03:15 +02:00
|
|
|
@@ -3843,6 +3867,11 @@ void BrowserView::AddedToWidget() {
|
2021-04-11 22:10:11 +02:00
|
|
|
SetThemeProfileForWindow(GetNativeWindow(), browser_->profile());
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+ // This browser view may already have a custom button provider set (e.g the
|
|
|
|
+ // hosted app frame).
|
|
|
|
+ if (!toolbar_button_provider_)
|
|
|
|
+ SetToolbarButtonProvider(toolbar_);
|
|
|
|
+
|
|
|
|
toolbar_->Init();
|
2021-02-18 02:58:25 +01:00
|
|
|
|
2023-04-04 20:00:13 +02:00
|
|
|
// TODO(pbos): Investigate whether the side panels should be creatable when
|
2023-06-06 11:03:15 +02:00
|
|
|
@@ -3889,13 +3918,9 @@ void BrowserView::AddedToWidget() {
|
2021-04-11 22:10:11 +02:00
|
|
|
|
|
|
|
EnsureFocusOrder();
|
|
|
|
|
|
|
|
- // This browser view may already have a custom button provider set (e.g the
|
|
|
|
- // hosted app frame).
|
|
|
|
- if (!toolbar_button_provider_)
|
|
|
|
- SetToolbarButtonProvider(toolbar_);
|
|
|
|
-
|
2021-02-18 02:58:25 +01:00
|
|
|
frame_->OnBrowserViewInitViewsComplete();
|
|
|
|
- frame_->GetFrameView()->UpdateMinimumSize();
|
|
|
|
+ if (frame_->GetFrameView())
|
|
|
|
+ frame_->GetFrameView()->UpdateMinimumSize();
|
|
|
|
using_native_frame_ = frame_->ShouldUseNativeFrame();
|
|
|
|
|
|
|
|
MaybeInitializeWebUITabStrip();
|
2023-06-06 11:03:15 +02:00
|
|
|
@@ -4300,7 +4325,8 @@ void BrowserView::ProcessFullscreen(bool fullscreen,
|
2022-01-13 00:11:27 +01:00
|
|
|
// Undo our anti-jankiness hacks and force a re-layout.
|
|
|
|
in_process_fullscreen_ = false;
|
|
|
|
ToolbarSizeChanged(false);
|
|
|
|
- frame_->GetFrameView()->OnFullscreenStateChanged();
|
|
|
|
+ if (frame_->GetFrameView())
|
|
|
|
+ frame_->GetFrameView()->OnFullscreenStateChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const {
|
2023-06-06 11:03:15 +02:00
|
|
|
@@ -4671,6 +4697,8 @@ Profile* BrowserView::GetProfile() {
|
2022-01-13 00:11:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserView::UpdateUIForTabFullscreen() {
|
|
|
|
+ if (!frame_->GetFrameView())
|
|
|
|
+ return;
|
|
|
|
frame()->GetFrameView()->UpdateFullscreenTopUI();
|
|
|
|
}
|
|
|
|
|
2023-06-06 11:03:15 +02:00
|
|
|
@@ -4693,6 +4721,8 @@ void BrowserView::HideDownloadShelf() {
|
2022-01-13 00:11:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserView::CanUserExitFullscreen() const {
|
|
|
|
+ if (!frame_->GetFrameView())
|
|
|
|
+ return true;
|
|
|
|
return frame_->GetFrameView()->CanUserExitFullscreen();
|
|
|
|
}
|
|
|
|
|
2021-02-18 02:58:25 +01:00
|
|
|
diff --git chrome/browser/ui/views/frame/browser_view.h chrome/browser/ui/views/frame/browser_view.h
|
2023-05-30 10:55:32 +02:00
|
|
|
index 3e812382f77e6..d821b03bfa510 100644
|
2021-02-18 02:58:25 +01:00
|
|
|
--- chrome/browser/ui/views/frame/browser_view.h
|
|
|
|
+++ chrome/browser/ui/views/frame/browser_view.h
|
2023-01-30 18:43:54 +01:00
|
|
|
@@ -124,11 +124,16 @@ class BrowserView : public BrowserWindow,
|
2021-03-04 23:36:57 +01:00
|
|
|
public webapps::AppBannerManager::Observer {
|
|
|
|
public:
|
|
|
|
METADATA_HEADER(BrowserView);
|
2021-02-18 02:58:25 +01:00
|
|
|
+ BrowserView();
|
|
|
|
explicit BrowserView(std::unique_ptr<Browser> browser);
|
|
|
|
+ void InitBrowser(std::unique_ptr<Browser> browser);
|
2021-03-04 23:36:57 +01:00
|
|
|
BrowserView(const BrowserView&) = delete;
|
|
|
|
BrowserView& operator=(const BrowserView&) = delete;
|
2021-02-18 02:58:25 +01:00
|
|
|
~BrowserView() override;
|
2021-08-28 03:55:15 +02:00
|
|
|
|
|
|
|
+ // Key used to bind BrowserView to the Widget with which it is associated.
|
|
|
|
+ static const char kBrowserViewKey[];
|
|
|
|
+
|
2023-01-30 18:43:54 +01:00
|
|
|
void set_frame(BrowserFrame* frame) {
|
|
|
|
frame_ = frame;
|
|
|
|
paint_as_active_subscription_ =
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -783,6 +788,12 @@ class BrowserView : public BrowserWindow,
|
2023-02-27 19:52:38 +01:00
|
|
|
return web_app_frame_toolbar();
|
|
|
|
}
|
2021-04-11 22:10:11 +02:00
|
|
|
|
|
|
|
+ protected:
|
|
|
|
+ virtual ToolbarView* OverrideCreateToolbar(Browser* browser,
|
|
|
|
+ BrowserView* browser_view) {
|
|
|
|
+ return nullptr;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
private:
|
|
|
|
// Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
|
|
|
|
// interface to keep these two classes decoupled and testable.
|
|
|
|
diff --git chrome/browser/ui/views/frame/browser_view_layout.cc chrome/browser/ui/views/frame/browser_view_layout.cc
|
2023-04-04 20:00:13 +02:00
|
|
|
index cf12bbd30e086..a227f64d8d5e9 100644
|
2021-04-11 22:10:11 +02:00
|
|
|
--- chrome/browser/ui/views/frame/browser_view_layout.cc
|
|
|
|
+++ chrome/browser/ui/views/frame/browser_view_layout.cc
|
2023-04-04 20:00:13 +02:00
|
|
|
@@ -47,6 +47,10 @@
|
2021-08-28 03:55:15 +02:00
|
|
|
#include "ui/views/window/client_view.h"
|
2023-02-27 19:52:38 +01:00
|
|
|
#include "ui/views/window/hit_test_utils.h"
|
2021-08-28 03:55:15 +02:00
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+#include "cef/libcef/browser/chrome/views/chrome_views_util.h"
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
using views::View;
|
|
|
|
using web_modal::ModalDialogHostObserver;
|
2023-01-03 00:34:43 +01:00
|
|
|
using web_modal::WebContentsModalDialogHost;
|
2023-04-04 20:00:13 +02:00
|
|
|
@@ -560,6 +564,13 @@ int BrowserViewLayout::LayoutWebUITabStrip(int top) {
|
2021-04-11 22:10:11 +02:00
|
|
|
|
|
|
|
int BrowserViewLayout::LayoutToolbar(int top) {
|
|
|
|
TRACE_EVENT0("ui", "BrowserViewLayout::LayoutToolbar");
|
2023-01-23 18:58:40 +01:00
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
2021-08-28 03:55:15 +02:00
|
|
|
+ if (cef::IsCefView(toolbar_)) {
|
2021-04-11 22:10:11 +02:00
|
|
|
+ // CEF may take ownership of the toolbar. Early exit to avoid the DCHECK
|
|
|
|
+ // in LayoutManager::SetViewVisibility().
|
|
|
|
+ return top;
|
|
|
|
+ }
|
2023-01-23 18:58:40 +01:00
|
|
|
+#endif
|
2021-04-11 22:10:11 +02:00
|
|
|
int browser_view_width = vertical_layout_rect_.width();
|
|
|
|
bool toolbar_visible = delegate_->IsToolbarVisible();
|
|
|
|
int height = toolbar_visible ? toolbar_->GetPreferredSize().height() : 0;
|
2022-04-14 21:12:23 +02:00
|
|
|
diff --git chrome/browser/ui/views/frame/contents_web_view.cc chrome/browser/ui/views/frame/contents_web_view.cc
|
2022-09-26 21:30:45 +02:00
|
|
|
index 5e059b9878fc2..c1f6fbcd40ec4 100644
|
2022-04-14 21:12:23 +02:00
|
|
|
--- chrome/browser/ui/views/frame/contents_web_view.cc
|
|
|
|
+++ chrome/browser/ui/views/frame/contents_web_view.cc
|
2022-04-21 20:58:48 +02:00
|
|
|
@@ -26,6 +26,11 @@
|
2022-04-14 21:12:23 +02:00
|
|
|
ContentsWebView::ContentsWebView(content::BrowserContext* browser_context)
|
|
|
|
: views::WebView(browser_context),
|
|
|
|
status_bubble_(nullptr) {
|
|
|
|
+ // Mouse events on draggable regions will not be handled by the WebView.
|
|
|
|
+ // Avoid the resulting DCHECK in NativeViewHost::OnMousePressed by
|
|
|
|
+ // configuring the NativeViewHost not to process events via the view
|
|
|
|
+ // hierarchy.
|
|
|
|
+ holder()->SetCanProcessEventsWithinSubtree(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
ContentsWebView::~ContentsWebView() {
|
2023-03-07 00:21:57 +01:00
|
|
|
diff --git chrome/browser/ui/views/page_action/page_action_icon_controller.cc chrome/browser/ui/views/page_action/page_action_icon_controller.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
index 85a3c9eec15fe..e9a8bc50532f8 100644
|
2023-03-07 00:21:57 +01:00
|
|
|
--- chrome/browser/ui/views/page_action/page_action_icon_controller.cc
|
|
|
|
+++ chrome/browser/ui/views/page_action/page_action_icon_controller.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -93,6 +93,12 @@ void PageActionIconController::Init(const PageActionIconParams& params,
|
2023-03-07 00:21:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
for (PageActionIconType type : params.types_enabled) {
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (params.browser && params.browser->cef_delegate() &&
|
|
|
|
+ !params.browser->cef_delegate()->IsPageActionIconVisible(type)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
switch (type) {
|
|
|
|
case PageActionIconType::kPaymentsOfferNotification:
|
|
|
|
add_page_action_icon(
|
2021-02-18 02:58:25 +01:00
|
|
|
diff --git chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
index 2753a95f8ff35..9745477102917 100644
|
2021-02-18 02:58:25 +01:00
|
|
|
--- chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
|
|
|
|
+++ chrome/browser/ui/views/tabs/browser_tab_strip_controller.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -559,33 +559,47 @@ gfx::Range BrowserTabStripController::ListTabsInGroup(
|
2021-02-18 02:58:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserTabStripController::IsFrameCondensed() const {
|
|
|
|
+ if (!GetFrameView())
|
|
|
|
+ return false;
|
|
|
|
return GetFrameView()->IsFrameCondensed();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserTabStripController::HasVisibleBackgroundTabShapes() const {
|
|
|
|
+ if (!GetFrameView())
|
|
|
|
+ return false;
|
|
|
|
return GetFrameView()->HasVisibleBackgroundTabShapes(
|
|
|
|
BrowserFrameActiveState::kUseCurrent);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserTabStripController::EverHasVisibleBackgroundTabShapes() const {
|
|
|
|
+ if (!GetFrameView())
|
|
|
|
+ return false;
|
|
|
|
return GetFrameView()->EverHasVisibleBackgroundTabShapes();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserTabStripController::ShouldPaintAsActiveFrame() const {
|
|
|
|
+ if (!GetFrameView())
|
|
|
|
+ return false;
|
|
|
|
return GetFrameView()->ShouldPaintAsActive();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserTabStripController::CanDrawStrokes() const {
|
|
|
|
+ if (!GetFrameView())
|
|
|
|
+ return false;
|
|
|
|
return GetFrameView()->CanDrawStrokes();
|
|
|
|
}
|
|
|
|
|
|
|
|
SkColor BrowserTabStripController::GetFrameColor(
|
|
|
|
BrowserFrameActiveState active_state) const {
|
|
|
|
+ if (!GetFrameView())
|
|
|
|
+ return SK_ColorWHITE;
|
|
|
|
return GetFrameView()->GetFrameColor(active_state);
|
|
|
|
}
|
|
|
|
|
2021-06-04 03:34:56 +02:00
|
|
|
absl::optional<int> BrowserTabStripController::GetCustomBackgroundId(
|
2021-02-18 02:58:25 +01:00
|
|
|
BrowserFrameActiveState active_state) const {
|
|
|
|
+ if (!GetFrameView())
|
2021-06-04 03:34:56 +02:00
|
|
|
+ return absl::nullopt;
|
2021-02-18 02:58:25 +01:00
|
|
|
return GetFrameView()->GetCustomBackgroundId(active_state);
|
|
|
|
}
|
|
|
|
|
2021-04-11 22:10:11 +02:00
|
|
|
diff --git chrome/browser/ui/views/toolbar/toolbar_view.cc chrome/browser/ui/views/toolbar/toolbar_view.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
index 4682fa0f74996..099742d04102a 100644
|
2021-04-11 22:10:11 +02:00
|
|
|
--- chrome/browser/ui/views/toolbar/toolbar_view.cc
|
|
|
|
+++ chrome/browser/ui/views/toolbar/toolbar_view.cc
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -175,12 +175,13 @@ constexpr int kBrowserAppMenuRefreshCollapsedMargin = 2;
|
2021-04-11 22:10:11 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// ToolbarView, public:
|
|
|
|
|
|
|
|
-ToolbarView::ToolbarView(Browser* browser, BrowserView* browser_view)
|
|
|
|
+ToolbarView::ToolbarView(Browser* browser, BrowserView* browser_view,
|
2021-07-23 18:40:13 +02:00
|
|
|
+ absl::optional<DisplayMode> display_mode)
|
2021-04-11 22:10:11 +02:00
|
|
|
: AnimationDelegateViews(this),
|
|
|
|
browser_(browser),
|
|
|
|
browser_view_(browser_view),
|
|
|
|
app_menu_icon_controller_(browser->profile(), this),
|
|
|
|
- display_mode_(GetDisplayMode(browser)) {
|
|
|
|
+ display_mode_(display_mode ? *display_mode : GetDisplayMode(browser)) {
|
|
|
|
SetID(VIEW_ID_TOOLBAR);
|
|
|
|
|
2023-01-30 18:43:54 +01:00
|
|
|
if (display_mode_ == DisplayMode::NORMAL) {
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -202,6 +203,19 @@ ToolbarView::~ToolbarView() {
|
2023-04-26 21:55:59 +02:00
|
|
|
}
|
2023-03-07 00:21:57 +01:00
|
|
|
|
2023-04-26 21:55:59 +02:00
|
|
|
void ToolbarView::Init() {
|
2023-03-07 00:21:57 +01:00
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ using ToolbarButtonType = cef::BrowserDelegate::ToolbarButtonType;
|
|
|
|
+ auto button_visible = [this](ToolbarButtonType type) {
|
|
|
|
+ if (this->browser_->cef_delegate()) {
|
|
|
|
+ return this->browser_->cef_delegate()->IsToolbarButtonVisible(type);
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ };
|
|
|
|
+ #define BUTTON_VISIBLE(type) button_visible(ToolbarButtonType::type)
|
|
|
|
+#else
|
|
|
|
+ #define BUTTON_VISIBLE(type) true
|
|
|
|
+#endif
|
|
|
|
+
|
2023-04-26 21:55:59 +02:00
|
|
|
#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
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -211,12 +225,13 @@ void ToolbarView::Init() {
|
2023-04-26 21:55:59 +02:00
|
|
|
#endif
|
|
|
|
auto location_bar = std::make_unique<LocationBarView>(
|
|
|
|
browser_, browser_->profile(), browser_->command_controller(), this,
|
|
|
|
- display_mode_ != DisplayMode::NORMAL);
|
|
|
|
+ display_mode_ != DisplayMode::NORMAL && !browser_->toolbar_overridden());
|
|
|
|
// Make sure the toolbar shows by default.
|
|
|
|
size_animation_.Reset(1);
|
|
|
|
|
|
|
|
std::unique_ptr<DownloadToolbarButtonView> download_button;
|
|
|
|
- if (download::IsDownloadBubbleEnabled(browser_->profile())) {
|
|
|
|
+ if (download::IsDownloadBubbleEnabled(browser_->profile()) &&
|
|
|
|
+ BUTTON_VISIBLE(kDownload)) {
|
|
|
|
download_button =
|
|
|
|
std::make_unique<DownloadToolbarButtonView>(browser_view_);
|
|
|
|
}
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -297,8 +312,10 @@ void ToolbarView::Init() {
|
2023-04-04 20:00:13 +02:00
|
|
|
}
|
2023-03-07 00:21:57 +01:00
|
|
|
}
|
|
|
|
std::unique_ptr<media_router::CastToolbarButton> cast;
|
|
|
|
- if (media_router::MediaRouterEnabled(browser_->profile()))
|
|
|
|
+ if (media_router::MediaRouterEnabled(browser_->profile()) &&
|
|
|
|
+ BUTTON_VISIBLE(kCast)) {
|
|
|
|
cast = media_router::CastToolbarButton::Create(browser_);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
std::unique_ptr<MediaToolbarButtonView> media_button;
|
|
|
|
if (base::FeatureList::IsEnabled(media::kGlobalMediaControls)) {
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -308,7 +325,8 @@ void ToolbarView::Init() {
|
2023-03-07 00:21:57 +01:00
|
|
|
|
|
|
|
std::unique_ptr<send_tab_to_self::SendTabToSelfToolbarIconView>
|
|
|
|
send_tab_to_self_button;
|
|
|
|
- if (!browser_->profile()->IsOffTheRecord()) {
|
|
|
|
+ if (!browser_->profile()->IsOffTheRecord() &&
|
|
|
|
+ BUTTON_VISIBLE(kSendTabToSelf)) {
|
|
|
|
send_tab_to_self_button =
|
|
|
|
std::make_unique<send_tab_to_self::SendTabToSelfToolbarIconView>(
|
|
|
|
browser_view_);
|
2023-05-30 10:55:32 +02:00
|
|
|
@@ -316,7 +334,7 @@ void ToolbarView::Init() {
|
2023-03-07 00:21:57 +01:00
|
|
|
|
|
|
|
std::unique_ptr<SidePanelToolbarButton> side_panel_button;
|
2023-04-04 20:00:13 +02:00
|
|
|
std::unique_ptr<SidePanelToolbarContainer> side_panel_toolbar_container;
|
2023-03-07 00:21:57 +01:00
|
|
|
- if (browser_view_->unified_side_panel()) {
|
|
|
|
+ if (browser_view_->unified_side_panel() && BUTTON_VISIBLE(kSidePanel)) {
|
2023-04-26 21:55:59 +02:00
|
|
|
if (base::FeatureList::IsEnabled(
|
|
|
|
companion::features::kSidePanelCompanion)) {
|
2023-04-04 20:00:13 +02:00
|
|
|
side_panel_toolbar_container =
|
2021-04-11 22:10:11 +02:00
|
|
|
diff --git chrome/browser/ui/views/toolbar/toolbar_view.h chrome/browser/ui/views/toolbar/toolbar_view.h
|
2023-05-30 10:55:32 +02:00
|
|
|
index c38f2b0545d21..fe9a92b2f610c 100644
|
2021-04-11 22:10:11 +02:00
|
|
|
--- chrome/browser/ui/views/toolbar/toolbar_view.h
|
|
|
|
+++ chrome/browser/ui/views/toolbar/toolbar_view.h
|
2023-04-04 20:00:13 +02:00
|
|
|
@@ -89,7 +89,8 @@ class ToolbarView : public views::AccessiblePaneView,
|
2021-04-11 22:10:11 +02:00
|
|
|
// needs to be displayed.
|
|
|
|
};
|
|
|
|
|
|
|
|
- ToolbarView(Browser* browser, BrowserView* browser_view);
|
|
|
|
+ ToolbarView(Browser* browser, BrowserView* browser_view,
|
2021-07-23 18:40:13 +02:00
|
|
|
+ absl::optional<DisplayMode> display_mode);
|
2021-04-11 22:10:11 +02:00
|
|
|
ToolbarView(const ToolbarView&) = delete;
|
|
|
|
ToolbarView& operator=(const ToolbarView&) = delete;
|
|
|
|
~ToolbarView() override;
|