OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/browser/profiles/avatar_menu.h" | 11 #include "chrome/browser/profiles/avatar_menu.h" |
12 #include "chrome/browser/profiles/avatar_menu_observer.h" | 12 #include "chrome/browser/profiles/avatar_menu_observer.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "google_apis/gaia/oauth2_token_service.h" | 14 #include "google_apis/gaia/oauth2_token_service.h" |
15 #include "ui/views/bubble/bubble_delegate.h" | 15 #include "ui/views/bubble/bubble_delegate.h" |
16 #include "ui/views/controls/button/button.h" | 16 #include "ui/views/controls/button/button.h" |
17 #include "ui/views/controls/button/menu_button_listener.h" | |
18 #include "ui/views/controls/link_listener.h" | 17 #include "ui/views/controls/link_listener.h" |
19 #include "ui/views/controls/styled_label_listener.h" | 18 #include "ui/views/controls/styled_label_listener.h" |
20 #include "ui/views/controls/textfield/textfield_controller.h" | 19 #include "ui/views/controls/textfield/textfield_controller.h" |
21 | 20 |
22 class EditableProfilePhoto; | 21 class EditableProfilePhoto; |
23 class EditableProfileName; | 22 class EditableProfileName; |
24 | 23 |
25 namespace gfx { | 24 namespace gfx { |
26 class Image; | 25 class Image; |
27 } | 26 } |
28 | 27 |
29 namespace views { | 28 namespace views { |
30 class GridLayout; | 29 class GridLayout; |
31 class ImageButton; | 30 class ImageButton; |
32 class Link; | 31 class Link; |
33 class LabelButton; | 32 class LabelButton; |
34 } | 33 } |
35 | 34 |
36 class Browser; | 35 class Browser; |
37 | 36 |
38 // This bubble view is displayed when the user clicks on the avatar button. | 37 // This bubble view is displayed when the user clicks on the avatar button. |
39 // It displays a list of profiles and allows users to switch between profiles. | 38 // It displays a list of profiles and allows users to switch between profiles. |
40 class ProfileChooserView : public views::BubbleDelegateView, | 39 class ProfileChooserView : public views::BubbleDelegateView, |
41 public views::ButtonListener, | 40 public views::ButtonListener, |
42 public views::LinkListener, | 41 public views::LinkListener, |
43 public views::MenuButtonListener, | |
44 public views::StyledLabelListener, | 42 public views::StyledLabelListener, |
45 public views::TextfieldController, | 43 public views::TextfieldController, |
46 public AvatarMenuObserver, | 44 public AvatarMenuObserver, |
47 public OAuth2TokenService::Observer { | 45 public OAuth2TokenService::Observer { |
48 public: | 46 public: |
49 // Different views that can be displayed in the bubble. | 47 // Different views that can be displayed in the bubble. |
50 enum BubbleViewMode { | 48 enum BubbleViewMode { |
51 // Shows a "fast profile switcher" view. | 49 // Shows a "fast profile switcher" view. |
52 BUBBLE_VIEW_MODE_PROFILE_CHOOSER, | 50 BUBBLE_VIEW_MODE_PROFILE_CHOOSER, |
53 // Shows a list of accounts for the active user. | 51 // Shows a list of accounts for the active user. |
(...skipping 26 matching lines...) Expand all Loading... |
80 static void clear_close_on_deactivate_for_testing() { | 78 static void clear_close_on_deactivate_for_testing() { |
81 close_on_deactivate_for_testing_ = false; | 79 close_on_deactivate_for_testing_ = false; |
82 } | 80 } |
83 | 81 |
84 private: | 82 private: |
85 friend class NewAvatarMenuButtonTest; | 83 friend class NewAvatarMenuButtonTest; |
86 FRIEND_TEST_ALL_PREFIXES(NewAvatarMenuButtonTest, SignOut); | 84 FRIEND_TEST_ALL_PREFIXES(NewAvatarMenuButtonTest, SignOut); |
87 | 85 |
88 typedef std::vector<size_t> Indexes; | 86 typedef std::vector<size_t> Indexes; |
89 typedef std::map<views::Button*, int> ButtonIndexes; | 87 typedef std::map<views::Button*, int> ButtonIndexes; |
90 typedef std::map<views::View*, std::string> AccountButtonIndexes; | 88 typedef std::map<views::Button*, std::string> AccountButtonIndexes; |
91 | 89 |
92 ProfileChooserView(views::View* anchor_view, | 90 ProfileChooserView(views::View* anchor_view, |
93 views::BubbleBorder::Arrow arrow, | 91 views::BubbleBorder::Arrow arrow, |
94 const gfx::Rect& anchor_rect, | 92 const gfx::Rect& anchor_rect, |
95 Browser* browser, | 93 Browser* browser, |
96 BubbleViewMode view_mode); | 94 BubbleViewMode view_mode); |
97 virtual ~ProfileChooserView(); | 95 virtual ~ProfileChooserView(); |
98 | 96 |
99 // views::BubbleDelegateView: | 97 // views::BubbleDelegateView: |
100 virtual void Init() OVERRIDE; | 98 virtual void Init() OVERRIDE; |
101 virtual void WindowClosing() OVERRIDE; | 99 virtual void WindowClosing() OVERRIDE; |
102 | 100 |
103 // views::ButtonListener: | 101 // views::ButtonListener: |
104 virtual void ButtonPressed(views::Button* sender, | 102 virtual void ButtonPressed(views::Button* sender, |
105 const ui::Event& event) OVERRIDE; | 103 const ui::Event& event) OVERRIDE; |
106 | 104 |
107 // views::LinkListener: | 105 // views::LinkListener: |
108 virtual void LinkClicked(views::Link* sender, int event_flags) OVERRIDE; | 106 virtual void LinkClicked(views::Link* sender, int event_flags) OVERRIDE; |
109 | 107 |
110 // views::MenuButtonListener: | |
111 virtual void OnMenuButtonClicked(views::View* source, | |
112 const gfx::Point& point) OVERRIDE; | |
113 | |
114 // views::StyledLabelListener implementation. | 108 // views::StyledLabelListener implementation. |
115 virtual void StyledLabelLinkClicked( | 109 virtual void StyledLabelLinkClicked( |
116 const gfx::Range& range, int event_flags) OVERRIDE; | 110 const gfx::Range& range, int event_flags) OVERRIDE; |
117 | 111 |
118 // views::TextfieldController: | 112 // views::TextfieldController: |
119 virtual bool HandleKeyEvent(views::Textfield* sender, | 113 virtual bool HandleKeyEvent(views::Textfield* sender, |
120 const ui::KeyEvent& key_event) OVERRIDE; | 114 const ui::KeyEvent& key_event) OVERRIDE; |
121 | 115 |
122 // AvatarMenuObserver: | 116 // AvatarMenuObserver: |
123 virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE; | 117 virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE; |
(...skipping 20 matching lines...) Expand all Loading... |
144 // is used to determine whether to show any Sign in/Sign out/Manage accounts | 138 // is used to determine whether to show any Sign in/Sign out/Manage accounts |
145 // links. | 139 // links. |
146 views::View* CreateCurrentProfileView( | 140 views::View* CreateCurrentProfileView( |
147 const AvatarMenu::Item& avatar_item, | 141 const AvatarMenu::Item& avatar_item, |
148 bool is_guest); | 142 bool is_guest); |
149 views::View* CreateGuestProfileView(); | 143 views::View* CreateGuestProfileView(); |
150 views::View* CreateOtherProfilesView(const Indexes& avatars_to_show); | 144 views::View* CreateOtherProfilesView(const Indexes& avatars_to_show); |
151 views::View* CreateOptionsView(bool enable_lock); | 145 views::View* CreateOptionsView(bool enable_lock); |
152 | 146 |
153 // Account Management view for the profile |avatar_item|. | 147 // Account Management view for the profile |avatar_item|. |
154 views::View* CreateCurrentProfileEditableView( | |
155 const AvatarMenu::Item& avatar_item); | |
156 views::View* CreateCurrentProfileAccountsView( | 148 views::View* CreateCurrentProfileAccountsView( |
157 const AvatarMenu::Item& avatar_item); | 149 const AvatarMenu::Item& avatar_item); |
158 void CreateAccountButton(views::GridLayout* layout, | 150 void CreateAccountButton(views::GridLayout* layout, |
159 const std::string& account, | 151 const std::string& account, |
160 bool is_primary_account, | 152 bool is_primary_account, |
161 int width); | 153 int width); |
162 | 154 |
163 // Creates a webview showing the gaia signin page. | 155 // Creates a webview showing the gaia signin page. |
164 views::View* CreateGaiaSigninView(bool add_secondary_account); | 156 views::View* CreateGaiaSigninView(bool add_secondary_account); |
165 | 157 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // Accounts associated with the current profile. | 194 // Accounts associated with the current profile. |
203 AccountButtonIndexes current_profile_accounts_map_; | 195 AccountButtonIndexes current_profile_accounts_map_; |
204 | 196 |
205 // Links and buttons displayed in the tutorial card. | 197 // Links and buttons displayed in the tutorial card. |
206 views::Link* tutorial_learn_more_link_; | 198 views::Link* tutorial_learn_more_link_; |
207 views::LabelButton* tutorial_ok_button_; | 199 views::LabelButton* tutorial_ok_button_; |
208 views::LabelButton* tutorial_enable_new_profile_management_button_; | 200 views::LabelButton* tutorial_enable_new_profile_management_button_; |
209 | 201 |
210 // Links displayed in the active profile card. | 202 // Links displayed in the active profile card. |
211 views::Link* manage_accounts_link_; | 203 views::Link* manage_accounts_link_; |
212 views::Link* signin_current_profile_link_; | 204 views::LabelButton* signin_current_profile_link_; |
213 | 205 |
214 // The profile name and photo in the active profile card. Owned by the | 206 // The profile name and photo in the active profile card. Owned by the |
215 // views hierarchy. | 207 // views hierarchy. |
216 EditableProfilePhoto* current_profile_photo_; | 208 EditableProfilePhoto* current_profile_photo_; |
217 EditableProfileName* current_profile_name_; | 209 EditableProfileName* current_profile_name_; |
218 | 210 |
219 // Action buttons. | 211 // Action buttons. |
220 views::LabelButton* users_button_; | 212 views::LabelButton* users_button_; |
221 views::LabelButton* lock_button_; | 213 views::LabelButton* lock_button_; |
222 views::LabelButton* add_account_button_; | 214 views::Link* add_account_link_; |
223 | 215 |
224 // Buttons displayed in the gaia signin view. | 216 // Buttons displayed in the gaia signin view. |
225 views::ImageButton* gaia_signin_cancel_button_; | 217 views::ImageButton* gaia_signin_cancel_button_; |
226 | 218 |
227 // Links and buttons displayed in the account removal view. | 219 // Links and buttons displayed in the account removal view. |
228 views::LabelButton* remove_account_and_relaunch_button_; | 220 views::LabelButton* remove_account_and_relaunch_button_; |
229 views::ImageButton* account_removal_cancel_button_; | 221 views::ImageButton* account_removal_cancel_button_; |
230 | 222 |
231 // Records the account id to remove. | 223 // Records the account id to remove. |
232 std::string account_id_to_remove_; | 224 std::string account_id_to_remove_; |
233 | 225 |
234 // Active view mode. | 226 // Active view mode. |
235 BubbleViewMode view_mode_; | 227 BubbleViewMode view_mode_; |
236 | 228 |
237 // Whether the tutorial is currently shown. | 229 // Whether the tutorial is currently shown. |
238 bool tutorial_showing_; | 230 bool tutorial_showing_; |
239 | 231 |
240 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); | 232 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); |
241 }; | 233 }; |
242 | 234 |
243 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 235 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
OLD | NEW |