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 inset of the topmost view in the client view from the top of
63 // the non-client view. The topmost view depends on the window type. The
64 // topmost view is the tab strip for tabbed browser windows, the toolbar for
65 // popups, the web contents for app windows and varies for fullscreen windows
66 int GetTopInset() 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 // Overridden from views::Widget:
78 virtual views::internal::RootView
* CreateRootView() OVERRIDE
;
79 virtual views::NonClientFrameView
* CreateNonClientFrameView() OVERRIDE
;
80 virtual bool GetAccelerator(int command_id
,
81 ui::Accelerator
* accelerator
) OVERRIDE
;
82 virtual ui::ThemeProvider
* GetThemeProvider() const OVERRIDE
;
83 virtual void SchedulePaintInRect(const gfx::Rect
& rect
) OVERRIDE
;
84 virtual void OnNativeWidgetActivationChanged(bool active
) OVERRIDE
;
86 // Overridden from views::ContextMenuController:
87 virtual void ShowContextMenuForView(views::View
* source
,
89 ui::MenuSourceType source_type
) OVERRIDE
;
91 // Returns true if we should leave any offset at the frame caption. Typically
92 // when the frame is maximized/full screen we want to leave no offset at the
94 bool ShouldLeaveOffsetNearTopBorder();
96 AvatarMenuButton
* GetAvatarMenuButton();
98 NewAvatarButton
* GetNewAvatarMenuButton();
100 // Returns the menu model. BrowserFrame owns the returned model.
101 // Note that in multi user mode this will upon each call create a new model.
102 ui::MenuModel
* GetSystemMenuModel();
105 NativeBrowserFrame
* native_browser_frame_
;
107 // A weak reference to the root view associated with the window. We save a
108 // copy as a BrowserRootView to avoid evil casting later, when we need to call
109 // functions that only exist on BrowserRootView (versus RootView).
110 BrowserRootView
* root_view_
;
112 // A pointer to our NonClientFrameView as a BrowserNonClientFrameView.
113 BrowserNonClientFrameView
* browser_frame_view_
;
115 // The BrowserView is our ClientView. This is a pointer to it.
116 BrowserView
* browser_view_
;
118 scoped_ptr
<SystemMenuModelBuilder
> menu_model_builder_
;
120 // Used to show the system menu. Only used if
121 // NativeBrowserFrame::UsesNativeSystemMenu() returns false.
122 scoped_ptr
<views::MenuRunner
> menu_runner_
;
124 // SetThemeProvider() triggers setting both |owned_theme_provider_| and
125 // |theme_provider_|. Initially |theme_provider_| is set to the ThemeService
126 // and |owned_theme_provider_| is NULL (as ThemeServices lifetime is managed
128 scoped_ptr
<ui::ThemeProvider
> owned_theme_provider_
;
129 ui::ThemeProvider
* theme_provider_
;
131 DISALLOW_COPY_AND_ASSIGN(BrowserFrame
);
134 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_FRAME_H_