mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
chrome: Support frameless document PiP window with draggable regions (fixes #3566)
This commit is contained in:
@@ -70,7 +70,7 @@ index cc4fbda7ddfa8..c7278ef3d7ff7 100644
|
||||
]
|
||||
}
|
||||
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
|
||||
index 501783a57a06e..5a90cf466eed1 100644
|
||||
index 501783a57a06e..3c0dd26c58465 100644
|
||||
--- chrome/browser/ui/browser.cc
|
||||
+++ chrome/browser/ui/browser.cc
|
||||
@@ -263,6 +263,25 @@
|
||||
@@ -99,21 +99,18 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
#include "chrome/browser/extensions/extension_browser_window_helper.h"
|
||||
#endif
|
||||
@@ -505,6 +524,13 @@ Browser::Browser(const CreateParams& params)
|
||||
|
||||
tab_strip_model_->AddObserver(this);
|
||||
|
||||
@@ -454,6 +473,10 @@ Browser::Browser(const CreateParams& params)
|
||||
type_(params.type),
|
||||
profile_(params.profile),
|
||||
window_(nullptr),
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ if (cef::IsChromeRuntimeEnabled()) {
|
||||
+ cef_browser_delegate_ =
|
||||
+ cef::BrowserDelegate::Create(this, params.cef_params);
|
||||
+ }
|
||||
+ cef_browser_delegate_(
|
||||
+ cef::BrowserDelegate::Create(this, params.cef_params, params.opener)),
|
||||
+#endif
|
||||
+
|
||||
location_bar_model_ = std::make_unique<LocationBarModelImpl>(
|
||||
location_bar_model_delegate_.get(), content::kMaxURLDisplayChars);
|
||||
|
||||
@@ -645,6 +671,12 @@ Browser::~Browser() {
|
||||
tab_strip_model_delegate_(
|
||||
std::make_unique<chrome::BrowserTabStripModelDelegate>(this)),
|
||||
tab_strip_model_(std::make_unique<TabStripModel>(
|
||||
@@ -645,6 +668,12 @@ Browser::~Browser() {
|
||||
// away so they don't try and call back to us.
|
||||
if (select_file_dialog_.get())
|
||||
select_file_dialog_->ListenerDestroyed();
|
||||
@@ -126,7 +123,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1380,6 +1412,14 @@ content::KeyboardEventProcessingResult Browser::PreHandleKeyboardEvent(
|
||||
@@ -1380,6 +1409,14 @@ content::KeyboardEventProcessingResult Browser::PreHandleKeyboardEvent(
|
||||
if (exclusive_access_manager_->HandleUserKeyEvent(event))
|
||||
return content::KeyboardEventProcessingResult::HANDLED;
|
||||
|
||||
@@ -141,7 +138,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
return window()->PreHandleKeyboardEvent(event);
|
||||
}
|
||||
|
||||
@@ -1387,8 +1427,18 @@ bool Browser::HandleKeyboardEvent(content::WebContents* source,
|
||||
@@ -1387,8 +1424,18 @@ bool Browser::HandleKeyboardEvent(content::WebContents* source,
|
||||
const NativeWebKeyboardEvent& event) {
|
||||
DevToolsWindow* devtools_window =
|
||||
DevToolsWindow::GetInstanceForInspectedWebContents(source);
|
||||
@@ -162,7 +159,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
}
|
||||
|
||||
bool Browser::TabsNeedBeforeUnloadFired() {
|
||||
@@ -1592,6 +1642,14 @@ WebContents* Browser::OpenURLFromTab(WebContents* source,
|
||||
@@ -1592,6 +1639,14 @@ WebContents* Browser::OpenURLFromTab(WebContents* source,
|
||||
return window->OpenURLFromTab(source, params);
|
||||
}
|
||||
|
||||
@@ -177,7 +174,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
NavigateParams nav_params(this, params.url, params.transition);
|
||||
nav_params.FillNavigateParamsFromOpenURLParams(params);
|
||||
nav_params.source_contents = source;
|
||||
@@ -1749,6 +1807,8 @@ void Browser::LoadingStateChanged(WebContents* source,
|
||||
@@ -1749,6 +1804,8 @@ void Browser::LoadingStateChanged(WebContents* source,
|
||||
bool should_show_loading_ui) {
|
||||
ScheduleUIUpdate(source, content::INVALIDATE_TYPE_LOAD);
|
||||
UpdateWindowForLoadingStateChanged(source, should_show_loading_ui);
|
||||
@@ -186,7 +183,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
}
|
||||
|
||||
void Browser::CloseContents(WebContents* source) {
|
||||
@@ -1777,6 +1837,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
||||
@@ -1777,6 +1834,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
||||
}
|
||||
|
||||
void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||
@@ -195,7 +192,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
if (!GetStatusBubble())
|
||||
return;
|
||||
|
||||
@@ -1784,6 +1846,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||
@@ -1784,6 +1843,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||
GetStatusBubble()->SetURL(url);
|
||||
}
|
||||
|
||||
@@ -213,7 +210,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
void Browser::ContentsMouseEvent(WebContents* source,
|
||||
bool motion,
|
||||
bool exited) {
|
||||
@@ -1808,6 +1881,19 @@ bool Browser::TakeFocus(content::WebContents* source, bool reverse) {
|
||||
@@ -1808,6 +1878,19 @@ bool Browser::TakeFocus(content::WebContents* source, bool reverse) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -233,7 +230,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
void Browser::BeforeUnloadFired(WebContents* web_contents,
|
||||
bool proceed,
|
||||
bool* proceed_to_fire_unload) {
|
||||
@@ -1900,6 +1986,10 @@ void Browser::WebContentsCreated(WebContents* source_contents,
|
||||
@@ -1900,6 +1983,10 @@ void Browser::WebContentsCreated(WebContents* source_contents,
|
||||
|
||||
// Make the tab show up in the task manager.
|
||||
task_manager::WebContentsTags::CreateForTabContents(new_contents);
|
||||
@@ -244,7 +241,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
}
|
||||
|
||||
void Browser::PortalWebContentsCreated(WebContents* portal_web_contents) {
|
||||
@@ -2017,11 +2107,15 @@ void Browser::EnterFullscreenModeForTab(
|
||||
@@ -2017,11 +2104,15 @@ void Browser::EnterFullscreenModeForTab(
|
||||
const blink::mojom::FullscreenOptions& options) {
|
||||
exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab(
|
||||
requesting_frame, options.display_id);
|
||||
@@ -260,7 +257,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
}
|
||||
|
||||
bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) {
|
||||
@@ -2211,6 +2305,15 @@ void Browser::RequestMediaAccessPermission(
|
||||
@@ -2211,6 +2302,15 @@ void Browser::RequestMediaAccessPermission(
|
||||
content::WebContents* web_contents,
|
||||
const content::MediaStreamRequest& request,
|
||||
content::MediaResponseCallback callback) {
|
||||
@@ -276,7 +273,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
const extensions::Extension* extension =
|
||||
GetExtensionForOrigin(profile_, request.security_origin);
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
|
||||
@@ -2762,13 +2865,20 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) {
|
||||
@@ -2762,13 +2862,20 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) {
|
||||
// Browser, Getters for UI (private):
|
||||
|
||||
StatusBubble* Browser::GetStatusBubble() {
|
||||
@@ -298,7 +295,7 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
return window_ ? window_->GetStatusBubble() : nullptr;
|
||||
}
|
||||
|
||||
@@ -2902,6 +3012,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
|
||||
@@ -2902,6 +3009,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
|
||||
BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this);
|
||||
web_contents_collection_.StopObserving(web_contents);
|
||||
}
|
||||
@@ -307,8 +304,23 @@ index 501783a57a06e..5a90cf466eed1 100644
|
||||
}
|
||||
|
||||
void Browser::TabDetachedAtImpl(content::WebContents* contents,
|
||||
@@ -3056,6 +3165,14 @@ bool Browser::PictureInPictureBrowserSupportsWindowFeature(
|
||||
|
||||
bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,
|
||||
bool check_can_support) const {
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ if (cef_delegate()) {
|
||||
+ if (auto value = cef_delegate()->SupportsWindowFeature(feature)) {
|
||||
+ return *value;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
switch (type_) {
|
||||
case TYPE_NORMAL:
|
||||
return NormalBrowserSupportsWindowFeature(feature, check_can_support);
|
||||
diff --git chrome/browser/ui/browser.h chrome/browser/ui/browser.h
|
||||
index 9fceed57deff5..bc0058f0b1db2 100644
|
||||
index 9fceed57deff5..a1a962cf014fa 100644
|
||||
--- chrome/browser/ui/browser.h
|
||||
+++ chrome/browser/ui/browser.h
|
||||
@@ -22,6 +22,7 @@
|
||||
@@ -330,19 +342,23 @@ index 9fceed57deff5..bc0058f0b1db2 100644
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
#error This file should only be included on desktop.
|
||||
#endif
|
||||
@@ -322,6 +327,11 @@ class Browser : public TabStripModelObserver,
|
||||
@@ -322,6 +327,15 @@ class Browser : public TabStripModelObserver,
|
||||
// Document Picture in Picture options, specific to TYPE_PICTURE_IN_PICTURE.
|
||||
absl::optional<blink::mojom::PictureInPictureWindowOptions> pip_options;
|
||||
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ // Opaque CEF-specific configuration. Will be propagated to new Browsers.
|
||||
+ scoped_refptr<cef::BrowserDelegate::CreateParams> cef_params;
|
||||
+
|
||||
+ // Specify the Browser that is opening this popup.
|
||||
+ // Currently only used with TYPE_PICTURE_IN_PICTURE.
|
||||
+ raw_ptr<Browser, DanglingUntriaged> opener = nullptr;
|
||||
+#endif
|
||||
+
|
||||
private:
|
||||
friend class Browser;
|
||||
friend class WindowSizerChromeOSTest;
|
||||
@@ -403,6 +413,13 @@ class Browser : public TabStripModelObserver,
|
||||
@@ -403,6 +417,13 @@ class Browser : public TabStripModelObserver,
|
||||
update_ui_immediately_for_testing_ = true;
|
||||
}
|
||||
|
||||
@@ -356,7 +372,7 @@ index 9fceed57deff5..bc0058f0b1db2 100644
|
||||
// Accessors ////////////////////////////////////////////////////////////////
|
||||
|
||||
const CreateParams& create_params() const { return create_params_; }
|
||||
@@ -476,6 +493,12 @@ class Browser : public TabStripModelObserver,
|
||||
@@ -476,6 +497,12 @@ class Browser : public TabStripModelObserver,
|
||||
|
||||
base::WeakPtr<Browser> AsWeakPtr();
|
||||
|
||||
@@ -369,7 +385,7 @@ index 9fceed57deff5..bc0058f0b1db2 100644
|
||||
// Get the FindBarController for this browser, creating it if it does not
|
||||
// yet exist.
|
||||
FindBarController* GetFindBarController();
|
||||
@@ -869,11 +892,19 @@ class Browser : public TabStripModelObserver,
|
||||
@@ -869,11 +896,19 @@ class Browser : public TabStripModelObserver,
|
||||
void SetContentsBounds(content::WebContents* source,
|
||||
const gfx::Rect& bounds) override;
|
||||
void UpdateTargetURL(content::WebContents* source, const GURL& url) override;
|
||||
@@ -389,7 +405,18 @@ index 9fceed57deff5..bc0058f0b1db2 100644
|
||||
void BeforeUnloadFired(content::WebContents* source,
|
||||
bool proceed,
|
||||
bool* proceed_to_fire_unload) override;
|
||||
@@ -1281,6 +1312,8 @@ class Browser : public TabStripModelObserver,
|
||||
@@ -1212,6 +1247,10 @@ class Browser : public TabStripModelObserver,
|
||||
// This Browser's window.
|
||||
raw_ptr<BrowserWindow, DanglingUntriaged> window_;
|
||||
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ std::unique_ptr<cef::BrowserDelegate> cef_browser_delegate_;
|
||||
+#endif
|
||||
+
|
||||
std::unique_ptr<TabStripModelDelegate> const tab_strip_model_delegate_;
|
||||
std::unique_ptr<TabStripModel> const tab_strip_model_;
|
||||
|
||||
@@ -1281,6 +1320,8 @@ class Browser : public TabStripModelObserver,
|
||||
const std::string initial_workspace_;
|
||||
bool initial_visible_on_all_workspaces_state_;
|
||||
|
||||
@@ -398,22 +425,22 @@ index 9fceed57deff5..bc0058f0b1db2 100644
|
||||
CreationSource creation_source_ = CreationSource::kUnknown;
|
||||
|
||||
UnloadController unload_controller_;
|
||||
@@ -1348,6 +1381,10 @@ class Browser : public TabStripModelObserver,
|
||||
extension_browser_window_helper_;
|
||||
#endif
|
||||
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ std::unique_ptr<cef::BrowserDelegate> cef_browser_delegate_;
|
||||
+#endif
|
||||
+
|
||||
const base::ElapsedTimer creation_timer_;
|
||||
|
||||
// The opener browser of the document picture-in-picture browser. Null if the
|
||||
diff --git chrome/browser/ui/browser_navigator.cc chrome/browser/ui/browser_navigator.cc
|
||||
index 88edd87bcb2d0..26f9d74bd4ed9 100644
|
||||
index 88edd87bcb2d0..03fc4f4ccd95f 100644
|
||||
--- chrome/browser/ui/browser_navigator.cc
|
||||
+++ chrome/browser/ui/browser_navigator.cc
|
||||
@@ -556,6 +556,13 @@ std::unique_ptr<content::WebContents> CreateTargetContents(
|
||||
@@ -293,6 +293,10 @@ std::pair<Browser*, int> GetBrowserAndTabForDisposition(
|
||||
: 1.0;
|
||||
browser_params.pip_options = pip_options;
|
||||
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ browser_params.opener = params.browser;
|
||||
+#endif
|
||||
+
|
||||
const BrowserWindow* const browser_window = params.browser->window();
|
||||
const gfx::NativeWindow native_window =
|
||||
browser_window ? browser_window->GetNativeWindow()
|
||||
@@ -556,6 +560,13 @@ std::unique_ptr<content::WebContents> CreateTargetContents(
|
||||
std::unique_ptr<WebContents> target_contents =
|
||||
WebContents::Create(create_params);
|
||||
|
||||
|
@@ -355,7 +355,7 @@ index 77ca1dbf118f9..c60711991d093 100644
|
||||
BrowserFrame(const BrowserFrame&) = delete;
|
||||
BrowserFrame& operator=(const BrowserFrame&) = delete;
|
||||
diff --git chrome/browser/ui/views/frame/browser_view.cc chrome/browser/ui/views/frame/browser_view.cc
|
||||
index 261dfb8562dbd..650a2847fb6c8 100644
|
||||
index 261dfb8562dbd..64bb1900483c8 100644
|
||||
--- chrome/browser/ui/views/frame/browser_view.cc
|
||||
+++ chrome/browser/ui/views/frame/browser_view.cc
|
||||
@@ -336,11 +336,10 @@ using content::NativeWebKeyboardEvent;
|
||||
@@ -411,7 +411,7 @@ index 261dfb8562dbd..650a2847fb6c8 100644
|
||||
|
||||
- toolbar_ = top_container_->AddChildView(
|
||||
- std::make_unique<ToolbarView>(browser_.get(), this));
|
||||
+ toolbar_ = OverrideCreateToolbar(browser_.get(), this);
|
||||
+ toolbar_ = OverrideCreateToolbar();
|
||||
+ if (!toolbar_) {
|
||||
+ toolbar_ = new ToolbarView(browser_.get(), this, absl::nullopt);
|
||||
+ } else {
|
||||
@@ -469,7 +469,57 @@ index 261dfb8562dbd..650a2847fb6c8 100644
|
||||
top_container()->DestroyLayer();
|
||||
AddChildViewAt(top_container(), 0);
|
||||
EnsureFocusOrder();
|
||||
@@ -3994,8 +4016,10 @@ void BrowserView::Layout() {
|
||||
@@ -3873,11 +3895,38 @@ void BrowserView::GetAccessiblePanes(std::vector<views::View*>* panes) {
|
||||
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(),
|
||||
@@ -3886,7 +3935,7 @@ bool BrowserView::ShouldDescendIntoChildForEventHandling(
|
||||
|
||||
// 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);
|
||||
@@ -3994,8 +4043,10 @@ void BrowserView::Layout() {
|
||||
|
||||
// TODO(jamescook): Why was this in the middle of layout code?
|
||||
toolbar_->location_bar()->omnibox_view()->SetFocusBehavior(
|
||||
@@ -482,7 +532,7 @@ index 261dfb8562dbd..650a2847fb6c8 100644
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// In chromeOS ash we round the bottom two corners of the browser frame by
|
||||
@@ -4073,6 +4097,11 @@ void BrowserView::AddedToWidget() {
|
||||
@@ -4073,6 +4124,11 @@ void BrowserView::AddedToWidget() {
|
||||
SetThemeProfileForWindow(GetNativeWindow(), browser_->profile());
|
||||
#endif
|
||||
|
||||
@@ -494,7 +544,7 @@ index 261dfb8562dbd..650a2847fb6c8 100644
|
||||
toolbar_->Init();
|
||||
|
||||
// TODO(pbos): Investigate whether the side panels should be creatable when
|
||||
@@ -4120,13 +4149,9 @@ void BrowserView::AddedToWidget() {
|
||||
@@ -4120,13 +4176,9 @@ void BrowserView::AddedToWidget() {
|
||||
|
||||
EnsureFocusOrder();
|
||||
|
||||
@@ -510,7 +560,7 @@ index 261dfb8562dbd..650a2847fb6c8 100644
|
||||
using_native_frame_ = frame_->ShouldUseNativeFrame();
|
||||
|
||||
MaybeInitializeWebUITabStrip();
|
||||
@@ -4544,7 +4569,8 @@ void BrowserView::ProcessFullscreen(bool fullscreen,
|
||||
@@ -4544,7 +4596,8 @@ void BrowserView::ProcessFullscreen(bool fullscreen,
|
||||
// Undo our anti-jankiness hacks and force a re-layout.
|
||||
in_process_fullscreen_ = false;
|
||||
ToolbarSizeChanged(false);
|
||||
@@ -520,7 +570,7 @@ index 261dfb8562dbd..650a2847fb6c8 100644
|
||||
}
|
||||
|
||||
bool BrowserView::ShouldUseImmersiveFullscreenForUrl(const GURL& url) const {
|
||||
@@ -4915,6 +4941,8 @@ Profile* BrowserView::GetProfile() {
|
||||
@@ -4915,6 +4968,8 @@ Profile* BrowserView::GetProfile() {
|
||||
}
|
||||
|
||||
void BrowserView::UpdateUIForTabFullscreen() {
|
||||
@@ -529,7 +579,7 @@ index 261dfb8562dbd..650a2847fb6c8 100644
|
||||
frame()->GetFrameView()->UpdateFullscreenTopUI();
|
||||
}
|
||||
|
||||
@@ -4937,6 +4965,8 @@ void BrowserView::HideDownloadShelf() {
|
||||
@@ -4937,6 +4992,8 @@ void BrowserView::HideDownloadShelf() {
|
||||
}
|
||||
|
||||
bool BrowserView::CanUserExitFullscreen() const {
|
||||
@@ -539,7 +589,7 @@ index 261dfb8562dbd..650a2847fb6c8 100644
|
||||
}
|
||||
|
||||
diff --git chrome/browser/ui/views/frame/browser_view.h chrome/browser/ui/views/frame/browser_view.h
|
||||
index 58f128d2217a0..c8dd2a4a5a940 100644
|
||||
index 58f128d2217a0..2d5115f2a568e 100644
|
||||
--- chrome/browser/ui/views/frame/browser_view.h
|
||||
+++ chrome/browser/ui/views/frame/browser_view.h
|
||||
@@ -136,11 +136,16 @@ class BrowserView : public BrowserWindow,
|
||||
@@ -559,15 +609,12 @@ index 58f128d2217a0..c8dd2a4a5a940 100644
|
||||
void set_frame(BrowserFrame* frame) {
|
||||
frame_ = frame;
|
||||
paint_as_active_subscription_ =
|
||||
@@ -810,6 +815,12 @@ class BrowserView : public BrowserWindow,
|
||||
@@ -810,6 +815,9 @@ class BrowserView : public BrowserWindow,
|
||||
return web_app_frame_toolbar();
|
||||
}
|
||||
|
||||
+ protected:
|
||||
+ virtual ToolbarView* OverrideCreateToolbar(Browser* browser,
|
||||
+ BrowserView* browser_view) {
|
||||
+ return nullptr;
|
||||
+ }
|
||||
+ virtual ToolbarView* OverrideCreateToolbar() { return nullptr; }
|
||||
+
|
||||
private:
|
||||
// Do not friend BrowserViewLayout. Use the BrowserViewLayoutDelegate
|
||||
@@ -617,6 +664,100 @@ index 8267a265a8e10..ee08f18e96a34 100644
|
||||
}
|
||||
|
||||
ContentsWebView::~ContentsWebView() {
|
||||
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
|
||||
index deb2cbe415610..b19dba22d8cc2 100644
|
||||
--- chrome/browser/ui/views/frame/picture_in_picture_browser_frame_view.cc
|
||||
+++ chrome/browser/ui/views/frame/picture_in_picture_browser_frame_view.cc
|
||||
@@ -404,6 +404,11 @@ PictureInPictureBrowserFrameView::PictureInPictureBrowserFrameView(
|
||||
frame->GetNativeWindow()->SetEventTargeter(
|
||||
std::make_unique<chromeos::InteriorResizeHandleTargeter>());
|
||||
#endif
|
||||
+
|
||||
+ if (!browser_view->browser()->SupportsWindowFeature(
|
||||
+ Browser::FEATURE_TITLEBAR)) {
|
||||
+ top_bar_container_view_->SetVisible(false);
|
||||
+ }
|
||||
}
|
||||
|
||||
PictureInPictureBrowserFrameView::~PictureInPictureBrowserFrameView() {
|
||||
@@ -503,17 +508,20 @@ gfx::Rect PictureInPictureBrowserFrameView::GetWindowBoundsForClientBounds(
|
||||
|
||||
int PictureInPictureBrowserFrameView::NonClientHitTest(
|
||||
const gfx::Point& point) {
|
||||
- // Allow interacting with the buttons.
|
||||
- if (GetLocationIconViewBounds().Contains(point) ||
|
||||
- GetBackToTabControlsBounds().Contains(point) ||
|
||||
- GetCloseControlsBounds().Contains(point)) {
|
||||
- return HTCLIENT;
|
||||
- }
|
||||
-
|
||||
- for (size_t i = 0; i < content_setting_views_.size(); i++) {
|
||||
- if (GetContentSettingViewBounds(i).Contains(point)) {
|
||||
+ 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)) {
|
||||
return HTCLIENT;
|
||||
}
|
||||
+
|
||||
+ for (size_t i = 0; i < content_setting_views_.size(); i++) {
|
||||
+ if (GetContentSettingViewBounds(i).Contains(point)) {
|
||||
+ return HTCLIENT;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
|
||||
// Allow dragging and resizing the window.
|
||||
@@ -523,6 +531,27 @@ int PictureInPictureBrowserFrameView::NonClientHitTest(
|
||||
if (window_component != HTNOWHERE)
|
||||
return window_component;
|
||||
|
||||
+#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;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+#endif // BUILDFLAG(ENABLE_CEF)
|
||||
+
|
||||
// Allow interacting with the web contents.
|
||||
int frame_component = frame()->client_view()->NonClientHitTest(point);
|
||||
if (frame_component != HTNOWHERE)
|
||||
@@ -581,7 +610,8 @@ void PictureInPictureBrowserFrameView::Layout() {
|
||||
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_) {
|
||||
@@ -982,7 +1012,8 @@ gfx::Insets PictureInPictureBrowserFrameView::ResizeBorderInsets() const {
|
||||
}
|
||||
|
||||
int PictureInPictureBrowserFrameView::GetTopAreaHeight() const {
|
||||
- return FrameBorderInsets().top() + kTopControlsHeight;
|
||||
+ return FrameBorderInsets().top() +
|
||||
+ (top_bar_container_view_->GetVisible() ? kTopControlsHeight : 0);
|
||||
}
|
||||
|
||||
gfx::Size PictureInPictureBrowserFrameView::GetNonClientViewAreaSize() const {
|
||||
diff --git chrome/browser/ui/views/page_action/page_action_icon_controller.cc chrome/browser/ui/views/page_action/page_action_icon_controller.cc
|
||||
index 723a2840bd988..975152c988917 100644
|
||||
--- chrome/browser/ui/views/page_action/page_action_icon_controller.cc
|
||||
@@ -790,3 +931,64 @@ index be3bd96444563..96669547e3ccf 100644
|
||||
ToolbarView(const ToolbarView&) = delete;
|
||||
ToolbarView& operator=(const ToolbarView&) = delete;
|
||||
~ToolbarView() override;
|
||||
diff --git chrome/browser/ui/web_applications/draggable_region_host_impl.cc chrome/browser/ui/web_applications/draggable_region_host_impl.cc
|
||||
index 460a2b08f964b..cb1b67d8b1213 100644
|
||||
--- chrome/browser/ui/web_applications/draggable_region_host_impl.cc
|
||||
+++ chrome/browser/ui/web_applications/draggable_region_host_impl.cc
|
||||
@@ -11,6 +11,24 @@
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||
|
||||
+namespace {
|
||||
+
|
||||
+bool IsSupported(Browser* browser) {
|
||||
+ if (web_app::AppBrowserController::IsWebApp(browser))
|
||||
+ return true;
|
||||
+
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ if (browser->cef_delegate() &&
|
||||
+ browser->cef_delegate()->SupportsDraggableRegion()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+} // namespace
|
||||
+
|
||||
DraggableRegionsHostImpl::DraggableRegionsHostImpl(
|
||||
content::RenderFrameHost& render_frame_host,
|
||||
mojo::PendingReceiver<chrome::mojom::DraggableRegions> receiver)
|
||||
@@ -28,7 +46,7 @@ void DraggableRegionsHostImpl::CreateIfAllowed(
|
||||
auto* browser = chrome::FindBrowserWithWebContents(web_contents);
|
||||
|
||||
// We only want to bind the receiver for PWAs.
|
||||
- if (!web_app::AppBrowserController::IsWebApp(browser))
|
||||
+ if (!IsSupported(browser))
|
||||
return;
|
||||
|
||||
// The object is bound to the lifetime of |render_frame_host| and the mojo
|
||||
@@ -43,7 +61,7 @@ void DraggableRegionsHostImpl::UpdateDraggableRegions(
|
||||
auto* browser = chrome::FindBrowserWithWebContents(web_contents);
|
||||
// When a WebApp browser's WebContents is reparented to a tabbed browser, a
|
||||
// draggable regions update may race with the reparenting logic.
|
||||
- if (!web_app::AppBrowserController::IsWebApp(browser))
|
||||
+ if (!IsSupported(browser))
|
||||
return;
|
||||
|
||||
SkRegion sk_region;
|
||||
@@ -56,5 +74,12 @@ void DraggableRegionsHostImpl::UpdateDraggableRegions(
|
||||
}
|
||||
|
||||
auto* app_browser_controller = browser->app_controller();
|
||||
- app_browser_controller->UpdateDraggableRegion(sk_region);
|
||||
+ if (app_browser_controller) {
|
||||
+ app_browser_controller->UpdateDraggableRegion(sk_region);
|
||||
+ }
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ else {
|
||||
+ browser->cef_delegate()->UpdateDraggableRegion(sk_region);
|
||||
+ }
|
||||
+#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user