| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/views/constrained_window_views.h" | 5 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 6 | 6 |
| 7 #include "views/window/window_win.h" | 7 #include "views/window/window_win.h" |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 bool IsNonClientHitTestCode(UINT hittest) { | 10 bool IsNonClientHitTestCode(UINT hittest) { |
| 11 return hittest != HTCLIENT && hittest != HTNOWHERE && hittest != HTCLOSE; | 11 return hittest != HTCLIENT && hittest != HTNOWHERE && hittest != HTCLOSE; |
| 12 } | 12 } |
| 13 } | 13 } |
| 14 | 14 |
| 15 class NativeConstrainedWindowWin : public NativeConstrainedWindow, | 15 class NativeConstrainedWindowWin : public NativeConstrainedWindow, |
| 16 public views::WindowWin { | 16 public views::WindowWin { |
| 17 public: | 17 public: |
| 18 explicit NativeConstrainedWindowWin(NativeConstrainedWindowDelegate* delegate) | 18 explicit NativeConstrainedWindowWin(NativeConstrainedWindowDelegate* delegate) |
| 19 : delegate_(delegate) { | 19 : views::WindowWin(delegate->AsNativeWindowDelegate()), |
| 20 delegate_(delegate) { |
| 20 } | 21 } |
| 21 | 22 |
| 22 virtual ~NativeConstrainedWindowWin() { | 23 virtual ~NativeConstrainedWindowWin() { |
| 23 } | 24 } |
| 24 | 25 |
| 25 private: | 26 private: |
| 26 // Overridden from NativeConstrainedWindow: | 27 // Overridden from NativeConstrainedWindow: |
| 27 virtual views::NativeWindow* AsNativeWindow() OVERRIDE { | 28 virtual views::NativeWindow* AsNativeWindow() OVERRIDE { |
| 28 return this; | 29 return this; |
| 29 } | 30 } |
| 30 | 31 |
| 31 // Overridden from views::WindowWin: | 32 // Overridden from views::WindowWin: |
| 32 virtual void OnFinalMessage(HWND window) OVERRIDE { | 33 virtual void OnFinalMessage(HWND window) OVERRIDE { |
| 33 delegate_->OnNativeConstrainedWindowDestroyed(); | 34 delegate_->OnNativeConstrainedWindowDestroyed(); |
| 34 WindowWin::OnFinalMessage(window); | 35 WindowWin::OnFinalMessage(window); |
| 35 } | 36 } |
| 36 virtual LRESULT OnMouseActivate(UINT message, | 37 virtual LRESULT OnMouseActivate(UINT message, |
| 37 WPARAM w_param, | 38 WPARAM w_param, |
| 38 LPARAM l_param) OVERRIDE { | 39 LPARAM l_param) OVERRIDE { |
| 39 if (IsNonClientHitTestCode(static_cast<UINT>(LOWORD(l_param)))) | 40 if (IsNonClientHitTestCode(static_cast<UINT>(LOWORD(l_param)))) |
| 40 delegate_->OnNativeConstrainedWindowMouseActivate(); | 41 delegate_->OnNativeConstrainedWindowMouseActivate(); |
| 41 return WindowWin::OnMouseActivate(message, w_param, l_param); | 42 return WindowWin::OnMouseActivate(message, w_param, l_param); |
| 42 } | 43 } |
| 43 | 44 |
| 44 // Overridden from views::Window: | |
| 45 virtual views::NonClientFrameView* CreateFrameViewForWindow() OVERRIDE { | |
| 46 return delegate_->CreateFrameViewForWindow(); | |
| 47 } | |
| 48 | |
| 49 NativeConstrainedWindowDelegate* delegate_; | 45 NativeConstrainedWindowDelegate* delegate_; |
| 50 | 46 |
| 51 DISALLOW_COPY_AND_ASSIGN(NativeConstrainedWindowWin); | 47 DISALLOW_COPY_AND_ASSIGN(NativeConstrainedWindowWin); |
| 52 }; | 48 }; |
| 53 | 49 |
| 54 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
| 55 // NativeConstrainedWindow, public: | 51 // NativeConstrainedWindow, public: |
| 56 | 52 |
| 57 // static | 53 // static |
| 58 NativeConstrainedWindow* NativeConstrainedWindow::CreateNativeConstrainedWindow( | 54 NativeConstrainedWindow* NativeConstrainedWindow::CreateNativeConstrainedWindow( |
| 59 NativeConstrainedWindowDelegate* delegate) { | 55 NativeConstrainedWindowDelegate* delegate) { |
| 60 return new NativeConstrainedWindowWin(delegate); | 56 return new NativeConstrainedWindowWin(delegate); |
| 61 } | 57 } |
| OLD | NEW |