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 "chrome/browser/ui/profile_chooser_constants.h" |
14 #include "google_apis/gaia/oauth2_token_service.h" | 15 #include "google_apis/gaia/oauth2_token_service.h" |
15 #include "ui/views/bubble/bubble_delegate.h" | 16 #include "ui/views/bubble/bubble_delegate.h" |
16 #include "ui/views/controls/button/button.h" | 17 #include "ui/views/controls/button/button.h" |
17 #include "ui/views/controls/link_listener.h" | 18 #include "ui/views/controls/link_listener.h" |
18 #include "ui/views/controls/styled_label_listener.h" | 19 #include "ui/views/controls/styled_label_listener.h" |
19 #include "ui/views/controls/textfield/textfield_controller.h" | 20 #include "ui/views/controls/textfield/textfield_controller.h" |
20 | 21 |
21 class EditableProfilePhoto; | 22 class EditableProfilePhoto; |
22 class EditableProfileName; | 23 class EditableProfileName; |
23 | 24 |
(...skipping 13 matching lines...) Expand all Loading... |
37 // This bubble view is displayed when the user clicks on the avatar button. | 38 // This bubble view is displayed when the user clicks on the avatar button. |
38 // It displays a list of profiles and allows users to switch between profiles. | 39 // It displays a list of profiles and allows users to switch between profiles. |
39 class ProfileChooserView : public views::BubbleDelegateView, | 40 class ProfileChooserView : public views::BubbleDelegateView, |
40 public views::ButtonListener, | 41 public views::ButtonListener, |
41 public views::LinkListener, | 42 public views::LinkListener, |
42 public views::StyledLabelListener, | 43 public views::StyledLabelListener, |
43 public views::TextfieldController, | 44 public views::TextfieldController, |
44 public AvatarMenuObserver, | 45 public AvatarMenuObserver, |
45 public OAuth2TokenService::Observer { | 46 public OAuth2TokenService::Observer { |
46 public: | 47 public: |
47 // Different views that can be displayed in the bubble. | |
48 enum BubbleViewMode { | |
49 // Shows a "fast profile switcher" view. | |
50 BUBBLE_VIEW_MODE_PROFILE_CHOOSER, | |
51 // Shows a list of accounts for the active user. | |
52 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, | |
53 // Shows a web view for primary sign in. | |
54 BUBBLE_VIEW_MODE_GAIA_SIGNIN, | |
55 // Shows a web view for adding secondary accounts. | |
56 BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, | |
57 // Shows a web view for reauthenticating an account. | |
58 BUBBLE_VIEW_MODE_GAIA_REAUTH, | |
59 // Shows a view for confirming account removal. | |
60 BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, | |
61 // Shows a view for ending new profile management preview. | |
62 BUBBLE_VIEW_MODE_END_PREVIEW | |
63 }; | |
64 | |
65 enum TutorialMode { | |
66 TUTORIAL_MODE_NONE, // No tutorial card shown. | |
67 TUTORIAL_MODE_ENABLE_PREVIEW, // The enable-mirror-preview tutorial shown. | |
68 TUTORIAL_MODE_PREVIEW_ENABLED, // The welcome-to-mirror tutorial shown. | |
69 TUTORIAL_MODE_SEND_FEEDBACK // The send-feedback tutorial shown. | |
70 }; | |
71 | |
72 // Shows the bubble if one is not already showing. This allows us to easily | 48 // Shows the bubble if one is not already showing. This allows us to easily |
73 // make a button toggle the bubble on and off when clicked: we unconditionally | 49 // make a button toggle the bubble on and off when clicked: we unconditionally |
74 // call this function when the button is clicked and if the bubble isn't | 50 // call this function when the button is clicked and if the bubble isn't |
75 // showing it will appear while if it is showing, nothing will happen here and | 51 // showing it will appear while if it is showing, nothing will happen here and |
76 // the existing bubble will auto-close due to focus loss. | 52 // the existing bubble will auto-close due to focus loss. |
77 static void ShowBubble(BubbleViewMode view_mode, | 53 static void ShowBubble(profiles::BubbleViewMode view_mode, |
78 views::View* anchor_view, | 54 views::View* anchor_view, |
79 views::BubbleBorder::Arrow arrow, | 55 views::BubbleBorder::Arrow arrow, |
80 views::BubbleBorder::BubbleAlignment border_alignment, | 56 views::BubbleBorder::BubbleAlignment border_alignment, |
81 const gfx::Rect& anchor_rect, | 57 const gfx::Rect& anchor_rect, |
82 Browser* browser); | 58 Browser* browser); |
83 static bool IsShowing(); | 59 static bool IsShowing(); |
84 static void Hide(); | 60 static void Hide(); |
85 | 61 |
86 // We normally close the bubble any time it becomes inactive but this can lead | 62 // We normally close the bubble any time it becomes inactive but this can lead |
87 // to flaky tests where unexpected UI events are triggering this behavior. | 63 // to flaky tests where unexpected UI events are triggering this behavior. |
88 // Tests should call this with "false" for more consistent operation. | 64 // Tests should call this with "false" for more consistent operation. |
89 static void clear_close_on_deactivate_for_testing() { | 65 static void clear_close_on_deactivate_for_testing() { |
90 close_on_deactivate_for_testing_ = false; | 66 close_on_deactivate_for_testing_ = false; |
91 } | 67 } |
92 | 68 |
93 private: | 69 private: |
94 friend class NewAvatarMenuButtonTest; | 70 friend class NewAvatarMenuButtonTest; |
95 FRIEND_TEST_ALL_PREFIXES(NewAvatarMenuButtonTest, SignOut); | 71 FRIEND_TEST_ALL_PREFIXES(NewAvatarMenuButtonTest, SignOut); |
96 | 72 |
97 typedef std::vector<size_t> Indexes; | 73 typedef std::vector<size_t> Indexes; |
98 typedef std::map<views::Button*, int> ButtonIndexes; | 74 typedef std::map<views::Button*, int> ButtonIndexes; |
99 typedef std::map<views::Button*, std::string> AccountButtonIndexes; | 75 typedef std::map<views::Button*, std::string> AccountButtonIndexes; |
100 | 76 |
101 ProfileChooserView(views::View* anchor_view, | 77 ProfileChooserView(views::View* anchor_view, |
102 views::BubbleBorder::Arrow arrow, | 78 views::BubbleBorder::Arrow arrow, |
103 const gfx::Rect& anchor_rect, | 79 const gfx::Rect& anchor_rect, |
104 Browser* browser, | 80 Browser* browser, |
105 BubbleViewMode view_mode); | 81 profiles::BubbleViewMode view_mode); |
106 virtual ~ProfileChooserView(); | 82 virtual ~ProfileChooserView(); |
107 | 83 |
108 // views::BubbleDelegateView: | 84 // views::BubbleDelegateView: |
109 virtual void Init() OVERRIDE; | 85 virtual void Init() OVERRIDE; |
110 virtual void WindowClosing() OVERRIDE; | 86 virtual void WindowClosing() OVERRIDE; |
111 | 87 |
112 // views::ButtonListener: | 88 // views::ButtonListener: |
113 virtual void ButtonPressed(views::Button* sender, | 89 virtual void ButtonPressed(views::Button* sender, |
114 const ui::Event& event) OVERRIDE; | 90 const ui::Event& event) OVERRIDE; |
115 | 91 |
(...skipping 14 matching lines...) Expand all Loading... |
130 // OAuth2TokenService::Observer overrides. | 106 // OAuth2TokenService::Observer overrides. |
131 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; | 107 virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; |
132 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE; | 108 virtual void OnRefreshTokenRevoked(const std::string& account_id) OVERRIDE; |
133 | 109 |
134 static ProfileChooserView* profile_bubble_; | 110 static ProfileChooserView* profile_bubble_; |
135 static bool close_on_deactivate_for_testing_; | 111 static bool close_on_deactivate_for_testing_; |
136 | 112 |
137 void ResetView(); | 113 void ResetView(); |
138 | 114 |
139 // Shows the bubble with the |view_to_display|. | 115 // Shows the bubble with the |view_to_display|. |
140 void ShowView(BubbleViewMode view_to_display, | 116 void ShowView(profiles::BubbleViewMode view_to_display, |
141 AvatarMenu* avatar_menu); | 117 AvatarMenu* avatar_menu); |
142 | 118 |
143 // Creates the profile chooser view. |tutorial_shown| indicates if the "mirror | 119 // Creates the profile chooser view. |tutorial_shown| indicates if the "mirror |
144 // enabled" tutorial was shown or not in the last active view. | 120 // enabled" tutorial was shown or not in the last active view. |
145 views::View* CreateProfileChooserView(AvatarMenu* avatar_menu, | 121 views::View* CreateProfileChooserView(AvatarMenu* avatar_menu, |
146 TutorialMode last_tutorial_mode); | 122 profiles::TutorialMode last_tutorial_mode); |
147 | 123 |
148 // Creates the main profile card for the profile |avatar_item|. |is_guest| | 124 // Creates the main profile card for the profile |avatar_item|. |is_guest| |
149 // is used to determine whether to show any Sign in/Sign out/Manage accounts | 125 // is used to determine whether to show any Sign in/Sign out/Manage accounts |
150 // links. | 126 // links. |
151 views::View* CreateCurrentProfileView( | 127 views::View* CreateCurrentProfileView( |
152 const AvatarMenu::Item& avatar_item, | 128 const AvatarMenu::Item& avatar_item, |
153 bool is_guest); | 129 bool is_guest); |
154 views::View* CreateGuestProfileView(); | 130 views::View* CreateGuestProfileView(); |
155 views::View* CreateOtherProfilesView(const Indexes& avatars_to_show); | 131 views::View* CreateOtherProfilesView(const Indexes& avatars_to_show); |
156 views::View* CreateOptionsView(bool enable_lock); | 132 views::View* CreateOptionsView(bool enable_lock); |
(...skipping 30 matching lines...) Expand all Loading... |
187 // Creates a a tutorial card at the top prompting the user to send feedback | 163 // Creates a a tutorial card at the top prompting the user to send feedback |
188 // about the new profile management preview and/or to end preview. | 164 // about the new profile management preview and/or to end preview. |
189 views::View* CreateSendPreviewFeedbackView(); | 165 views::View* CreateSendPreviewFeedbackView(); |
190 | 166 |
191 // Creates a tutorial card with the specified |title_text|, |context_text|, | 167 // Creates a tutorial card with the specified |title_text|, |context_text|, |
192 // and a bottom row with a right-aligned link using the specified |link_text|, | 168 // and a bottom row with a right-aligned link using the specified |link_text|, |
193 // and a left aligned button using the specified |button_text|. The method | 169 // and a left aligned button using the specified |button_text|. The method |
194 // sets |link| to point to the newly created link, |button| to the newly | 170 // sets |link| to point to the newly created link, |button| to the newly |
195 // created button, and |tutorial_mode_| to the given |tutorial_mode|. | 171 // created button, and |tutorial_mode_| to the given |tutorial_mode|. |
196 views::View* CreateTutorialView( | 172 views::View* CreateTutorialView( |
197 TutorialMode tutorial_mode, | 173 profiles::TutorialMode tutorial_mode, |
198 const base::string16& title_text, | 174 const base::string16& title_text, |
199 const base::string16& content_text, | 175 const base::string16& content_text, |
200 const base::string16& link_text, | 176 const base::string16& link_text, |
201 const base::string16& button_text, | 177 const base::string16& button_text, |
202 views::Link** link, | 178 views::Link** link, |
203 views::LabelButton** button); | 179 views::LabelButton** button); |
204 | 180 |
205 views::View* CreateEndPreviewView(); | 181 views::View* CreateEndPreviewView(); |
206 | 182 |
207 scoped_ptr<AvatarMenu> avatar_menu_; | 183 scoped_ptr<AvatarMenu> avatar_menu_; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 views::ImageButton* account_removal_cancel_button_; | 220 views::ImageButton* account_removal_cancel_button_; |
245 | 221 |
246 // Links and buttons displayed in the end-preview view. | 222 // Links and buttons displayed in the end-preview view. |
247 views::LabelButton* end_preview_and_relaunch_button_; | 223 views::LabelButton* end_preview_and_relaunch_button_; |
248 views::ImageButton* end_preview_cancel_button_; | 224 views::ImageButton* end_preview_cancel_button_; |
249 | 225 |
250 // Records the account id to remove. | 226 // Records the account id to remove. |
251 std::string account_id_to_remove_; | 227 std::string account_id_to_remove_; |
252 | 228 |
253 // Active view mode. | 229 // Active view mode. |
254 BubbleViewMode view_mode_; | 230 profiles::BubbleViewMode view_mode_; |
255 | 231 |
256 // The current tutorial mode. | 232 // The current tutorial mode. |
257 TutorialMode tutorial_mode_; | 233 profiles::TutorialMode tutorial_mode_; |
258 | 234 |
259 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); | 235 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); |
260 }; | 236 }; |
261 | 237 |
262 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 238 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
OLD | NEW |