| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_H_ | 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_ | 6 #define CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 8 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
| 9 #include "ui/views/window/non_client_view.h" | 9 #include "ui/views/window/non_client_view.h" |
| 10 | 10 |
| 11 #if defined(FRAME_AVATAR_BUTTON) | 11 #if defined(FRAME_AVATAR_BUTTON) |
| 12 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" | 12 #include "chrome/browser/ui/views/frame/avatar_button_bridge.h" |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #if defined(ENABLE_SUPERVISED_USERS) | 15 #if defined(ENABLE_SUPERVISED_USERS) |
| 16 class SupervisedUserAvatarLabel; | 16 class SupervisedUserAvatarLabel; |
| 17 #endif | 17 #endif |
| 18 class AvatarMenuButton; | 18 class AvatarMenuButton; |
| 19 class BrowserFrame; | 19 class BrowserFrame; |
| 20 class BrowserView; | 20 class BrowserView; |
| 21 | 21 |
| 22 // A specialization of the NonClientFrameView object that provides additional | 22 // A specialization of the NonClientFrameView object that provides additional |
| 23 // Browser-specific methods. | 23 // Browser-specific methods. |
| 24 class BrowserNonClientFrameView : public views::NonClientFrameView, | 24 class BrowserNonClientFrameView : public views::NonClientFrameView, |
| 25 public ProfileInfoCacheObserver { | 25 public ProfileInfoCacheObserver { |
| 26 public: | 26 public: |
| 27 BrowserNonClientFrameView(BrowserFrame* frame, BrowserView* browser_view); | 27 BrowserNonClientFrameView(BrowserFrame* frame, BrowserView* browser_view); |
| 28 ~BrowserNonClientFrameView() override; | 28 ~BrowserNonClientFrameView() override; |
| 29 | 29 |
| 30 BrowserView* browser_view() const { return browser_view_; } |
| 31 BrowserFrame* frame() const { return frame_; } |
| 30 AvatarMenuButton* avatar_button() const { return avatar_button_; } | 32 AvatarMenuButton* avatar_button() const { return avatar_button_; } |
| 31 | 33 |
| 32 #if defined(FRAME_AVATAR_BUTTON) | 34 #if defined(FRAME_AVATAR_BUTTON) |
| 33 NewAvatarButton* new_avatar_button() const { return new_avatar_button_; } | 35 views::View* new_avatar_button() const { |
| 36 return avatar_button_bridge_.view(); |
| 37 } |
| 34 #endif | 38 #endif |
| 35 | 39 |
| 36 #if defined(ENABLE_SUPERVISED_USERS) | 40 #if defined(ENABLE_SUPERVISED_USERS) |
| 37 SupervisedUserAvatarLabel* supervised_user_avatar_label() const { | 41 SupervisedUserAvatarLabel* supervised_user_avatar_label() const { |
| 38 return supervised_user_avatar_label_; | 42 return supervised_user_avatar_label_; |
| 39 } | 43 } |
| 40 | 44 |
| 41 void OnThemeChanged() override; | 45 void OnThemeChanged() override; |
| 42 #endif | 46 #endif |
| 43 | 47 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 67 virtual void UpdateToolbar(); | 71 virtual void UpdateToolbar(); |
| 68 | 72 |
| 69 // Returns the location icon, if this frame has any. | 73 // Returns the location icon, if this frame has any. |
| 70 virtual views::View* GetLocationIconView() const; | 74 virtual views::View* GetLocationIconView() const; |
| 71 | 75 |
| 72 // Overriden from views::View. | 76 // Overriden from views::View. |
| 73 void VisibilityChanged(views::View* starting_from, bool is_visible) override; | 77 void VisibilityChanged(views::View* starting_from, bool is_visible) override; |
| 74 void ChildPreferredSizeChanged(View* child) override; | 78 void ChildPreferredSizeChanged(View* child) override; |
| 75 | 79 |
| 76 protected: | 80 protected: |
| 77 BrowserView* browser_view() const { return browser_view_; } | |
| 78 BrowserFrame* frame() const { return frame_; } | |
| 79 | |
| 80 // Whether the frame should be painted with theming. | 81 // Whether the frame should be painted with theming. |
| 81 // By default, tabbed browser windows are themed but popup and app windows are | 82 // By default, tabbed browser windows are themed but popup and app windows are |
| 82 // not. | 83 // not. |
| 83 virtual bool ShouldPaintAsThemed() const; | 84 virtual bool ShouldPaintAsThemed() const; |
| 84 | 85 |
| 85 // Compute aspects of the frame needed to paint the frame background. | 86 // Compute aspects of the frame needed to paint the frame background. |
| 86 SkColor GetFrameColor() const; | 87 SkColor GetFrameColor() const; |
| 87 gfx::ImageSkia* GetFrameImage() const; | 88 gfx::ImageSkia* GetFrameImage() const; |
| 88 gfx::ImageSkia* GetFrameOverlayImage() const; | 89 gfx::ImageSkia* GetFrameOverlayImage() const; |
| 89 int GetTopAreaHeight() const; | 90 int GetTopAreaHeight() const; |
| 90 | 91 |
| 91 // Updates the avatar button using the old or new UI based on the BrowserView | 92 // Updates the avatar button using the old or new UI based on the BrowserView |
| 92 // type, and the presence of the --enable-new-avatar-menu flag. Calls either | 93 // type, and the presence of the --enable-new-avatar-menu flag. Calls either |
| 93 // UpdateOldAvatarButton() or UpdateNewAvatarButtonImpl() accordingly. | 94 // UpdateOldAvatarButton() or UpdateNewAvatarButtonImpl() accordingly. |
| 94 void UpdateAvatar(); | 95 void UpdateAvatar(); |
| 95 | 96 |
| 96 // Updates the title and icon of the old avatar button. | 97 // Updates the title and icon of the old avatar button. |
| 97 void UpdateOldAvatarButton(); | 98 void UpdateOldAvatarButton(); |
| 98 | 99 |
| 99 // Updates the avatar button displayed in the caption area by calling | 100 // Updates the avatar button displayed in the caption area by calling |
| 100 // UpdateNewAvatarButton() with an implementation specific |listener| | 101 // UpdateNewAvatarButton() with an implementation specific |listener| |
| 101 // and button |style|. | 102 // and button |style|. |
| 102 virtual void UpdateNewAvatarButtonImpl() = 0; | 103 virtual void UpdateNewAvatarButtonImpl() = 0; |
| 103 | 104 |
| 104 #if defined(FRAME_AVATAR_BUTTON) | 105 #if defined(FRAME_AVATAR_BUTTON) |
| 105 // Updates the title of the avatar button displayed in the caption area. | 106 // Updates the title of the avatar button displayed in the caption area. |
| 106 // The button uses |style| to match the browser window style and notifies | 107 // The button uses |style| to match the browser window style. |
| 107 // |listener| when it is clicked. | 108 void UpdateNewAvatarButton(const AvatarButtonStyle style); |
| 108 void UpdateNewAvatarButton(views::ButtonListener* listener, | |
| 109 const NewAvatarButton::AvatarButtonStyle style); | |
| 110 #endif | 109 #endif |
| 111 | 110 |
| 112 private: | 111 private: |
| 113 // Overriden from ProfileInfoCacheObserver. | 112 // Overriden from ProfileInfoCacheObserver. |
| 114 void OnProfileAdded(const base::FilePath& profile_path) override; | 113 void OnProfileAdded(const base::FilePath& profile_path) override; |
| 115 void OnProfileWasRemoved(const base::FilePath& profile_path, | 114 void OnProfileWasRemoved(const base::FilePath& profile_path, |
| 116 const base::string16& profile_name) override; | 115 const base::string16& profile_name) override; |
| 117 void OnProfileAvatarChanged(const base::FilePath& profile_path) override; | 116 void OnProfileAvatarChanged(const base::FilePath& profile_path) override; |
| 118 | 117 |
| 119 // Draws a taskbar icon if avatars are enabled, erases it otherwise. | 118 // Draws a taskbar icon if avatars are enabled, erases it otherwise. |
| 120 void UpdateTaskbarDecoration(); | 119 void UpdateTaskbarDecoration(); |
| 121 | 120 |
| 122 // The frame that hosts this view. | 121 // The frame that hosts this view. |
| 123 BrowserFrame* frame_; | 122 BrowserFrame* frame_; |
| 124 | 123 |
| 125 // The BrowserView hosted within this View. | 124 // The BrowserView hosted within this View. |
| 126 BrowserView* browser_view_; | 125 BrowserView* browser_view_; |
| 127 | 126 |
| 128 #if defined(ENABLE_SUPERVISED_USERS) | 127 #if defined(ENABLE_SUPERVISED_USERS) |
| 129 SupervisedUserAvatarLabel* supervised_user_avatar_label_; | 128 SupervisedUserAvatarLabel* supervised_user_avatar_label_; |
| 130 #endif | 129 #endif |
| 131 | 130 |
| 132 #if defined(FRAME_AVATAR_BUTTON) | 131 #if defined(FRAME_AVATAR_BUTTON) |
| 133 // Menu button that displays the name of the active or guest profile. | 132 // Wrapper around the in-frame avatar switcher. |
| 134 // May be null and will not be displayed for off the record profiles. | 133 // TODO(tapted): Move this component down into the subclasses that need it. |
| 135 NewAvatarButton* new_avatar_button_; | 134 AvatarButtonBridge avatar_button_bridge_; |
| 136 #endif | 135 #endif |
| 137 | 136 |
| 138 // Menu button that displays the incognito icon. May be null for some frame | 137 // Menu button that displays the incognito icon. May be null for some frame |
| 139 // styles. TODO(anthonyvd): simplify/rename. | 138 // styles. TODO(anthonyvd): simplify/rename. |
| 140 AvatarMenuButton* avatar_button_; | 139 AvatarMenuButton* avatar_button_; |
| 141 }; | 140 }; |
| 142 | 141 |
| 143 namespace chrome { | 142 namespace chrome { |
| 144 | 143 |
| 145 // Provided by a browser_non_client_frame_view_factory_*.cc implementation | 144 // Provided by a browser_non_client_frame_view_factory_*.cc implementation |
| 146 BrowserNonClientFrameView* CreateBrowserNonClientFrameView( | 145 BrowserNonClientFrameView* CreateBrowserNonClientFrameView( |
| 147 BrowserFrame* frame, BrowserView* browser_view); | 146 BrowserFrame* frame, BrowserView* browser_view); |
| 148 | 147 |
| 149 } // namespace chrome | 148 } // namespace chrome |
| 150 | 149 |
| 151 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_H_ | 150 #endif // CHROME_BROWSER_UI_VIEWS_FRAME_BROWSER_NON_CLIENT_FRAME_VIEW_H_ |
| OLD | NEW |