From 64329268b839cac665337c1d3d6480a17d91e8e3 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 8 Jul 2013 17:00:42 +0800 Subject: [PATCH] [Win] Provide ClientView implementation. --- browser/native_window_win.cc | 30 +++++++++++++++++++++++++++++- browser/native_window_win.h | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/browser/native_window_win.cc b/browser/native_window_win.cc index f437b022..5f31ed12 100644 --- a/browser/native_window_win.cc +++ b/browser/native_window_win.cc @@ -10,9 +10,34 @@ #include "content/public/browser/native_web_keyboard_event.h" #include "ui/views/controls/webview/webview.h" #include "ui/views/widget/widget.h" +#include "ui/views/window/client_view.h" namespace atom { +namespace { + +class NativeWindowClientView : public views::ClientView { + public: + NativeWindowClientView(views::Widget* widget, + views::View* contents_view, + NativeWindowWin* shell) + : views::ClientView(widget, contents_view), + shell_(shell) { + } + virtual ~NativeWindowClientView() {} + + virtual bool CanClose() OVERRIDE { + shell_->CloseWebContents(); + return false; + } + + private: + NativeWindowWin* shell_; +}; + + +} // namespace + NativeWindowWin::NativeWindowWin(content::WebContents* web_contents, base::DictionaryValue* options) : NativeWindow(web_contents, options), @@ -32,7 +57,6 @@ NativeWindowWin::NativeWindowWin(content::WebContents* web_contents, window_->CenterWindow(size); web_view_->SetWebContents(web_contents); - window_->SetContentsView(web_view_); } NativeWindowWin::~NativeWindowWin() { @@ -216,6 +240,10 @@ const views::Widget* NativeWindowWin::GetWidget() const { return window_.get(); } +views::ClientView* NativeWindowWin::CreateClientView(views::Widget* widget) { + return new NativeWindowClientView(widget, web_view_, this); +} + // static NativeWindow* NativeWindow::Create(content::WebContents* web_contents, base::DictionaryValue* options) { diff --git a/browser/native_window_win.h b/browser/native_window_win.h index 68abaacd..22c6d35a 100644 --- a/browser/native_window_win.h +++ b/browser/native_window_win.h @@ -74,6 +74,7 @@ class NativeWindowWin : public NativeWindow, virtual bool ShouldShowWindowIcon() const OVERRIDE; virtual views::Widget* GetWidget() OVERRIDE; virtual const views::Widget* GetWidget() const OVERRIDE; + virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE; private: scoped_ptr window_; -- 2.43.0