chore: Move draggable regions implementation from NativeBrowserView into InspectableWebContentsView (#35007)

* hore: Move draggable regions implementation from NativeBrowserView into InspectableWebContentsView

The draggable regions implementation is related to WebView, so
InspectableWebContentsView is a more appropriate place to put it there.
Also, this refactoring will allow the subsequent extension of the
WebContentsView API, which will eventually replace BrowserView API.

* fix: Lint error

* fix: Adjusted owner-window
This commit is contained in:
Daniel Kocielinski 2022-10-17 11:10:07 -04:00 committed by GitHub
parent f2c341b655
commit 23d4a252c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 397 additions and 360 deletions

View file

@ -18,6 +18,7 @@
#include "content/public/browser/web_contents_user_data.h"
#include "extensions/browser/app_window/size_constraints.h"
#include "shell/browser/native_window_observer.h"
#include "shell/browser/ui/inspectable_web_contents_view.h"
#include "shell/common/api/api.mojom.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "ui/views/widget/widget_delegate.h"
@ -50,6 +51,10 @@ namespace electron {
class ElectronMenuModel;
class NativeBrowserView;
namespace api {
class BrowserView;
}
#if BUILDFLAG(IS_MAC)
typedef NSView* NativeWindowHandle;
#else
@ -373,9 +378,15 @@ class NativeWindow : public base::SupportsUserData,
std::list<NativeBrowserView*> browser_views() const { return browser_views_; }
std::list<InspectableWebContentsView*> inspectable_views() const {
return inspectable_views_;
}
int32_t window_id() const { return next_id_; }
protected:
friend class api::BrowserView;
NativeWindow(const gin_helper::Dictionary& options, NativeWindow* parent);
// views::WidgetDelegate:
@ -393,6 +404,16 @@ class NativeWindow : public base::SupportsUserData,
[&browser_view](NativeBrowserView* n) { return (n == browser_view); });
}
void add_inspectable_view(InspectableWebContentsView* inspectable_view) {
inspectable_views_.push_back(inspectable_view);
}
void remove_inspectable_view(InspectableWebContentsView* inspectable_view) {
inspectable_views_.remove_if(
[&inspectable_view](InspectableWebContentsView* n) {
return (n == inspectable_view);
});
}
// The boolean parsing of the "titleBarOverlay" option
bool titlebar_overlay_ = false;
@ -456,6 +477,9 @@ class NativeWindow : public base::SupportsUserData,
// The browser view layer.
std::list<NativeBrowserView*> browser_views_;
// The inspectable webContents views.
std::list<InspectableWebContentsView*> inspectable_views_;
// Observers of this window.
base::ObserverList<NativeWindowObserver> observers_;