| 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/profiles/profile_metrics.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/profile_chooser_constants.h" | 15 #include "chrome/browser/ui/profile_chooser_constants.h" |
| 15 #include "google_apis/gaia/oauth2_token_service.h" | 16 #include "google_apis/gaia/oauth2_token_service.h" |
| 16 #include "ui/views/bubble/bubble_delegate.h" | 17 #include "ui/views/bubble/bubble_delegate.h" |
| 17 #include "ui/views/controls/button/button.h" | 18 #include "ui/views/controls/button/button.h" |
| 18 #include "ui/views/controls/link_listener.h" | 19 #include "ui/views/controls/link_listener.h" |
| 19 #include "ui/views/controls/styled_label_listener.h" | 20 #include "ui/views/controls/styled_label_listener.h" |
| 20 #include "ui/views/controls/textfield/textfield_controller.h" | 21 #include "ui/views/controls/textfield/textfield_controller.h" |
| 21 | 22 |
| 22 class EditableProfilePhoto; | 23 class EditableProfilePhoto; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 44 public views::TextfieldController, | 45 public views::TextfieldController, |
| 45 public AvatarMenuObserver, | 46 public AvatarMenuObserver, |
| 46 public OAuth2TokenService::Observer { | 47 public OAuth2TokenService::Observer { |
| 47 public: | 48 public: |
| 48 // Shows the bubble if one is not already showing. This allows us to easily | 49 // Shows the bubble if one is not already showing. This allows us to easily |
| 49 // make a button toggle the bubble on and off when clicked: we unconditionally | 50 // make a button toggle the bubble on and off when clicked: we unconditionally |
| 50 // call this function when the button is clicked and if the bubble isn't | 51 // call this function when the button is clicked and if the bubble isn't |
| 51 // showing it will appear while if it is showing, nothing will happen here and | 52 // showing it will appear while if it is showing, nothing will happen here and |
| 52 // the existing bubble will auto-close due to focus loss. | 53 // the existing bubble will auto-close due to focus loss. |
| 53 static void ShowBubble(profiles::BubbleViewMode view_mode, | 54 static void ShowBubble(profiles::BubbleViewMode view_mode, |
| 55 signin::GAIAServiceType service_type, |
| 54 views::View* anchor_view, | 56 views::View* anchor_view, |
| 55 views::BubbleBorder::Arrow arrow, | 57 views::BubbleBorder::Arrow arrow, |
| 56 views::BubbleBorder::BubbleAlignment border_alignment, | 58 views::BubbleBorder::BubbleAlignment border_alignment, |
| 57 const gfx::Rect& anchor_rect, | 59 const gfx::Rect& anchor_rect, |
| 58 Browser* browser); | 60 Browser* browser); |
| 59 static bool IsShowing(); | 61 static bool IsShowing(); |
| 60 static void Hide(); | 62 static void Hide(); |
| 61 | 63 |
| 62 // We normally close the bubble any time it becomes inactive but this can lead | 64 // We normally close the bubble any time it becomes inactive but this can lead |
| 63 // to flaky tests where unexpected UI events are triggering this behavior. | 65 // to flaky tests where unexpected UI events are triggering this behavior. |
| 64 // Tests should call this with "false" for more consistent operation. | 66 // Tests should call this with "false" for more consistent operation. |
| 65 static void clear_close_on_deactivate_for_testing() { | 67 static void clear_close_on_deactivate_for_testing() { |
| 66 close_on_deactivate_for_testing_ = false; | 68 close_on_deactivate_for_testing_ = false; |
| 67 } | 69 } |
| 68 | 70 |
| 69 private: | 71 private: |
| 70 friend class NewAvatarMenuButtonTest; | 72 friend class NewAvatarMenuButtonTest; |
| 71 FRIEND_TEST_ALL_PREFIXES(NewAvatarMenuButtonTest, SignOut); | 73 FRIEND_TEST_ALL_PREFIXES(NewAvatarMenuButtonTest, SignOut); |
| 72 | 74 |
| 73 typedef std::vector<size_t> Indexes; | 75 typedef std::vector<size_t> Indexes; |
| 74 typedef std::map<views::Button*, int> ButtonIndexes; | 76 typedef std::map<views::Button*, int> ButtonIndexes; |
| 75 typedef std::map<views::Button*, std::string> AccountButtonIndexes; | 77 typedef std::map<views::Button*, std::string> AccountButtonIndexes; |
| 76 | 78 |
| 77 ProfileChooserView(views::View* anchor_view, | 79 ProfileChooserView(views::View* anchor_view, |
| 78 views::BubbleBorder::Arrow arrow, | 80 views::BubbleBorder::Arrow arrow, |
| 79 const gfx::Rect& anchor_rect, | 81 const gfx::Rect& anchor_rect, |
| 80 Browser* browser, | 82 Browser* browser, |
| 81 profiles::BubbleViewMode view_mode); | 83 profiles::BubbleViewMode view_mode, |
| 84 signin::GAIAServiceType service_type); |
| 82 virtual ~ProfileChooserView(); | 85 virtual ~ProfileChooserView(); |
| 83 | 86 |
| 84 // views::BubbleDelegateView: | 87 // views::BubbleDelegateView: |
| 85 virtual void Init() OVERRIDE; | 88 virtual void Init() OVERRIDE; |
| 86 virtual void WindowClosing() OVERRIDE; | 89 virtual void WindowClosing() OVERRIDE; |
| 87 | 90 |
| 88 // views::ButtonListener: | 91 // views::ButtonListener: |
| 89 virtual void ButtonPressed(views::Button* sender, | 92 virtual void ButtonPressed(views::Button* sender, |
| 90 const ui::Event& event) OVERRIDE; | 93 const ui::Event& event) OVERRIDE; |
| 91 | 94 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 profiles::TutorialMode tutorial_mode, | 176 profiles::TutorialMode tutorial_mode, |
| 174 const base::string16& title_text, | 177 const base::string16& title_text, |
| 175 const base::string16& content_text, | 178 const base::string16& content_text, |
| 176 const base::string16& link_text, | 179 const base::string16& link_text, |
| 177 const base::string16& button_text, | 180 const base::string16& button_text, |
| 178 views::Link** link, | 181 views::Link** link, |
| 179 views::LabelButton** button); | 182 views::LabelButton** button); |
| 180 | 183 |
| 181 views::View* CreateEndPreviewView(); | 184 views::View* CreateEndPreviewView(); |
| 182 | 185 |
| 186 // Clean-up done after an action was performed in the ProfileChooser. |
| 187 void PostActionPerformed(ProfileMetrics::ProfileDesktopMenu action_performed); |
| 188 |
| 183 scoped_ptr<AvatarMenu> avatar_menu_; | 189 scoped_ptr<AvatarMenu> avatar_menu_; |
| 184 Browser* browser_; | 190 Browser* browser_; |
| 185 | 191 |
| 186 // Other profiles used in the "fast profile switcher" view. | 192 // Other profiles used in the "fast profile switcher" view. |
| 187 ButtonIndexes open_other_profile_indexes_map_; | 193 ButtonIndexes open_other_profile_indexes_map_; |
| 188 | 194 |
| 189 // Buttons associated with the current profile. | 195 // Buttons associated with the current profile. |
| 190 AccountButtonIndexes delete_account_button_map_; | 196 AccountButtonIndexes delete_account_button_map_; |
| 191 AccountButtonIndexes reauth_account_button_map_; | 197 AccountButtonIndexes reauth_account_button_map_; |
| 192 | 198 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 231 |
| 226 // Records the account id to remove. | 232 // Records the account id to remove. |
| 227 std::string account_id_to_remove_; | 233 std::string account_id_to_remove_; |
| 228 | 234 |
| 229 // Active view mode. | 235 // Active view mode. |
| 230 profiles::BubbleViewMode view_mode_; | 236 profiles::BubbleViewMode view_mode_; |
| 231 | 237 |
| 232 // The current tutorial mode. | 238 // The current tutorial mode. |
| 233 profiles::TutorialMode tutorial_mode_; | 239 profiles::TutorialMode tutorial_mode_; |
| 234 | 240 |
| 241 // The GAIA service type provided in the response header. |
| 242 signin::GAIAServiceType gaia_service_type_; |
| 243 |
| 235 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); | 244 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); |
| 236 }; | 245 }; |
| 237 | 246 |
| 238 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 247 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
| OLD | NEW |