From 62c44ee47b8cb2eae067760c068f026af9d40cd5 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 25 Jun 2015 13:27:51 +0800 Subject: [PATCH] Rename CloseWebContents to RequestToClosePage --- atom/browser/native_window.cc | 16 ++++++++-------- atom/browser/native_window.h | 8 +++----- atom/browser/native_window_mac.mm | 2 +- atom/browser/native_window_views.cc | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 01ed4746..a612ec61 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -315,7 +315,14 @@ void NativeWindow::CapturePage(const gfx::Rect& rect, kBGRA_8888_SkColorType); } -void NativeWindow::CloseWebContents() { +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, observers_, @@ -344,13 +351,6 @@ void NativeWindow::CloseWebContents() { web_contents->Close(); } -content::WebContents* NativeWindow::GetWebContents() const { - if (inspectable_web_contents_) - return inspectable_web_contents_->GetWebContents(); - else - return nullptr; -} - void NativeWindow::AppendExtraCommandLineSwitches( base::CommandLine* command_line) { // Append --node-integration to renderer process. diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index cc14d7b1..db546d71 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -163,17 +163,15 @@ class NativeWindow : public content::WebContentsObserver, virtual void SetMenuBarVisibility(bool visible); virtual bool IsMenuBarVisible(); - // The same with closing a tab in a real browser. - // - // Should be called by platform code when user want to close the window. - virtual void CloseWebContents(); - base::WeakPtr GetWeakPtr() { return weak_factory_.GetWeakPtr(); } content::WebContents* GetWebContents() const; + // Requests the WebContents to close, can be cancelled by the page. + virtual void RequestToClosePage(); + // Methods called by the WebContents. virtual void CloseContents(content::WebContents* source); virtual void RendererUnresponsive(content::WebContents* source); diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 5c17ee30..fc165665 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -149,7 +149,7 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; // When user tries to close the window by clicking the close button, we do // not close the window immediately, instead we try to close the web page // fisrt, and when the web page is closed the window will also be closed. - shell_->CloseWebContents(); + shell_->RequestToClosePage(); return NO; } diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index b4f51187..42802c92 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -133,7 +133,7 @@ class NativeWindowClientView : public views::ClientView { virtual ~NativeWindowClientView() {} bool CanClose() override { - static_cast(contents_view())->CloseWebContents(); + static_cast(contents_view())->RequestToClosePage(); return false; } -- 2.43.0