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;
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;
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();
// 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;
}
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;
}
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;
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,
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
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) {
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.
return weak_factory_.GetWeakPtr();
}
- content::WebContents* GetWebContents() const;
-
// Requests the WebContents to close, can be cancelled by the page.
virtual void RequestToClosePage();
}
- (void)windowDidBecomeMain:(NSNotification*)notification {
- content::WebContents* web_contents = shell_->GetWebContents();
+ content::WebContents* web_contents = shell_->web_contents();
if (!web_contents)
return;
}
- (void)windowDidResignMain:(NSNotification*)notification {
- content::WebContents* web_contents = shell_->GetWebContents();
+ content::WebContents* web_contents = shell_->web_contents();
if (!web_contents)
return;
}
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();
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
}
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,
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_)