[Win] Provide ClientView implementation.

This commit is contained in:
Cheng Zhao 2013-07-08 17:00:42 +08:00
parent 6a48faebe3
commit 64329268b8
2 changed files with 30 additions and 1 deletions

View file

@ -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) {

View file

@ -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<views::Widget> window_;