- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / frame / browser_frame.h
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/logging.h"
10 #include "build/build_config.h"
11 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
12 #include "ui/views/context_menu_controller.h"
13 #include "ui/views/widget/widget.h"
14
15 class AvatarMenuButton;
16 class BrowserRootView;
17 class BrowserView;
18 class NativeBrowserFrame;
19 class NewAvatarButton;
20 class NonClientFrameView;
21 class SystemMenuModelBuilder;
22
23 namespace gfx {
24 class Font;
25 class Rect;
26 }
27
28 namespace ui {
29 class MenuModel;
30 class ThemeProvider;
31 }
32
33 namespace views {
34 class MenuRunner;
35 class View;
36 }
37
38 // This is a virtual interface that allows system specific browser frames.
39 class BrowserFrame
40     : public views::Widget,
41       public views::ContextMenuController {
42  public:
43   explicit BrowserFrame(BrowserView* browser_view);
44   virtual ~BrowserFrame();
45
46   static const gfx::Font& GetTitleFont();
47
48   // Initialize the frame (creates the underlying native window).
49   void InitBrowserFrame();
50
51   // Sets the ThemeProvider returned from GetThemeProvider().
52   void SetThemeProvider(scoped_ptr<ui::ThemeProvider> provider);
53
54   // Determine the distance of the left edge of the minimize button from the
55   // left edge of the window. Used in our Non-Client View's Layout.
56   int GetMinimizeButtonOffset() const;
57
58   // Retrieves the bounds, in non-client view coordinates for the specified
59   // TabStrip view.
60   gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const;
61
62   // Returns the y coordinate within the window at which the horizontal TabStrip
63   // begins (or would begin).  If |force_restored| is true, this is calculated
64   // as if we were in restored mode regardless of the current mode.
65   BrowserNonClientFrameView::TabStripInsets GetTabStripInsets(
66       bool force_restored) const;
67
68   // Returns the amount that the theme background should be inset.
69   int GetThemeBackgroundXInset() const;
70
71   // Tells the frame to update the throbber.
72   void UpdateThrobber(bool running);
73
74   // Returns the NonClientFrameView of this frame.
75   views::View* GetFrameView() const;
76
77   // Notifies the frame that the tab strip display mode changed so it can update
78   // its frame treatment if necessary.
79   void TabStripDisplayModeChanged();
80
81   // Overridden from views::Widget:
82   virtual views::internal::RootView* CreateRootView() OVERRIDE;
83   virtual views::NonClientFrameView* CreateNonClientFrameView() OVERRIDE;
84   virtual bool GetAccelerator(int command_id,
85                               ui::Accelerator* accelerator) OVERRIDE;
86   virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE;
87   virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
88   virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE;
89
90   // Overridden from views::ContextMenuController:
91   virtual void ShowContextMenuForView(views::View* source,
92                                       const gfx::Point& p,
93                                       ui::MenuSourceType source_type) OVERRIDE;
94
95   // Returns true if we should leave any offset at the frame caption. Typically
96   // when the frame is maximized/full screen we want to leave no offset at the
97   // top.
98   bool ShouldLeaveOffsetNearTopBorder();
99
100   AvatarMenuButton* GetAvatarMenuButton();
101
102   NewAvatarButton* GetNewAvatarMenuButton();
103
104   // Returns the menu model. BrowserFrame owns the returned model.
105   // Note that in multi user mode this will upon each call create a new model.
106   ui::MenuModel* GetSystemMenuModel();
107
108  private:
109   NativeBrowserFrame* native_browser_frame_;
110
111   // A weak reference to the root view associated with the window. We save a
112   // copy as a BrowserRootView to avoid evil casting later, when we need to call
113   // functions that only exist on BrowserRootView (versus RootView).
114   BrowserRootView* root_view_;
115
116   // A pointer to our NonClientFrameView as a BrowserNonClientFrameView.
117   BrowserNonClientFrameView* browser_frame_view_;
118
119   // The BrowserView is our ClientView. This is a pointer to it.
120   BrowserView* browser_view_;
121
122   scoped_ptr<SystemMenuModelBuilder> menu_model_builder_;
123
124   // Used to show the system menu. Only used if
125   // NativeBrowserFrame::UsesNativeSystemMenu() returns false.
126   scoped_ptr<views::MenuRunner> menu_runner_;
127
128   // SetThemeProvider() triggers setting both |owned_theme_provider_| and
129   // |theme_provider_|. Initially |theme_provider_| is set to the ThemeService
130   // and |owned_theme_provider_| is NULL (as ThemeServices lifetime is managed
131   // externally).
132   scoped_ptr<ui::ThemeProvider> owned_theme_provider_;
133   ui::ThemeProvider* theme_provider_;
134
135   DISALLOW_COPY_AND_ASSIGN(BrowserFrame);
136 };
137
138 #endif  // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_