OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" | 11 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" |
| 12 #include "ui/views/context_menu_controller.h" |
12 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
13 | 14 |
14 class AvatarMenuButton; | 15 class AvatarMenuButton; |
15 class BrowserRootView; | 16 class BrowserRootView; |
16 class BrowserView; | 17 class BrowserView; |
17 class NativeBrowserFrame; | 18 class NativeBrowserFrame; |
18 class NonClientFrameView; | 19 class NonClientFrameView; |
| 20 class SystemMenuModelBuilder; |
19 | 21 |
20 namespace gfx { | 22 namespace gfx { |
21 class Font; | 23 class Font; |
22 class Rect; | 24 class Rect; |
23 } | 25 } |
24 | 26 |
25 namespace ui { | 27 namespace ui { |
| 28 class MenuModel; |
26 class ThemeProvider; | 29 class ThemeProvider; |
27 } | 30 } |
28 | 31 |
29 namespace views { | 32 namespace views { |
| 33 class MenuRunner; |
30 class View; | 34 class View; |
31 } | 35 } |
32 | 36 |
33 // This is a virtual interface that allows system specific browser frames. | 37 // This is a virtual interface that allows system specific browser frames. |
34 class BrowserFrame : public views::Widget { | 38 class BrowserFrame |
| 39 : public views::Widget, |
| 40 public views::ContextMenuController { |
35 public: | 41 public: |
36 explicit BrowserFrame(BrowserView* browser_view); | 42 explicit BrowserFrame(BrowserView* browser_view); |
37 virtual ~BrowserFrame(); | 43 virtual ~BrowserFrame(); |
38 | 44 |
39 static const gfx::Font& GetTitleFont(); | 45 static const gfx::Font& GetTitleFont(); |
40 | 46 |
41 // Initialize the frame (creates the underlying native window). | 47 // Initialize the frame (creates the underlying native window). |
42 void InitBrowserFrame(); | 48 void InitBrowserFrame(); |
43 | 49 |
44 // Determine the distance of the left edge of the minimize button from the | 50 // Determine the distance of the left edge of the minimize button from the |
(...skipping 24 matching lines...) Expand all Loading... |
69 void TabStripDisplayModeChanged(); | 75 void TabStripDisplayModeChanged(); |
70 | 76 |
71 // Overridden from views::Widget: | 77 // Overridden from views::Widget: |
72 virtual views::internal::RootView* CreateRootView() OVERRIDE; | 78 virtual views::internal::RootView* CreateRootView() OVERRIDE; |
73 virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | 79 virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE; |
74 virtual bool GetAccelerator(int command_id, | 80 virtual bool GetAccelerator(int command_id, |
75 ui::Accelerator* accelerator) OVERRIDE; | 81 ui::Accelerator* accelerator) OVERRIDE; |
76 virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE; | 82 virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE; |
77 virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE; | 83 virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE; |
78 | 84 |
| 85 // Overridden from views::ContextMenuController: |
| 86 virtual void ShowContextMenuForView(views::View* source, |
| 87 const gfx::Point& p) OVERRIDE; |
| 88 |
79 // Returns true if we should leave any offset at the frame caption. Typically | 89 // Returns true if we should leave any offset at the frame caption. Typically |
80 // when the frame is maximized/full screen we want to leave no offset at the | 90 // when the frame is maximized/full screen we want to leave no offset at the |
81 // top. | 91 // top. |
82 bool ShouldLeaveOffsetNearTopBorder(); | 92 bool ShouldLeaveOffsetNearTopBorder(); |
83 | 93 |
84 AvatarMenuButton* GetAvatarMenuButton(); | 94 AvatarMenuButton* GetAvatarMenuButton(); |
85 | 95 |
| 96 // Returns the menu model. BrowserFrame owns the returned model. |
| 97 ui::MenuModel* GetSystemMenuModel(); |
| 98 |
86 private: | 99 private: |
87 NativeBrowserFrame* native_browser_frame_; | 100 NativeBrowserFrame* native_browser_frame_; |
88 | 101 |
89 // A weak reference to the root view associated with the window. We save a | 102 // A weak reference to the root view associated with the window. We save a |
90 // copy as a BrowserRootView to avoid evil casting later, when we need to call | 103 // copy as a BrowserRootView to avoid evil casting later, when we need to call |
91 // functions that only exist on BrowserRootView (versus RootView). | 104 // functions that only exist on BrowserRootView (versus RootView). |
92 BrowserRootView* root_view_; | 105 BrowserRootView* root_view_; |
93 | 106 |
94 // A pointer to our NonClientFrameView as a BrowserNonClientFrameView. | 107 // A pointer to our NonClientFrameView as a BrowserNonClientFrameView. |
95 BrowserNonClientFrameView* browser_frame_view_; | 108 BrowserNonClientFrameView* browser_frame_view_; |
96 | 109 |
97 // The BrowserView is our ClientView. This is a pointer to it. | 110 // The BrowserView is our ClientView. This is a pointer to it. |
98 BrowserView* browser_view_; | 111 BrowserView* browser_view_; |
99 | 112 |
| 113 scoped_ptr<SystemMenuModelBuilder> menu_model_builder_; |
| 114 |
| 115 // Used to show the system menu. Only used if |
| 116 // NativeBrowserFrame::UsesNativeSystemMenu() returns false. |
| 117 scoped_ptr<views::MenuRunner> menu_runner_; |
| 118 |
100 DISALLOW_COPY_AND_ASSIGN(BrowserFrame); | 119 DISALLOW_COPY_AND_ASSIGN(BrowserFrame); |
101 }; | 120 }; |
102 | 121 |
103 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ | 122 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_ |
OLD | NEW |