Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / browser_frame.h
blob4452240c7b5bc01d9cbf39853ff9005e7e434f50
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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_
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"
15 class AvatarMenuButton;
16 class BrowserRootView;
17 class BrowserView;
18 class NativeBrowserFrame;
19 class NewAvatarButton;
20 class NonClientFrameView;
21 class SystemMenuModelBuilder;
23 namespace gfx {
24 class FontList;
25 class Rect;
28 namespace ui {
29 class EventHandler;
30 class MenuModel;
31 class ThemeProvider;
34 namespace views {
35 class MenuRunner;
36 class View;
39 // This is a virtual interface that allows system specific browser frames.
40 class BrowserFrame
41 : public views::Widget,
42 public views::ContextMenuController {
43 public:
44 explicit BrowserFrame(BrowserView* browser_view);
45 ~BrowserFrame() override;
47 static const gfx::FontList& GetTitleFontList();
49 // Initialize the frame (creates the underlying native window).
50 void InitBrowserFrame();
52 // Sets the ThemeProvider returned from GetThemeProvider().
53 void SetThemeProvider(scoped_ptr<ui::ThemeProvider> provider);
55 // Determine the distance of the left edge of the minimize button from the
56 // left edge of the window. Used in our Non-Client View's Layout.
57 int GetMinimizeButtonOffset() const;
59 // Retrieves the bounds, in non-client view coordinates for the specified
60 // TabStrip view.
61 gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const;
63 // Returns the inset of the topmost view in the client view from the top of
64 // the non-client view. The topmost view depends on the window type. The
65 // topmost view is the tab strip for tabbed browser windows, the toolbar for
66 // popups, the web contents for app windows and varies for fullscreen windows
67 int GetTopInset() const;
69 // Returns the amount that the theme background should be inset.
70 int GetThemeBackgroundXInset() const;
72 // Tells the frame to update the throbber.
73 void UpdateThrobber(bool running);
75 // Tells the frame to update any toolbar elements it has.
76 void UpdateToolbar();
78 // Returns the location icon, if there is a location icon embedded into the
79 // frame. This is the case for web app frames, which do not have a visible
80 // toolbar. Instead of using the normal location icon from the location bar
81 // in the toolbar, these windows have a location icon in the frame.
82 views::View* GetLocationIconView() const;
84 // Returns the NonClientFrameView of this frame.
85 views::View* GetFrameView() const;
87 // Returns |true| if we should use the custom frame.
88 bool UseCustomFrame() const;
90 // Returns true when the window placement should be saved.
91 bool ShouldSaveWindowPlacement() const;
93 // Retrieves the window placement (show state and bounds) for restoring.
94 void GetWindowPlacement(gfx::Rect* bounds,
95 ui::WindowShowState* show_state) const;
97 // Overridden from views::Widget:
98 views::internal::RootView* CreateRootView() override;
99 views::NonClientFrameView* CreateNonClientFrameView() override;
100 bool GetAccelerator(int command_id,
101 ui::Accelerator* accelerator) const override;
102 ui::ThemeProvider* GetThemeProvider() const override;
103 void SchedulePaintInRect(const gfx::Rect& rect) override;
104 void OnNativeWidgetActivationChanged(bool active) override;
106 // Overridden from views::ContextMenuController:
107 void ShowContextMenuForView(views::View* source,
108 const gfx::Point& p,
109 ui::MenuSourceType source_type) override;
111 // Returns true if we should leave any offset at the frame caption. Typically
112 // when the frame is maximized/full screen we want to leave no offset at the
113 // top.
114 bool ShouldLeaveOffsetNearTopBorder();
116 AvatarMenuButton* GetAvatarMenuButton();
118 #if defined(FRAME_AVATAR_BUTTON)
119 NewAvatarButton* GetNewAvatarMenuButton();
120 #endif
122 // Returns the menu model. BrowserFrame owns the returned model.
123 // Note that in multi user mode this will upon each call create a new model.
124 ui::MenuModel* GetSystemMenuModel();
126 private:
127 NativeBrowserFrame* native_browser_frame_;
129 // A weak reference to the root view associated with the window. We save a
130 // copy as a BrowserRootView to avoid evil casting later, when we need to call
131 // functions that only exist on BrowserRootView (versus RootView).
132 BrowserRootView* root_view_;
134 // A pointer to our NonClientFrameView as a BrowserNonClientFrameView.
135 BrowserNonClientFrameView* browser_frame_view_;
137 // The BrowserView is our ClientView. This is a pointer to it.
138 BrowserView* browser_view_;
140 scoped_ptr<SystemMenuModelBuilder> menu_model_builder_;
142 // Used to show the system menu. Only used if
143 // NativeBrowserFrame::UsesNativeSystemMenu() returns false.
144 scoped_ptr<views::MenuRunner> menu_runner_;
146 // SetThemeProvider() triggers setting both |owned_theme_provider_| and
147 // |theme_provider_|. Initially |theme_provider_| is set to the ThemeService
148 // and |owned_theme_provider_| is null (as ThemeServices lifetime is managed
149 // externally).
150 scoped_ptr<ui::ThemeProvider> owned_theme_provider_;
151 ui::ThemeProvider* theme_provider_;
153 scoped_ptr<ui::EventHandler> browser_command_handler_;
155 DISALLOW_COPY_AND_ASSIGN(BrowserFrame);
158 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_