2021-04-11 22:10:11 +02:00
|
|
|
diff --git chrome/browser/ui/browser_command_controller.cc chrome/browser/ui/browser_command_controller.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index e70c1340dd2ee..745b3982aa9ad 100644
|
2021-04-11 22:10:11 +02:00
|
|
|
--- chrome/browser/ui/browser_command_controller.cc
|
|
|
|
+++ chrome/browser/ui/browser_command_controller.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -411,6 +411,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
|
|
|
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -427,6 +428,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) {
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1215,11 +1223,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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 2a1eb7cd0a644..b3e95b92b2951 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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -658,10 +658,12 @@ FindAndEditSubMenuModel::FindAndEditSubMenuModel(
|
|
|
|
ui::SimpleMenuModel::Delegate* delegate)
|
|
|
|
: SimpleMenuModel(delegate) {
|
|
|
|
AddItemWithStringIdAndVectorIcon(this, IDC_FIND, IDS_FIND, kSearchMenuIcon);
|
|
|
|
+ if (delegate->IsCommandIdVisible(IDC_EDIT_MENU)) {
|
|
|
|
AddSeparator(ui::NORMAL_SEPARATOR);
|
|
|
|
AddItemWithStringIdAndVectorIcon(this, IDC_CUT, IDS_CUT, kCutMenuIcon);
|
|
|
|
AddItemWithStringIdAndVectorIcon(this, IDC_COPY, IDS_COPY, kCopyMenuIcon);
|
|
|
|
AddItemWithStringIdAndVectorIcon(this, IDC_PASTE, IDS_PASTE, kPasteMenuIcon);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
class SaveAndShareSubMenuModel : public ui::SimpleMenuModel {
|
|
|
|
@@ -736,6 +738,57 @@ SaveAndShareSubMenuModel::SaveAndShareSubMenuModel(
|
2023-05-30 10:55:32 +02:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1596,7 +1649,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);
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1611,6 +1664,30 @@ bool AppMenuModel::IsCommandIdEnabled(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 BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (browser_->cef_delegate()) {
|
|
|
|
+ return browser_->cef_delegate()->IsAppMenuItemVisible(command_id);
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
bool AppMenuModel::IsCommandIdAlerted(int command_id) const {
|
2023-11-21 20:17:55 +01:00
|
|
|
if (command_id == IDC_VIEW_PASSWORDS ||
|
|
|
|
command_id == IDC_SHOW_PASSWORD_MANAGER) {
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1773,8 +1850,10 @@ void AppMenuModel::Build() {
|
2024-05-23 03:52:35 +02:00
|
|
|
IDS_CLEAR_BROWSING_DATA,
|
|
|
|
kTrashCanRefreshIcon);
|
2023-03-07 00:21:57 +01:00
|
|
|
|
|
|
|
+ if (IsCommandIdVisible(IDC_ZOOM_MENU)) {
|
2024-05-23 03:52:35 +02:00
|
|
|
AddSeparator(ui::NORMAL_SEPARATOR);
|
|
|
|
CreateZoomMenu();
|
2023-03-07 00:21:57 +01:00
|
|
|
+ }
|
2024-05-23 03:52:35 +02:00
|
|
|
AddSeparator(ui::NORMAL_SEPARATOR);
|
2023-03-07 00:21:57 +01:00
|
|
|
|
2024-05-23 03:52:35 +02:00
|
|
|
AddItemWithStringIdAndVectorIcon(this, IDC_PRINT, IDS_PRINT, kPrintMenuIcon);
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1896,6 +1975,11 @@ void AppMenuModel::Build() {
|
2023-03-07 00:21:57 +01:00
|
|
|
}
|
2024-05-23 03:52:35 +02:00
|
|
|
#endif // !BUILDFLAG(IS_CHROMEOS_ASH)
|
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
|
2024-06-14 19:01:45 +02:00
|
|
|
index ada5cc02223d4..37da48f2e5412 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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -232,6 +232,7 @@ class AppMenuModel : public ui::SimpleMenuModel,
|
2023-06-26 12:13:38 +02:00
|
|
|
void ExecuteCommand(int command_id, int event_flags) override;
|
|
|
|
bool IsCommandIdChecked(int command_id) const override;
|
|
|
|
bool IsCommandIdEnabled(int command_id) const override;
|
|
|
|
+ bool IsCommandIdVisible(int command_id) const override;
|
|
|
|
bool IsCommandIdAlerted(int command_id) const override;
|
2023-11-21 20:17:55 +01:00
|
|
|
bool IsElementIdAlerted(ui::ElementIdentifier element_id) const override;
|
2023-06-26 12:13:38 +02:00
|
|
|
bool GetAcceleratorForCommandId(int command_id,
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -272,6 +273,8 @@ class AppMenuModel : public ui::SimpleMenuModel,
|
2024-05-23 03:52:35 +02:00
|
|
|
void LogSafetyHubInteractionMetrics(safety_hub::SafetyHubModuleType sh_module,
|
|
|
|
int event_flags);
|
2023-03-07 00:21:57 +01:00
|
|
|
|
|
|
|
+ bool IsCommandIdEnabledInternal(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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 86fad4ad36024..8ca6f3e0eb42f 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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -583,6 +583,14 @@ gfx::Rect FindBarHost::GetDialogPosition(gfx::Rect avoid_overlapping_rect) {
|
2023-04-12 20:34:39 +02:00
|
|
|
// 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.
|
2024-03-19 22:11:42 +01:00
|
|
|
gfx::Rect find_bar_bounds = browser_view_->GetFindBarBoundingBox();
|
2023-04-12 20:34:39 +02:00
|
|
|
+
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
2024-03-19 22:11:42 +01:00
|
|
|
+ if (browser_view_->browser() && browser_view_->browser()->cef_delegate()) {
|
|
|
|
+ browser_view_->browser()->cef_delegate()->UpdateFindBarBoundingBox(
|
|
|
|
+ &find_bar_bounds);
|
2023-04-12 20:34:39 +02:00
|
|
|
+ }
|
|
|
|
+#endif
|
2024-03-19 22:11:42 +01:00
|
|
|
+
|
|
|
|
if (find_bar_bounds.IsEmpty()) {
|
|
|
|
return gfx::Rect();
|
|
|
|
}
|
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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 19343898d78d9..9b974442606b4 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
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -114,15 +114,25 @@ ui::ColorProviderKey::SchemeVariant GetSchemeVariant(
|
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)
|
2024-05-13 23:36:09 +02:00
|
|
|
+ SetBrowserView(browser_view);
|
2021-02-18 02:58:25 +01:00
|
|
|
+}
|
|
|
|
+
|
2024-05-13 23:36:09 +02:00
|
|
|
+void BrowserFrame::SetBrowserView(BrowserView* browser_view) {
|
2021-02-18 02:58:25 +01:00
|
|
|
+ browser_view_ = browser_view;
|
2024-05-13 23:36:09 +02:00
|
|
|
+ if (browser_view_) {
|
|
|
|
+ browser_view_->set_frame(this);
|
|
|
|
+ }
|
2021-02-18 02:58:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
BrowserFrame::~BrowserFrame() {}
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -228,10 +238,20 @@ 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-11-14 18:16:43 +01:00
|
|
|
void BrowserFrame::UpdateThrobber(bool running) {
|
|
|
|
+ if (!browser_frame_view_) {
|
|
|
|
+ // Not supported with CEF Views-hosted DevTools windows.
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
browser_frame_view_->UpdateThrobber(running);
|
|
|
|
}
|
|
|
|
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -240,6 +260,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();
|
|
|
|
}
|
|
|
|
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -253,20 +275,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(
|
2024-06-14 19:01:45 +02:00
|
|
|
const input::NativeWebKeyboardEvent& event) {
|
2021-02-18 02:58:25 +01:00
|
|
|
+ if (!native_browser_frame_)
|
|
|
|
+ return content::KeyboardEventProcessingResult::NOT_HANDLED;
|
|
|
|
return native_browser_frame_->PreHandleKeyboardEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BrowserFrame::HandleKeyboardEvent(
|
2024-06-14 19:01:45 +02:00
|
|
|
const input::NativeWebKeyboardEvent& event) {
|
2021-02-18 02:58:25 +01:00
|
|
|
+ if (!native_browser_frame_)
|
|
|
|
+ return false;
|
|
|
|
return native_browser_frame_->HandleKeyboardEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserFrame::OnBrowserViewInitViewsComplete() {
|
|
|
|
+ if (!browser_frame_view_)
|
|
|
|
+ return;
|
|
|
|
browser_frame_view_->OnBrowserViewInitViewsComplete();
|
|
|
|
}
|
|
|
|
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -367,6 +399,8 @@ ui::ColorProviderKey::ThemeInitializerSupplier* BrowserFrame::GetCustomTheme()
|
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());
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -572,6 +606,13 @@ void BrowserFrame::SelectNativeTheme() {
|
2024-03-29 17:48:33 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Always use the NativeTheme for forced color modes.
|
|
|
|
+ if (ui::NativeTheme::IsForcedDarkMode() ||
|
|
|
|
+ ui::NativeTheme::IsForcedLightMode()) {
|
|
|
|
+ SetNativeTheme(native_theme);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
// Ignore the system theme for web apps with window-controls-overlay as the
|
|
|
|
// display_override so the web contents can blend with the overlay by using
|
|
|
|
// the developer-provided theme color for a better experience. Context:
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -637,5 +678,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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 14a8a70d853f6..bf81594947886 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
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -58,6 +58,7 @@ 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);
|
|
|
|
|
2021-10-19 00:17:16 +02:00
|
|
|
BrowserFrame(const BrowserFrame&) = delete;
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -137,7 +138,7 @@ class BrowserFrame : public views::Widget, public views::ContextMenuController {
|
2024-03-29 17:48:33 +01:00
|
|
|
|
|
|
|
// ThemeService calls this when a user has changed their theme, indicating
|
|
|
|
// that it's time to redraw everything.
|
|
|
|
- void UserChangedTheme(BrowserThemeChangeType theme_change_type);
|
|
|
|
+ virtual void UserChangedTheme(BrowserThemeChangeType theme_change_type);
|
|
|
|
|
|
|
|
// views::Widget:
|
|
|
|
views::internal::RootView* CreateRootView() override;
|
2024-05-13 23:36:09 +02:00
|
|
|
@@ -170,22 +171,26 @@ class BrowserFrame : public views::Widget, public views::ContextMenuController {
|
|
|
|
void SetTabDragKind(TabDragKind tab_drag_kind);
|
|
|
|
TabDragKind tab_drag_kind() const { return tab_drag_kind_; }
|
|
|
|
|
|
|
|
+ BrowserView* browser_view() const { return browser_view_.get(); }
|
|
|
|
+
|
|
|
|
protected:
|
|
|
|
+ void SetBrowserView(BrowserView* browser_view);
|
|
|
|
+
|
|
|
|
// views::Widget:
|
2024-03-29 17:48:33 +01:00
|
|
|
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;
|
|
|
|
ui::ColorProviderKey GetColorProviderKey() const override;
|
|
|
|
|
|
|
|
+ // Select a native theme that is appropriate for the current context. This is
|
|
|
|
+ // currently only needed for Linux to switch between the regular NativeTheme
|
|
|
|
+ // and the GTK NativeTheme instance.
|
|
|
|
+ void SelectNativeTheme();
|
|
|
|
+
|
|
|
|
private:
|
|
|
|
void OnTouchUiChanged();
|
|
|
|
|
|
|
|
// Callback for MenuRunner.
|
|
|
|
void OnMenuClosed();
|
|
|
|
|
|
|
|
- // Select a native theme that is appropriate for the current context. This is
|
|
|
|
- // currently only needed for Linux to switch between the regular NativeTheme
|
|
|
|
- // and the GTK NativeTheme instance.
|
|
|
|
- void SelectNativeTheme();
|
|
|
|
-
|
|
|
|
// Regenerate the frame on theme change if necessary. Returns true if
|
|
|
|
// regenerated.
|
|
|
|
bool RegenerateFrameOnThemeChange(BrowserThemeChangeType theme_change_type);
|
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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 1142fec7a138c..71e381f04adcc 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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -350,11 +350,10 @@ using content::WebContents;
|
|
|
|
using input::NativeWebKeyboardEvent;
|
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.
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -694,6 +693,14 @@ class BrowserViewLayoutDelegateImpl : public BrowserViewLayoutDelegate {
|
2024-01-12 00:32:08 +01:00
|
|
|
return browser_view_->frame()->GetTopInset() - browser_view_->y();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ void UpdateDialogTopInsetInBrowserView(int* dialog_top_y) const override {
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (auto cef_delegate = browser_view_->browser_->cef_delegate()) {
|
|
|
|
+ cef_delegate->UpdateDialogTopInset(dialog_top_y);
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
bool IsToolbarVisible() const override {
|
|
|
|
return browser_view_->IsToolbarVisible();
|
|
|
|
}
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -845,11 +852,21 @@ 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_(
|
2023-11-21 20:17:55 +01:00
|
|
|
std::make_unique<AccessibilityModeObserver>(this)) {
|
|
|
|
+ if (browser) {
|
2021-02-18 02:58:25 +01:00
|
|
|
+ InitBrowser(std::move(browser));
|
2023-11-21 20:17:55 +01:00
|
|
|
+ }
|
2021-02-18 02:58:25 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void BrowserView::InitBrowser(std::unique_ptr<Browser> browser) {
|
|
|
|
+ DCHECK(!browser_);
|
|
|
|
+ browser_ = std::move(browser);
|
|
|
|
+
|
2024-06-14 19:01:45 +02:00
|
|
|
SetShowIcon(
|
|
|
|
::ShouldShowWindowIcon(browser_.get(), AppUsesWindowControlsOverlay()));
|
|
|
|
|
|
|
|
@@ -944,8 +961,15 @@ BrowserView::BrowserView(std::unique_ptr<Browser> browser)
|
2021-04-11 22:10:11 +02:00
|
|
|
contents_container->SetLayoutManager(std::make_unique<ContentsLayoutManager>(
|
2024-03-19 22:11:42 +01:00
|
|
|
devtools_web_view_, contents_web_view_, watermark_view_));
|
2021-04-11 22:10:11 +02:00
|
|
|
|
|
|
|
- toolbar_ = top_container_->AddChildView(
|
|
|
|
- std::make_unique<ToolbarView>(browser_.get(), this));
|
2023-09-07 19:28:27 +02:00
|
|
|
+ toolbar_ = OverrideCreateToolbar();
|
2021-04-11 22:10:11 +02:00
|
|
|
+ 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>());
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1019,7 +1043,9 @@ BrowserView::~BrowserView() {
|
2023-10-13 19:48:01 +02:00
|
|
|
|
|
|
|
// All the tabs should have been destroyed already. If we were closed by the
|
|
|
|
// OS with some tabs than the NativeBrowserFrame should have destroyed them.
|
|
|
|
+ if (browser_) {
|
|
|
|
DCHECK_EQ(0, browser_->tab_strip_model()->count());
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// Stop the animation timer explicitly here to avoid running it in a nested
|
|
|
|
// message loop, which may run by Browser destructor.
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1028,17 +1054,18 @@ BrowserView::~BrowserView() {
|
2024-05-13 23:36:09 +02:00
|
|
|
// Immersive mode may need to reparent views before they are removed/deleted.
|
|
|
|
immersive_mode_controller_.reset();
|
|
|
|
|
|
|
|
- // Reset autofill bubble handler to make sure it does not out-live toolbar,
|
|
|
|
- // since it is responsible for showing autofill related bubbles from toolbar's
|
|
|
|
- // child views and it is an observer for avatar toolbar button if any.
|
|
|
|
- autofill_bubble_handler_.reset();
|
|
|
|
+ // If the Toolbar is not overloaded it will be destroyed via
|
|
|
|
+ // RemoveAllChildViews().
|
|
|
|
+ WillDestroyToolbar();
|
2023-10-13 19:48:01 +02:00
|
|
|
|
|
|
|
+ if (browser_) {
|
|
|
|
auto* global_registry =
|
|
|
|
extensions::ExtensionCommandsGlobalRegistry::Get(browser_->profile());
|
|
|
|
if (global_registry->registry_for_active_window() ==
|
|
|
|
extension_keybinding_registry_.get()) {
|
|
|
|
global_registry->set_registry_for_active_window(nullptr);
|
|
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
|
|
// The TabStrip attaches a listener to the model. Make sure we shut down the
|
|
|
|
// TabStrip first so that it can cleanly remove the listener.
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1062,7 +1089,9 @@ BrowserView::~BrowserView() {
|
2023-10-13 19:48:01 +02:00
|
|
|
|
|
|
|
// `SidePanelUI::RemoveSidePanelUIForBrowser()` deletes the
|
|
|
|
// SidePanelCoordinator.
|
|
|
|
+ if (browser()) {
|
|
|
|
SidePanelUI::RemoveSidePanelUIForBrowser(browser());
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1618,6 +1647,13 @@ gfx::Point BrowserView::GetThemeOffsetFromBrowserView() const {
|
2024-05-13 23:36:09 +02:00
|
|
|
ThemeProperties::kFrameHeightAboveTabs - browser_view_origin.y());
|
|
|
|
}
|
|
|
|
|
|
|
|
+void BrowserView::WillDestroyToolbar() {
|
|
|
|
+ // Reset autofill bubble handler to make sure it does not out-live toolbar,
|
|
|
|
+ // since it is responsible for showing autofill related bubbles from toolbar's
|
|
|
|
+ // child views and it is an observer for avatar toolbar button if any.
|
|
|
|
+ autofill_bubble_handler_.reset();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
// static:
|
|
|
|
BrowserView::DevToolsDockedPlacement BrowserView::GetDevToolsDockedPlacement(
|
|
|
|
const gfx::Rect& contents_webview_bounds,
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -2021,9 +2057,14 @@ void BrowserView::OnExclusiveAccessUserInput() {
|
2023-10-23 20:39:33 +02:00
|
|
|
|
|
|
|
bool BrowserView::ShouldHideUIForFullscreen() const {
|
|
|
|
// Immersive mode needs UI for the slide-down top panel.
|
|
|
|
- if (immersive_mode_controller_->IsEnabled())
|
|
|
|
+ // Avoid callback into |immersive_mode_controller_| during construction.
|
|
|
|
+ // See CEF issue #3527.
|
|
|
|
+ if (immersive_mode_controller_ &&
|
|
|
|
+ immersive_mode_controller_->IsEnabled())
|
2021-02-18 02:58:25 +01:00
|
|
|
return false;
|
|
|
|
|
|
|
|
+ if (!frame_->GetFrameView())
|
|
|
|
+ return false;
|
|
|
|
return frame_->GetFrameView()->ShouldHideTopUIForFullscreen();
|
|
|
|
}
|
|
|
|
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -3185,7 +3226,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;
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -3740,7 +3782,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();
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -4223,11 +4266,38 @@ void BrowserView::GetAccessiblePanes(std::vector<views::View*>* panes) {
|
2023-09-07 19:28:27 +02:00
|
|
|
bool BrowserView::ShouldDescendIntoChildForEventHandling(
|
|
|
|
gfx::NativeView child,
|
|
|
|
const gfx::Point& location) {
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ const bool frameless_pip =
|
|
|
|
+ GetIsPictureInPictureType() &&
|
|
|
|
+ !browser_->SupportsWindowFeature(Browser::FEATURE_TITLEBAR);
|
|
|
|
+ if (frameless_pip) {
|
|
|
|
+ if (auto frame_view = frame()->GetFrameView()) {
|
|
|
|
+ int result = frame_view->NonClientHitTest(location);
|
|
|
|
+ if (result == HTTOP || result == HTTOPLEFT || result == HTTOPRIGHT) {
|
|
|
|
+ // Allow resize from the top of a frameless window.
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ absl::optional<SkRegion> draggable_region;
|
|
|
|
+
|
|
|
|
// Window for PWAs with window-controls-overlay display override should claim
|
|
|
|
// mouse events that fall within the draggable region.
|
|
|
|
web_app::AppBrowserController* controller = browser()->app_controller();
|
|
|
|
- if (AreDraggableRegionsEnabled() && controller &&
|
|
|
|
- controller->draggable_region().has_value()) {
|
|
|
|
+ if (AreDraggableRegionsEnabled() && controller) {
|
|
|
|
+ draggable_region = controller->draggable_region();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ // Match logic in PictureInPictureBrowserFrameView::NonClientHitTest.
|
|
|
|
+ if (!draggable_region.has_value() && frameless_pip) {
|
|
|
|
+ draggable_region = browser_->cef_delegate()->GetDraggableRegion();
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+ if (draggable_region.has_value()) {
|
|
|
|
// Draggable regions are defined relative to the web contents.
|
|
|
|
gfx::Point point_in_contents_web_view_coords(location);
|
|
|
|
views::View::ConvertPointToTarget(GetWidget()->GetRootView(),
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -4236,7 +4306,7 @@ bool BrowserView::ShouldDescendIntoChildForEventHandling(
|
2023-09-07 19:28:27 +02:00
|
|
|
|
|
|
|
// Draggable regions should be ignored for clicks into any browser view's
|
|
|
|
// owned widgets, for example alerts, permission prompts or find bar.
|
|
|
|
- return !controller->draggable_region()->contains(
|
|
|
|
+ return !draggable_region->contains(
|
|
|
|
point_in_contents_web_view_coords.x(),
|
|
|
|
point_in_contents_web_view_coords.y()) ||
|
|
|
|
WidgetOwnedByAnchorContainsPoint(point_in_contents_web_view_coords);
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -4347,8 +4417,10 @@ void BrowserView::Layout(PassKey) {
|
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();
|
|
|
|
|
2024-01-26 03:12:43 +01:00
|
|
|
// Some of the situations when the BrowserView is laid out are:
|
|
|
|
// - Enter/exit immersive fullscreen mode.
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -4414,6 +4486,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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -4455,13 +4532,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();
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -4821,7 +4894,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();
|
|
|
|
}
|
|
|
|
|
2024-05-23 03:52:35 +02:00
|
|
|
void BrowserView::RequestFullscreen(bool fullscreen, int64_t display_id) {
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -5294,6 +5368,8 @@ Profile* BrowserView::GetProfile() {
|
2022-01-13 00:11:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BrowserView::UpdateUIForTabFullscreen() {
|
|
|
|
+ if (!frame_->GetFrameView())
|
|
|
|
+ return;
|
|
|
|
frame()->GetFrameView()->UpdateFullscreenTopUI();
|
|
|
|
}
|
|
|
|
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -5316,6 +5392,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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 0e1ac9a2fd806..0b6f9370737f0 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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -142,11 +142,16 @@ class BrowserView : public BrowserWindow,
|
2024-01-26 03:12:43 +01:00
|
|
|
METADATA_HEADER(BrowserView, views::ClientView)
|
2023-08-09 23:17:17 +02:00
|
|
|
|
2024-01-26 03:12:43 +01:00
|
|
|
public:
|
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_ =
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -862,6 +867,10 @@ class BrowserView : public BrowserWindow,
|
|
|
|
base::WeakPtr<content::WebContents> expected_web_contents,
|
|
|
|
const enterprise_data_protection::UrlSettings& settings);
|
2024-05-13 23:36:09 +02:00
|
|
|
|
|
|
|
+ // Called during Toolbar destruction to remove dependent objects that have
|
|
|
|
+ // dangling references.
|
|
|
|
+ virtual void WillDestroyToolbar();
|
|
|
|
+
|
|
|
|
protected:
|
|
|
|
// Enumerates where the devtools are docked relative to the browser's main
|
|
|
|
// web contents.
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -885,6 +894,8 @@ class BrowserView : public BrowserWindow,
|
2024-01-26 03:12:43 +01:00
|
|
|
const gfx::Rect& contents_webview_bounds,
|
|
|
|
const gfx::Rect& local_webview_container_bounds);
|
2021-04-11 22:10:11 +02:00
|
|
|
|
2023-09-07 19:28:27 +02:00
|
|
|
+ virtual ToolbarView* OverrideCreateToolbar() { return nullptr; }
|
2021-04-11 22:10:11 +02:00
|
|
|
+
|
|
|
|
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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 96b489221fb3a..b372f67cd5c92 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-09-15 21:51:43 +02:00
|
|
|
@@ -48,6 +48,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;
|
2024-01-12 00:32:08 +01:00
|
|
|
@@ -92,6 +96,10 @@ class BrowserViewLayout::WebContentsModalDialogHostViews
|
|
|
|
observer.OnHostDestroying();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ bool HasObservers() const {
|
|
|
|
+ return !observer_list_.empty();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
void NotifyPositionRequiresUpdate() {
|
|
|
|
for (ModalDialogHostObserver& observer : observer_list_)
|
|
|
|
observer.OnPositionRequiresUpdate();
|
|
|
|
@@ -102,7 +110,7 @@ class BrowserViewLayout::WebContentsModalDialogHostViews
|
|
|
|
views::View* view = browser_view_layout_->contents_container_;
|
|
|
|
gfx::Rect rect = view->ConvertRectToWidget(view->GetLocalBounds());
|
|
|
|
const int middle_x = rect.x() + rect.width() / 2;
|
|
|
|
- const int top = browser_view_layout_->dialog_top_y_;
|
|
|
|
+ const int top = GetDialogTopY();
|
|
|
|
return gfx::Point(middle_x - size.width() / 2, top);
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -117,7 +125,7 @@ class BrowserViewLayout::WebContentsModalDialogHostViews
|
|
|
|
gfx::Size GetMaximumDialogSize() override {
|
|
|
|
views::View* view = browser_view_layout_->contents_container_;
|
|
|
|
gfx::Rect content_area = view->ConvertRectToWidget(view->GetLocalBounds());
|
|
|
|
- const int top = browser_view_layout_->dialog_top_y_;
|
|
|
|
+ const int top = GetDialogTopY();
|
|
|
|
return gfx::Size(content_area.width(), content_area.bottom() - top);
|
|
|
|
}
|
|
|
|
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -132,6 +140,13 @@ class BrowserViewLayout::WebContentsModalDialogHostViews
|
|
|
|
return host_widget ? host_widget->GetNativeView() : nullptr;
|
2024-01-12 00:32:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+ int GetDialogTopY() const {
|
|
|
|
+ int dialog_top_y = browser_view_layout_->dialog_top_y_;
|
|
|
|
+ browser_view_layout_->delegate_->UpdateDialogTopInsetInBrowserView(
|
|
|
|
+ &dialog_top_y);
|
|
|
|
+ return dialog_top_y;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
// Add/remove observer.
|
|
|
|
void AddObserver(ModalDialogHostObserver* observer) override {
|
|
|
|
observer_list_.AddObserver(observer);
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -442,6 +457,8 @@ void BrowserViewLayout::Layout(views::View* browser_view) {
|
2024-01-12 00:32:08 +01:00
|
|
|
if (exclusive_access_bubble)
|
|
|
|
exclusive_access_bubble->RepositionIfVisible();
|
|
|
|
|
|
|
|
+ // Avoid unnecessary calls to UpdateDialogTopInsetInBrowserView().
|
|
|
|
+ if (dialog_host_->HasObservers()) {
|
|
|
|
// Adjust any hosted dialogs if the browser's dialog hosting bounds changed.
|
|
|
|
const gfx::Rect dialog_bounds(dialog_host_->GetDialogPosition(gfx::Size()),
|
|
|
|
dialog_host_->GetMaximumDialogSize());
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -455,6 +472,7 @@ void BrowserViewLayout::Layout(views::View* browser_view) {
|
2024-01-12 00:32:08 +01:00
|
|
|
latest_dialog_bounds_in_screen_ = dialog_bounds_in_screen;
|
|
|
|
dialog_host_->NotifyPositionRequiresUpdate();
|
|
|
|
}
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
2024-05-23 03:52:35 +02:00
|
|
|
gfx::Size BrowserViewLayout::GetPreferredSize(
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -590,6 +608,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;
|
2024-01-12 00:32:08 +01:00
|
|
|
diff --git chrome/browser/ui/views/frame/browser_view_layout_delegate.h chrome/browser/ui/views/frame/browser_view_layout_delegate.h
|
|
|
|
index 29ad5517bd3c9..b0fe093467abc 100644
|
|
|
|
--- chrome/browser/ui/views/frame/browser_view_layout_delegate.h
|
|
|
|
+++ chrome/browser/ui/views/frame/browser_view_layout_delegate.h
|
|
|
|
@@ -28,6 +28,7 @@ class BrowserViewLayoutDelegate {
|
|
|
|
const gfx::Rect& available_space,
|
|
|
|
views::Label& window_title_label) const = 0;
|
|
|
|
virtual int GetTopInsetInBrowserView() const = 0;
|
|
|
|
+ virtual void UpdateDialogTopInsetInBrowserView(int* dialog_top_y) const = 0;
|
|
|
|
virtual bool IsToolbarVisible() const = 0;
|
|
|
|
virtual bool IsBookmarkBarVisible() const = 0;
|
|
|
|
virtual bool IsContentsSeparatorEnabled() const = 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
|
2024-01-26 03:12:43 +01:00
|
|
|
index 71445bfab1824..c77750ea2a820 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
|
2024-01-26 03:12:43 +01:00
|
|
|
@@ -28,6 +28,12 @@ ContentsWebView::ContentsWebView(content::BrowserContext* browser_context)
|
2022-04-14 21:12:23 +02:00
|
|
|
: views::WebView(browser_context),
|
|
|
|
status_bubble_(nullptr) {
|
2024-01-26 03:12:43 +01:00
|
|
|
SetProperty(views::kElementIdentifierKey, kContentsWebViewElementId);
|
|
|
|
+
|
2022-04-14 21:12:23 +02:00
|
|
|
+ // 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-09-07 19:28:27 +02:00
|
|
|
diff --git chrome/browser/ui/views/frame/picture_in_picture_browser_frame_view.cc chrome/browser/ui/views/frame/picture_in_picture_browser_frame_view.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
index 9858a9660ccee..a0cc25fb4fca4 100644
|
2023-09-07 19:28:27 +02:00
|
|
|
--- chrome/browser/ui/views/frame/picture_in_picture_browser_frame_view.cc
|
|
|
|
+++ chrome/browser/ui/views/frame/picture_in_picture_browser_frame_view.cc
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -606,6 +606,11 @@ PictureInPictureBrowserFrameView::PictureInPictureBrowserFrameView(
|
|
|
|
return window->GetProperty(chromeos::kWindowStateTypeKey);
|
|
|
|
})));
|
2023-09-07 19:28:27 +02:00
|
|
|
#endif
|
|
|
|
+
|
|
|
|
+ if (!browser_view->browser()->SupportsWindowFeature(
|
|
|
|
+ Browser::FEATURE_TITLEBAR)) {
|
|
|
|
+ top_bar_container_view_->SetVisible(false);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
PictureInPictureBrowserFrameView::~PictureInPictureBrowserFrameView() {
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -733,18 +738,42 @@ gfx::Rect PictureInPictureBrowserFrameView::GetWindowBoundsForClientBounds(
|
2023-09-07 19:28:27 +02:00
|
|
|
|
|
|
|
int PictureInPictureBrowserFrameView::NonClientHitTest(
|
|
|
|
const gfx::Point& point) {
|
|
|
|
- // Allow interacting with the buttons.
|
|
|
|
- if (GetLocationIconViewBounds().Contains(point) ||
|
|
|
|
- GetBackToTabControlsBounds().Contains(point) ||
|
|
|
|
- GetCloseControlsBounds().Contains(point)) {
|
|
|
|
- return HTCLIENT;
|
|
|
|
+ const bool frameless = !top_bar_container_view_->GetVisible();
|
|
|
|
+ if (!frameless) {
|
|
|
|
+ // Allow interacting with the buttons.
|
|
|
|
+ if (GetLocationIconViewBounds().Contains(point) ||
|
|
|
|
+ GetBackToTabControlsBounds().Contains(point) ||
|
|
|
|
+ GetCloseControlsBounds().Contains(point)) {
|
2023-11-06 21:46:43 +01:00
|
|
|
+ return HTCLIENT;
|
|
|
|
+ }
|
2023-09-07 19:28:27 +02:00
|
|
|
+
|
|
|
|
+ for (size_t i = 0; i < content_setting_views_.size(); i++) {
|
|
|
|
+ if (GetContentSettingViewBounds(i).Contains(point)) {
|
|
|
|
+ return HTCLIENT;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
2023-11-06 21:46:43 +01:00
|
|
|
- for (size_t i = 0; i < content_setting_views_.size(); i++) {
|
|
|
|
- if (GetContentSettingViewBounds(i).Contains(point)) {
|
|
|
|
- return HTCLIENT;
|
2023-09-07 19:28:27 +02:00
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (frameless) {
|
|
|
|
+ // Match logic in BrowserView::ShouldDescendIntoChildForEventHandling.
|
|
|
|
+ const auto draggable_region =
|
|
|
|
+ browser_view()->browser()->cef_delegate()->GetDraggableRegion();
|
|
|
|
+ if (draggable_region.has_value()) {
|
|
|
|
+ // Draggable regions are defined relative to the web contents.
|
|
|
|
+ gfx::Point point_in_contents_web_view_coords(point);
|
|
|
|
+ views::View::ConvertPointToTarget(GetWidget()->GetRootView(),
|
|
|
|
+ browser_view()->contents_web_view(),
|
|
|
|
+ &point_in_contents_web_view_coords);
|
|
|
|
+
|
|
|
|
+ if (draggable_region->contains(
|
|
|
|
+ point_in_contents_web_view_coords.x(),
|
|
|
|
+ point_in_contents_web_view_coords.y())) {
|
|
|
|
+ return HTCAPTION;
|
|
|
|
+ }
|
2023-11-06 21:46:43 +01:00
|
|
|
}
|
|
|
|
}
|
2023-09-07 19:28:27 +02:00
|
|
|
+#endif // BUILDFLAG(ENABLE_CEF)
|
2023-11-06 21:46:43 +01:00
|
|
|
|
|
|
|
// Allow dragging and resizing the window.
|
|
|
|
int window_component = GetHTComponentForFrame(
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -813,7 +842,8 @@ void PictureInPictureBrowserFrameView::Layout(PassKey) {
|
2023-09-07 19:28:27 +02:00
|
|
|
gfx::Rect content_area = GetLocalBounds();
|
|
|
|
content_area.Inset(FrameBorderInsets());
|
|
|
|
gfx::Rect top_bar = content_area;
|
|
|
|
- top_bar.set_height(kTopControlsHeight);
|
|
|
|
+ top_bar.set_height(
|
|
|
|
+ top_bar_container_view_->GetVisible() ? kTopControlsHeight : 0);
|
|
|
|
top_bar_container_view_->SetBoundsRect(top_bar);
|
|
|
|
#if !BUILDFLAG(IS_ANDROID)
|
|
|
|
if (auto_pip_setting_overlay_) {
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -1300,7 +1330,8 @@ gfx::Insets PictureInPictureBrowserFrameView::ResizeBorderInsets() const {
|
2023-09-07 19:28:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int PictureInPictureBrowserFrameView::GetTopAreaHeight() const {
|
|
|
|
- return FrameBorderInsets().top() + kTopControlsHeight;
|
|
|
|
+ return FrameBorderInsets().top() +
|
|
|
|
+ (top_bar_container_view_->GetVisible() ? kTopControlsHeight : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::Size PictureInPictureBrowserFrameView::GetNonClientViewAreaSize() const {
|
2023-12-06 21:16:15 +01:00
|
|
|
diff --git chrome/browser/ui/views/omnibox/omnibox_popup_closer.cc chrome/browser/ui/views/omnibox/omnibox_popup_closer.cc
|
|
|
|
index b862ceac7225d..9575440a77d67 100644
|
|
|
|
--- chrome/browser/ui/views/omnibox/omnibox_popup_closer.cc
|
|
|
|
+++ chrome/browser/ui/views/omnibox/omnibox_popup_closer.cc
|
|
|
|
@@ -27,7 +27,8 @@ OmniboxPopupCloser::OmniboxPopupCloser(BrowserView* browser_view)
|
|
|
|
OmniboxPopupCloser::~OmniboxPopupCloser() = default;
|
|
|
|
|
|
|
|
void OmniboxPopupCloser::OnMouseEvent(ui::MouseEvent* event) {
|
|
|
|
- if (!browser_view_->browser()->is_delete_scheduled() &&
|
|
|
|
+ if (browser_view_->browser() &&
|
|
|
|
+ !browser_view_->browser()->is_delete_scheduled() &&
|
|
|
|
event->type() == ui::ET_MOUSE_PRESSED) {
|
|
|
|
LocationBarView* location_bar_view = browser_view_->GetLocationBarView();
|
|
|
|
CHECK(location_bar_view);
|
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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 04639b0a2f603..f4cfc16f6b4de 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
|
2024-05-23 03:52:35 +02:00
|
|
|
@@ -96,6 +96,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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 9ba58b49d613e..90749dcd2d945 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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -605,29 +605,41 @@ 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::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);
|
|
|
|
}
|
|
|
|
|
2024-01-26 03:12:43 +01:00
|
|
|
std::optional<int> BrowserTabStripController::GetCustomBackgroundId(
|
2021-02-18 02:58:25 +01:00
|
|
|
BrowserFrameActiveState active_state) const {
|
|
|
|
+ if (!GetFrameView())
|
2024-01-26 03:12:43 +01:00
|
|
|
+ return std::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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 05ae08a41e203..1d99112e56e14 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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -190,7 +190,7 @@ class TabstripLikeBackground : public views::Background {
|
2023-08-09 23:17:17 +02:00
|
|
|
void Paint(gfx::Canvas* canvas, views::View* view) const override {
|
2023-09-15 21:51:43 +02:00
|
|
|
bool painted = TopContainerBackground::PaintThemeCustomImage(canvas, view,
|
|
|
|
browser_view_);
|
2023-08-09 23:17:17 +02:00
|
|
|
- if (!painted) {
|
|
|
|
+ if (!painted && browser_view_->frame()->GetFrameView()) {
|
|
|
|
SkColor frame_color =
|
|
|
|
browser_view_->frame()->GetFrameView()->GetFrameColor(
|
|
|
|
BrowserFrameActiveState::kUseCurrent);
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -220,12 +220,13 @@ END_METADATA
|
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-06-26 12:13:38 +02:00
|
|
|
container_view_ = AddChildView(std::make_unique<ContainerView>());
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -249,9 +250,24 @@ ToolbarView::~ToolbarView() {
|
2024-05-13 23:36:09 +02:00
|
|
|
|
|
|
|
for (const auto& view_and_command : GetViewCommandMap())
|
|
|
|
chrome::RemoveCommandObserver(browser_, view_and_command.second, this);
|
|
|
|
+
|
|
|
|
+ browser_view_->WillDestroyToolbar();
|
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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -274,12 +290,12 @@ void ToolbarView::Init() {
|
2023-06-26 12:13:38 +02:00
|
|
|
|
2023-04-26 21:55:59 +02:00
|
|
|
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;
|
2023-12-06 21:16:15 +01:00
|
|
|
- if (download::IsDownloadBubbleEnabled()) {
|
|
|
|
+ if (download::IsDownloadBubbleEnabled() && BUTTON_VISIBLE(kDownload)) {
|
2023-04-26 21:55:59 +02:00
|
|
|
download_button =
|
|
|
|
std::make_unique<DownloadToolbarButtonView>(browser_view_);
|
|
|
|
}
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -359,8 +375,10 @@ void ToolbarView::Init() {
|
|
|
|
toolbar_divider = std::make_unique<views::View>();
|
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)) {
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -370,7 +388,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_);
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -796,7 +815,8 @@ void ToolbarView::Layout(PassKey) {
|
|
|
|
|
2024-03-22 19:50:09 +01:00
|
|
|
if (display_mode_ == DisplayMode::NORMAL) {
|
|
|
|
LayoutCommon();
|
2024-06-14 19:01:45 +02:00
|
|
|
- UpdateClipPath();
|
|
|
|
+ if (!browser_->toolbar_overridden())
|
|
|
|
+ UpdateClipPath();
|
2024-03-22 19:50:09 +01:00
|
|
|
}
|
2024-06-14 19:01:45 +02:00
|
|
|
|
|
|
|
// Use two-pass solution to avoid the overflow button interfering with toolbar
|
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
|
2024-06-14 19:01:45 +02:00
|
|
|
index 78079d1c56460..0585cfd0de16b 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
|
2024-06-14 19:01:45 +02:00
|
|
|
@@ -92,7 +92,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;
|