Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / browser_non_client_frame_view.h
blob9da2a5d3c1a6130035d6d1586e4a51a95a1419d1
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_NON_CLIENT_FRAME_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_H_
8 #include "chrome/browser/profiles/profile_info_cache_observer.h"
9 #include "ui/views/window/non_client_view.h"
11 #if defined(FRAME_AVATAR_BUTTON)
12 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
13 #endif
15 #if defined(ENABLE_SUPERVISED_USERS)
16 class SupervisedUserAvatarLabel;
17 #endif
18 class AvatarMenuButton;
19 class BrowserFrame;
20 class BrowserView;
22 // A specialization of the NonClientFrameView object that provides additional
23 // Browser-specific methods.
24 class BrowserNonClientFrameView : public views::NonClientFrameView,
25 public ProfileInfoCacheObserver {
26 public:
27 BrowserNonClientFrameView(BrowserFrame* frame, BrowserView* browser_view);
28 ~BrowserNonClientFrameView() override;
30 AvatarMenuButton* avatar_button() const { return avatar_button_; }
32 #if defined(FRAME_AVATAR_BUTTON)
33 NewAvatarButton* new_avatar_button() const { return new_avatar_button_; }
34 #endif
36 #if defined(ENABLE_SUPERVISED_USERS)
37 SupervisedUserAvatarLabel* supervised_user_avatar_label() const {
38 return supervised_user_avatar_label_;
41 void OnThemeChanged() override;
42 #endif
44 // Retrieves the bounds, in non-client view coordinates within which the
45 // TabStrip should be laid out.
46 virtual gfx::Rect GetBoundsForTabStrip(views::View* tabstrip) const = 0;
48 // Returns the inset of the topmost view in the client view from the top of
49 // the non-client view. The topmost view depends on the window type. The
50 // topmost view is the tab strip for tabbed browser windows, the toolbar for
51 // popups, the web contents for app windows and varies for fullscreen windows.
52 virtual int GetTopInset() const = 0;
54 // Returns the amount that the theme background should be inset.
55 virtual int GetThemeBackgroundXInset() const = 0;
57 // Updates the throbber.
58 virtual void UpdateThrobber(bool running) = 0;
60 // Updates any toolbar components in the frame. The default implementation
61 // does nothing.
62 virtual void UpdateToolbar();
64 // Returns the location icon, if this frame has any.
65 virtual views::View* GetLocationIconView() const;
67 // Overriden from views::View.
68 void VisibilityChanged(views::View* starting_from, bool is_visible) override;
69 void ChildPreferredSizeChanged(View* child) override;
71 protected:
72 BrowserView* browser_view() const { return browser_view_; }
73 BrowserFrame* frame() const { return frame_; }
75 // Whether the frame should be painted with theming.
76 // By default, tabbed browser windows are themed but popup and app windows are
77 // not.
78 virtual bool ShouldPaintAsThemed() const;
80 // Compute aspects of the frame needed to paint the frame background.
81 SkColor GetFrameColor() const;
82 gfx::ImageSkia* GetFrameImage() const;
83 gfx::ImageSkia* GetFrameOverlayImage() const;
84 int GetTopAreaHeight() const;
86 // Updates the avatar button using the old or new UI based on the BrowserView
87 // type, and the presence of the --enable-new-avatar-menu flag. Calls either
88 // UpdateOldAvatarButton() or UpdateNewAvatarButtonImpl() accordingly.
89 void UpdateAvatar();
91 // Updates the title and icon of the old avatar button.
92 void UpdateOldAvatarButton();
94 // Updates the avatar button displayed in the caption area by calling
95 // UpdateNewAvatarButton() with an implementation specific |listener|
96 // and button |style|.
97 virtual void UpdateNewAvatarButtonImpl() = 0;
99 #if defined(FRAME_AVATAR_BUTTON)
100 // Updates the title of the avatar button displayed in the caption area.
101 // The button uses |style| to match the browser window style and notifies
102 // |listener| when it is clicked.
103 void UpdateNewAvatarButton(views::ButtonListener* listener,
104 const NewAvatarButton::AvatarButtonStyle style);
105 #endif
107 private:
108 // Overriden from ProfileInfoCacheObserver.
109 void OnProfileAdded(const base::FilePath& profile_path) override;
110 void OnProfileWasRemoved(const base::FilePath& profile_path,
111 const base::string16& profile_name) override;
112 void OnProfileAvatarChanged(const base::FilePath& profile_path) override;
114 // Draws a taskbar icon if avatars are enabled, erases it otherwise.
115 void UpdateTaskbarDecoration();
117 // The frame that hosts this view.
118 BrowserFrame* frame_;
120 // The BrowserView hosted within this View.
121 BrowserView* browser_view_;
123 #if defined(ENABLE_SUPERVISED_USERS)
124 SupervisedUserAvatarLabel* supervised_user_avatar_label_;
125 #endif
127 #if defined(FRAME_AVATAR_BUTTON)
128 // Menu button that displays the name of the active or guest profile.
129 // May be null and will not be displayed for off the record profiles.
130 NewAvatarButton* new_avatar_button_;
131 #endif
133 // Menu button that displays the incognito icon. May be null for some frame
134 // styles. TODO(anthonyvd): simplify/rename.
135 AvatarMenuButton* avatar_button_;
138 namespace chrome {
140 // Provided by a browser_non_client_frame_view_factory_*.cc implementation
141 BrowserNonClientFrameView* CreateBrowserNonClientFrameView(
142 BrowserFrame* frame, BrowserView* browser_view);
144 } // namespace chrome
146 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_H_