| 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/profiles/profile_metrics.h" |
| 14 #include "chrome/browser/ui/browser_list_observer.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/profile_chooser_constants.h" | 16 #include "chrome/browser/ui/profile_chooser_constants.h" |
| 16 #include "components/signin/core/browser/signin_header_helper.h" | 17 #include "components/signin/core/browser/signin_header_helper.h" |
| 17 #include "content/public/browser/web_contents_delegate.h" | 18 #include "content/public/browser/web_contents_delegate.h" |
| 18 #include "google_apis/gaia/oauth2_token_service.h" | 19 #include "google_apis/gaia/oauth2_token_service.h" |
| 19 #include "ui/views/bubble/bubble_delegate.h" | 20 #include "ui/views/bubble/bubble_delegate.h" |
| 20 #include "ui/views/controls/button/button.h" | 21 #include "ui/views/controls/button/button.h" |
| 21 #include "ui/views/controls/link_listener.h" | 22 #include "ui/views/controls/link_listener.h" |
| 22 #include "ui/views/controls/styled_label_listener.h" | 23 #include "ui/views/controls/styled_label_listener.h" |
| 23 #include "ui/views/controls/textfield/textfield_controller.h" | 24 #include "ui/views/controls/textfield/textfield_controller.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 40 | 41 |
| 41 // This bubble view is displayed when the user clicks on the avatar button. | 42 // This bubble view is displayed when the user clicks on the avatar button. |
| 42 // It displays a list of profiles and allows users to switch between profiles. | 43 // It displays a list of profiles and allows users to switch between profiles. |
| 43 class ProfileChooserView : public content::WebContentsDelegate, | 44 class ProfileChooserView : public content::WebContentsDelegate, |
| 44 public views::BubbleDelegateView, | 45 public views::BubbleDelegateView, |
| 45 public views::ButtonListener, | 46 public views::ButtonListener, |
| 46 public views::LinkListener, | 47 public views::LinkListener, |
| 47 public views::StyledLabelListener, | 48 public views::StyledLabelListener, |
| 48 public views::TextfieldController, | 49 public views::TextfieldController, |
| 49 public AvatarMenuObserver, | 50 public AvatarMenuObserver, |
| 50 public OAuth2TokenService::Observer { | 51 public OAuth2TokenService::Observer, |
| 52 public chrome::BrowserListObserver { |
| 51 public: | 53 public: |
| 52 // Shows the bubble if one is not already showing. This allows us to easily | 54 // Shows the bubble if one is not already showing. This allows us to easily |
| 53 // make a button toggle the bubble on and off when clicked: we unconditionally | 55 // make a button toggle the bubble on and off when clicked: we unconditionally |
| 54 // call this function when the button is clicked and if the bubble isn't | 56 // call this function when the button is clicked and if the bubble isn't |
| 55 // showing it will appear while if it is showing, nothing will happen here and | 57 // showing it will appear while if it is showing, nothing will happen here and |
| 56 // the existing bubble will auto-close due to focus loss. | 58 // the existing bubble will auto-close due to focus loss. |
| 57 static void ShowBubble( | 59 static void ShowBubble( |
| 58 profiles::BubbleViewMode view_mode, | 60 profiles::BubbleViewMode view_mode, |
| 59 profiles::TutorialMode tutorial_mode, | 61 profiles::TutorialMode tutorial_mode, |
| 60 const signin::ManageAccountsParams& manage_accounts_params, | 62 const signin::ManageAccountsParams& manage_accounts_params, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 bool HandleKeyEvent(views::Textfield* sender, | 105 bool HandleKeyEvent(views::Textfield* sender, |
| 104 const ui::KeyEvent& key_event) override; | 106 const ui::KeyEvent& key_event) override; |
| 105 | 107 |
| 106 // AvatarMenuObserver: | 108 // AvatarMenuObserver: |
| 107 void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override; | 109 void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override; |
| 108 | 110 |
| 109 // OAuth2TokenService::Observer overrides. | 111 // OAuth2TokenService::Observer overrides. |
| 110 void OnRefreshTokenAvailable(const std::string& account_id) override; | 112 void OnRefreshTokenAvailable(const std::string& account_id) override; |
| 111 void OnRefreshTokenRevoked(const std::string& account_id) override; | 113 void OnRefreshTokenRevoked(const std::string& account_id) override; |
| 112 | 114 |
| 115 // chrome::BrowserListObserver overrides: |
| 116 void OnBrowserRemoved(Browser* browser) override; |
| 117 |
| 113 static ProfileChooserView* profile_bubble_; | 118 static ProfileChooserView* profile_bubble_; |
| 114 | 119 |
| 115 // We normally close the bubble any time it becomes inactive but this can lead | 120 // We normally close the bubble any time it becomes inactive but this can lead |
| 116 // to flaky tests where unexpected UI events are triggering this behavior. | 121 // to flaky tests where unexpected UI events are triggering this behavior. |
| 117 // Tests set this to "false" for more consistent operation. | 122 // Tests set this to "false" for more consistent operation. |
| 118 static bool close_on_deactivate_for_testing_; | 123 static bool close_on_deactivate_for_testing_; |
| 119 | 124 |
| 120 void ResetView(); | 125 void ResetView(); |
| 121 | 126 |
| 122 // Shows the bubble with the |view_to_display|. | 127 // Shows the bubble with the |view_to_display|. |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // The current tutorial mode. | 271 // The current tutorial mode. |
| 267 profiles::TutorialMode tutorial_mode_; | 272 profiles::TutorialMode tutorial_mode_; |
| 268 | 273 |
| 269 // The GAIA service type provided in the response header. | 274 // The GAIA service type provided in the response header. |
| 270 signin::GAIAServiceType gaia_service_type_; | 275 signin::GAIAServiceType gaia_service_type_; |
| 271 | 276 |
| 272 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); | 277 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); |
| 273 }; | 278 }; |
| 274 | 279 |
| 275 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 280 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
| OLD | NEW |