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;
18 class NativeBrowserFrame;
19 class NewAvatarButton;
20 class NonClientFrameView;
21 class SystemMenuModelBuilder;
38 // This is a virtual interface that allows system specific browser frames.
40 : public views::Widget,
41 public views::ContextMenuController {
43 explicit BrowserFrame(BrowserView* browser_view);
44 virtual ~BrowserFrame();
46 static const gfx::Font& GetTitleFont();
48 // Initialize the frame (creates the underlying native window).
49 void InitBrowserFrame();
51 // Sets the ThemeProvider returned from GetThemeProvider().
52 void SetThemeProvider(scoped_ptr<ui::ThemeProvider> provider);
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;
58 // Retrieves the bounds, in non-client view coordinates for the specified
60 gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const;
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;
68 // Returns the amount that the theme background should be inset.
69 int GetThemeBackgroundXInset() const;
71 // Tells the frame to update the throbber.
72 void UpdateThrobber(bool running);
74 // Returns the NonClientFrameView of this frame.
75 views::View* GetFrameView() const;
77 // Notifies the frame that the tab strip display mode changed so it can update
78 // its frame treatment if necessary.
79 void TabStripDisplayModeChanged();
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;
90 // Overridden from views::ContextMenuController:
91 virtual void ShowContextMenuForView(views::View* source,
93 ui::MenuSourceType source_type) OVERRIDE;
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
98 bool ShouldLeaveOffsetNearTopBorder();
100 AvatarMenuButton* GetAvatarMenuButton();
102 NewAvatarButton* GetNewAvatarMenuButton();
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();
109 NativeBrowserFrame* native_browser_frame_;
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_;
116 // A pointer to our NonClientFrameView as a BrowserNonClientFrameView.
117 BrowserNonClientFrameView* browser_frame_view_;
119 // The BrowserView is our ClientView. This is a pointer to it.
120 BrowserView* browser_view_;
122 scoped_ptr<SystemMenuModelBuilder> menu_model_builder_;
124 // Used to show the system menu. Only used if
125 // NativeBrowserFrame::UsesNativeSystemMenu() returns false.
126 scoped_ptr<views::MenuRunner> menu_runner_;
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
132 scoped_ptr<ui::ThemeProvider> owned_theme_provider_;
133 ui::ThemeProvider* theme_provider_;
135 DISALLOW_COPY_AND_ASSIGN(BrowserFrame);
138 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_