Remove NativeWindow::GetWebContents
This commit is contained in:
parent
01dc0f973c
commit
9f52b11761
7 changed files with 25 additions and 44 deletions
|
@ -22,7 +22,7 @@ void MenuMac::Popup(Window* window) {
|
|||
NativeWindow* native_window = window->window();
|
||||
if (!native_window)
|
||||
return;
|
||||
content::WebContents* web_contents = native_window->GetWebContents();
|
||||
content::WebContents* web_contents = native_window->web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
|
@ -54,7 +54,7 @@ void MenuMac::PopupAt(Window* window, int x, int y) {
|
|||
NativeWindow* native_window = window->window();
|
||||
if (!native_window)
|
||||
return;
|
||||
content::WebContents* web_contents = native_window->GetWebContents();
|
||||
content::WebContents* web_contents = native_window->web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ void MenuViews::PopupAt(Window* window, int x, int y) {
|
|||
NativeWindow* native_window = static_cast<NativeWindow*>(window->window());
|
||||
if (!native_window)
|
||||
return;
|
||||
content::WebContents* web_contents = native_window->GetWebContents();
|
||||
content::WebContents* web_contents = native_window->web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
content::RenderWidgetHostView* view = web_contents->GetRenderWidgetHostView();
|
||||
|
|
|
@ -63,7 +63,7 @@ ProcessOwner GetProcessOwner(int process_id,
|
|||
|
||||
// First search for NativeWindow.
|
||||
for (auto native_window : *WindowList::GetInstance())
|
||||
if (web_contents == native_window->GetWebContents()) {
|
||||
if (web_contents == native_window->web_contents()) {
|
||||
*window = native_window;
|
||||
return OWNER_NATIVE_WINDOW;
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ NativeWindow* NativeWindow::FromWebContents(
|
|||
content::WebContents* web_contents) {
|
||||
WindowList& window_list = *WindowList::GetInstance();
|
||||
for (NativeWindow* window : window_list) {
|
||||
if (window->GetWebContents() == web_contents)
|
||||
if (window->web_contents() == web_contents)
|
||||
return window;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -268,24 +268,22 @@ bool NativeWindow::HasModalDialog() {
|
|||
}
|
||||
|
||||
void NativeWindow::FocusOnWebView() {
|
||||
GetWebContents()->GetRenderViewHost()->Focus();
|
||||
web_contents()->GetRenderViewHost()->Focus();
|
||||
}
|
||||
|
||||
void NativeWindow::BlurWebView() {
|
||||
GetWebContents()->GetRenderViewHost()->Blur();
|
||||
web_contents()->GetRenderViewHost()->Blur();
|
||||
}
|
||||
|
||||
bool NativeWindow::IsWebViewFocused() {
|
||||
RenderWidgetHostView* host_view =
|
||||
GetWebContents()->GetRenderViewHost()->GetView();
|
||||
auto host_view = web_contents()->GetRenderViewHost()->GetView();
|
||||
return host_view && host_view->HasFocus();
|
||||
}
|
||||
|
||||
void NativeWindow::CapturePage(const gfx::Rect& rect,
|
||||
const CapturePageCallback& callback) {
|
||||
content::WebContents* contents = GetWebContents();
|
||||
RenderWidgetHostView* const view = contents->GetRenderWidgetHostView();
|
||||
RenderWidgetHost* const host = view ? view->GetRenderWidgetHost() : nullptr;
|
||||
const auto view = web_contents()->GetRenderWidgetHostView();
|
||||
const auto host = view ? view->GetRenderWidgetHost() : nullptr;
|
||||
if (!view || !host) {
|
||||
callback.Run(SkBitmap());
|
||||
return;
|
||||
|
@ -315,13 +313,6 @@ void NativeWindow::CapturePage(const gfx::Rect& rect,
|
|||
kBGRA_8888_SkColorType);
|
||||
}
|
||||
|
||||
content::WebContents* NativeWindow::GetWebContents() const {
|
||||
if (inspectable_web_contents_)
|
||||
return inspectable_web_contents_->GetWebContents();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void NativeWindow::RequestToClosePage() {
|
||||
bool prevent_default = false;
|
||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||
|
@ -332,12 +323,6 @@ void NativeWindow::RequestToClosePage() {
|
|||
return;
|
||||
}
|
||||
|
||||
content::WebContents* web_contents(GetWebContents());
|
||||
if (!web_contents) {
|
||||
CloseImmediately();
|
||||
return;
|
||||
}
|
||||
|
||||
// Assume the window is not responding if it doesn't cancel the close and is
|
||||
// not closed in 5s, in this way we can quickly show the unresponsive
|
||||
// dialog when the window is busy executing some script withouth waiting for
|
||||
|
@ -345,10 +330,10 @@ void NativeWindow::RequestToClosePage() {
|
|||
if (window_unresposive_closure_.IsCancelled())
|
||||
ScheduleUnresponsiveEvent(5000);
|
||||
|
||||
if (web_contents->NeedToFireBeforeUnload())
|
||||
web_contents->DispatchBeforeUnload(false);
|
||||
if (web_contents()->NeedToFireBeforeUnload())
|
||||
web_contents()->DispatchBeforeUnload(false);
|
||||
else
|
||||
web_contents->Close();
|
||||
web_contents()->Close();
|
||||
}
|
||||
|
||||
void NativeWindow::CloseContents(content::WebContents* source) {
|
||||
|
@ -357,6 +342,7 @@ void NativeWindow::CloseContents(content::WebContents* source) {
|
|||
|
||||
inspectable_web_contents_->GetView()->SetDelegate(nullptr);
|
||||
inspectable_web_contents_ = nullptr;
|
||||
Observe(nullptr);
|
||||
|
||||
// When the web contents is gone, close the window immediately, but the
|
||||
// memory will not be freed until you call delete.
|
||||
|
|
|
@ -167,8 +167,6 @@ class NativeWindow : public content::WebContentsObserver,
|
|||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
content::WebContents* GetWebContents() const;
|
||||
|
||||
// Requests the WebContents to close, can be cancelled by the page.
|
||||
virtual void RequestToClosePage();
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
|
|||
}
|
||||
|
||||
- (void)windowDidBecomeMain:(NSNotification*)notification {
|
||||
content::WebContents* web_contents = shell_->GetWebContents();
|
||||
content::WebContents* web_contents = shell_->web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
|
@ -82,7 +82,7 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
|
|||
}
|
||||
|
||||
- (void)windowDidResignMain:(NSNotification*)notification {
|
||||
content::WebContents* web_contents = shell_->GetWebContents();
|
||||
content::WebContents* web_contents = shell_->web_contents();
|
||||
if (!web_contents)
|
||||
return;
|
||||
|
||||
|
@ -677,10 +677,9 @@ void NativeWindowMac::SetOverlayIcon(const gfx::Image& overlay,
|
|||
}
|
||||
|
||||
void NativeWindowMac::ShowDefinitionForSelection() {
|
||||
content::WebContents* web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
if (!web_contents())
|
||||
return;
|
||||
content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView();
|
||||
auto rwhv = web_contents()->GetRenderWidgetHostView();
|
||||
if (!rwhv)
|
||||
return;
|
||||
rwhv->ShowDefinitionForSelection();
|
||||
|
@ -704,10 +703,9 @@ bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
|||
bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const {
|
||||
if (!draggable_region_)
|
||||
return false;
|
||||
content::WebContents* web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
if (!web_contents())
|
||||
return false;
|
||||
NSView* webView = web_contents->GetNativeView();
|
||||
NSView* webView = web_contents()->GetNativeView();
|
||||
NSInteger webViewHeight = NSHeight([webView bounds]);
|
||||
// |draggable_region_| is stored in local platform-indepdent coordiate system
|
||||
// while |point| is in local Cocoa coordinate system. Do the conversion
|
||||
|
@ -814,16 +812,15 @@ void NativeWindowMac::UninstallView() {
|
|||
}
|
||||
|
||||
void NativeWindowMac::ClipWebView() {
|
||||
content::WebContents* web_contents = GetWebContents();
|
||||
if (!web_contents)
|
||||
if (!web_contents())
|
||||
return;
|
||||
NSView* webView = web_contents->GetNativeView();
|
||||
NSView* webView = web_contents()->GetNativeView();
|
||||
webView.layer.masksToBounds = YES;
|
||||
webView.layer.cornerRadius = kAtomWindowCornerRadius;
|
||||
}
|
||||
|
||||
void NativeWindowMac::InstallDraggableRegionView() {
|
||||
NSView* webView = GetWebContents()->GetNativeView();
|
||||
NSView* webView = web_contents()->GetNativeView();
|
||||
base::scoped_nsobject<NSView> controlRegion(
|
||||
[[ControlRegionView alloc] initWithShellWindow:this]);
|
||||
[controlRegion setFrame:NSMakeRect(0, 0,
|
||||
|
|
|
@ -728,9 +728,9 @@ void NativeWindowViews::OnWidgetActivationChanged(
|
|||
else
|
||||
NotifyWindowBlur();
|
||||
|
||||
if (active && GetWebContents() &&
|
||||
if (active && inspectable_web_contents() &&
|
||||
!inspectable_web_contents()->IsDevToolsViewShowing())
|
||||
GetWebContents()->Focus();
|
||||
web_contents()->Focus();
|
||||
|
||||
// Hide menu bar when window is blured.
|
||||
if (!active && menu_bar_autohide_ && menu_bar_visible_)
|
||||
|
|
Loading…
Reference in a new issue