]> khamidou — GitHub mirrors - electron.git/commitdiff
[Win] Add custom frame view implementation for native window.
authorCheng Zhao <zcbenz@gmail.com>
Mon, 8 Jul 2013 09:24:54 +0000 (17:24 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 8 Jul 2013 09:24:54 +0000 (17:24 +0800)
browser/native_window_win.cc
browser/native_window_win.h

index ff42210013f0b09b964eb309893a56c088b6f53b..0a84afd4d731be3f72df6310d3b30772535c6010 100644 (file)
@@ -11,6 +11,7 @@
 #include "ui/views/controls/webview/webview.h"
 #include "ui/views/widget/widget.h"
 #include "ui/views/window/client_view.h"
+#include "ui/views/window/native_frame_view.h"
 
 namespace atom {
 
@@ -33,6 +34,30 @@ class NativeWindowClientView : public views::ClientView {
 
  private:
   NativeWindowWin* shell_;
+
+  DISALLOW_COPY_AND_ASSIGN(NativeWindowClientView);
+};
+
+class NativeWindowFrameView : public views::NativeFrameView {
+ public:
+  explicit NativeWindowFrameView(views::Widget* frame, NativeWindowWin* shell)
+      : NativeFrameView(frame),
+        shell_(shell) {
+  }
+  virtual ~NativeWindowFrameView() {}
+
+  virtual gfx::Size GetMinimumSize() OVERRIDE {
+    return shell_->GetMinimumSize();
+  }
+
+  virtual gfx::Size GetMaximumSize() OVERRIDE {
+    return shell_->GetMaximumSize();
+  }
+
+ private:
+  NativeWindowWin* shell_;
+
+  DISALLOW_COPY_AND_ASSIGN(NativeWindowFrameView);
 };
 
 
@@ -237,6 +262,11 @@ views::ClientView* NativeWindowWin::CreateClientView(views::Widget* widget) {
   return new NativeWindowClientView(widget, web_view_, this);
 }
 
+views::NonClientFrameView* NativeWindowWin::CreateNonClientFrameView(
+    views::Widget* widget) {
+  return new NativeWindowFrameView(widget, this);
+}
+
 // static
 NativeWindow* NativeWindow::Create(content::WebContents* web_contents,
                                    base::DictionaryValue* options) {
index 22c6d35adb4056c4847c367a6ce2031bcdf52d4f..3d09615e59fefd24c832a13ea2371b6076814c2a 100644 (file)
@@ -75,6 +75,8 @@ class NativeWindowWin : public NativeWindow,
   virtual views::Widget* GetWidget() OVERRIDE;
   virtual const views::Widget* GetWidget() const OVERRIDE;
   virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE;
+  virtual views::NonClientFrameView* CreateNonClientFrameView(
+      views::Widget* widget) OVERRIDE;
 
  private:
   scoped_ptr<views::Widget> window_;