| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "chrome/browser/profiles/avatar_menu.h" | 14 #include "chrome/browser/profiles/avatar_menu.h" |
| 15 #include "chrome/browser/profiles/avatar_menu_observer.h" | 15 #include "chrome/browser/profiles/avatar_menu_observer.h" |
| 16 #include "chrome/browser/profiles/profile_metrics.h" | 16 #include "chrome/browser/profiles/profile_metrics.h" |
| 17 #include "chrome/browser/ui/browser_window.h" | 17 #include "chrome/browser/ui/browser_window.h" |
| 18 #include "chrome/browser/ui/profile_chooser_constants.h" | 18 #include "chrome/browser/ui/profile_chooser_constants.h" |
| 19 #include "components/signin/core/browser/signin_header_helper.h" | 19 #include "components/signin/core/browser/signin_header_helper.h" |
| 20 #include "content/public/browser/web_contents_delegate.h" | 20 #include "content/public/browser/web_contents_delegate.h" |
| 21 #include "google_apis/gaia/oauth2_token_service.h" | 21 #include "google_apis/gaia/oauth2_token_service.h" |
| 22 #include "ui/views/bubble/bubble_dialog_delegate.h" | 22 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 23 #include "ui/views/controls/button/button.h" | 23 #include "ui/views/controls/button/button.h" |
| 24 #include "ui/views/controls/link_listener.h" | 24 #include "ui/views/controls/link_listener.h" |
| 25 #include "ui/views/controls/styled_label_listener.h" | 25 #include "ui/views/controls/styled_label_listener.h" |
| 26 #include "ui/views/controls/textfield/textfield_controller.h" | |
| 27 | |
| 28 class EditableProfilePhoto; | |
| 29 class EditableProfileName; | |
| 30 | 26 |
| 31 namespace views { | 27 namespace views { |
| 32 class GridLayout; | 28 class GridLayout; |
| 33 class ImageButton; | 29 class ImageButton; |
| 34 class Link; | 30 class Link; |
| 35 class LabelButton; | 31 class LabelButton; |
| 36 } | 32 } |
| 37 | 33 |
| 38 class Browser; | 34 class Browser; |
| 39 | 35 |
| 40 // This bubble view is displayed when the user clicks on the avatar button. | 36 // This bubble view is displayed when the user clicks on the avatar button. |
| 41 // It displays a list of profiles and allows users to switch between profiles. | 37 // It displays a list of profiles and allows users to switch between profiles. |
| 42 class ProfileChooserView : public content::WebContentsDelegate, | 38 class ProfileChooserView : public content::WebContentsDelegate, |
| 43 public views::BubbleDialogDelegateView, | 39 public views::BubbleDialogDelegateView, |
| 44 public views::ButtonListener, | 40 public views::ButtonListener, |
| 45 public views::LinkListener, | 41 public views::LinkListener, |
| 46 public views::StyledLabelListener, | 42 public views::StyledLabelListener, |
| 47 public views::TextfieldController, | |
| 48 public AvatarMenuObserver, | 43 public AvatarMenuObserver, |
| 49 public OAuth2TokenService::Observer { | 44 public OAuth2TokenService::Observer { |
| 50 public: | 45 public: |
| 51 // Shows the bubble if one is not already showing. This allows us to easily | 46 // Shows the bubble if one is not already showing. This allows us to easily |
| 52 // make a button toggle the bubble on and off when clicked: we unconditionally | 47 // make a button toggle the bubble on and off when clicked: we unconditionally |
| 53 // call this function when the button is clicked and if the bubble isn't | 48 // call this function when the button is clicked and if the bubble isn't |
| 54 // showing it will appear while if it is showing, nothing will happen here and | 49 // showing it will appear while if it is showing, nothing will happen here and |
| 55 // the existing bubble will auto-close due to focus loss. | 50 // the existing bubble will auto-close due to focus loss. |
| 56 static void ShowBubble( | 51 static void ShowBubble( |
| 57 profiles::BubbleViewMode view_mode, | 52 profiles::BubbleViewMode view_mode, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 90 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 96 | 91 |
| 97 // views::LinkListener: | 92 // views::LinkListener: |
| 98 void LinkClicked(views::Link* sender, int event_flags) override; | 93 void LinkClicked(views::Link* sender, int event_flags) override; |
| 99 | 94 |
| 100 // views::StyledLabelListener: | 95 // views::StyledLabelListener: |
| 101 void StyledLabelLinkClicked(views::StyledLabel* label, | 96 void StyledLabelLinkClicked(views::StyledLabel* label, |
| 102 const gfx::Range& range, | 97 const gfx::Range& range, |
| 103 int event_flags) override; | 98 int event_flags) override; |
| 104 | 99 |
| 105 // views::TextfieldController: | |
| 106 bool HandleKeyEvent(views::Textfield* sender, | |
| 107 const ui::KeyEvent& key_event) override; | |
| 108 | |
| 109 // AvatarMenuObserver: | 100 // AvatarMenuObserver: |
| 110 void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override; | 101 void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override; |
| 111 | 102 |
| 112 // OAuth2TokenService::Observer overrides. | 103 // OAuth2TokenService::Observer overrides. |
| 113 void OnRefreshTokenAvailable(const std::string& account_id) override; | 104 void OnRefreshTokenAvailable(const std::string& account_id) override; |
| 114 void OnRefreshTokenRevoked(const std::string& account_id) override; | 105 void OnRefreshTokenRevoked(const std::string& account_id) override; |
| 115 | 106 |
| 116 static ProfileChooserView* profile_bubble_; | 107 static ProfileChooserView* profile_bubble_; |
| 117 | 108 |
| 118 // We normally close the bubble any time it becomes inactive but this can lead | 109 // We normally close the bubble any time it becomes inactive but this can lead |
| (...skipping 17 matching lines...) Expand all Loading... |
| 136 AvatarMenu* avatar_menu); | 127 AvatarMenu* avatar_menu); |
| 137 | 128 |
| 138 // Populates |layout| with all the elements of the Avatar Menu (current user | 129 // Populates |layout| with all the elements of the Avatar Menu (current user |
| 139 // bubble, options buttons, tutorials). | 130 // bubble, options buttons, tutorials). |
| 140 void PopulateCompleteProfileChooserView(views::GridLayout* layout, | 131 void PopulateCompleteProfileChooserView(views::GridLayout* layout, |
| 141 AvatarMenu* avatar_menu); | 132 AvatarMenu* avatar_menu); |
| 142 | 133 |
| 143 // Creates the main profile card for the profile |avatar_item|. |is_guest| | 134 // Creates the main profile card for the profile |avatar_item|. |is_guest| |
| 144 // is used to determine whether to show any Sign in/Sign out/Manage accounts | 135 // is used to determine whether to show any Sign in/Sign out/Manage accounts |
| 145 // links. | 136 // links. |
| 146 views::View* CreateCurrentProfileView( | |
| 147 const AvatarMenu::Item& avatar_item, | |
| 148 bool is_guest); | |
| 149 views::View* CreateMaterialDesignCurrentProfileView( | 137 views::View* CreateMaterialDesignCurrentProfileView( |
| 150 const AvatarMenu::Item& avatar_item, | 138 const AvatarMenu::Item& avatar_item, |
| 151 bool is_guest); | 139 bool is_guest); |
| 152 views::View* CreateGuestProfileView(); | 140 views::View* CreateGuestProfileView(); |
| 153 views::View* CreateOtherProfilesView(const Indexes& avatars_to_show); | 141 views::View* CreateOtherProfilesView(const Indexes& avatars_to_show); |
| 154 views::View* CreateOptionsView(bool display_lock, AvatarMenu* avatar_menu); | 142 views::View* CreateOptionsView(bool display_lock, AvatarMenu* avatar_menu); |
| 155 views::View* CreateSupervisedUserDisclaimerView(); | 143 views::View* CreateSupervisedUserDisclaimerView(); |
| 156 | 144 |
| 157 // Account Management view for the profile |avatar_item|. | 145 // Account Management view for the profile |avatar_item|. |
| 158 views::View* CreateCurrentProfileAccountsView( | 146 views::View* CreateCurrentProfileAccountsView( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 views::LabelButton* sync_error_upgrade_button_; | 233 views::LabelButton* sync_error_upgrade_button_; |
| 246 views::LabelButton* sync_error_signin_again_button_; | 234 views::LabelButton* sync_error_signin_again_button_; |
| 247 views::LabelButton* sync_error_signout_button_; | 235 views::LabelButton* sync_error_signout_button_; |
| 248 | 236 |
| 249 // Links and buttons displayed in the active profile card. | 237 // Links and buttons displayed in the active profile card. |
| 250 views::Link* manage_accounts_link_; | 238 views::Link* manage_accounts_link_; |
| 251 views::LabelButton* manage_accounts_button_; | 239 views::LabelButton* manage_accounts_button_; |
| 252 views::LabelButton* signin_current_profile_button_; | 240 views::LabelButton* signin_current_profile_button_; |
| 253 views::LabelButton* auth_error_email_button_; | 241 views::LabelButton* auth_error_email_button_; |
| 254 | 242 |
| 255 // The profile name and photo in the active profile card in non-material- | |
| 256 // design user menu. Owned by the views hierarchy. | |
| 257 EditableProfilePhoto* current_profile_photo_; | |
| 258 EditableProfileName* current_profile_name_; | |
| 259 // For material design user menu, the active profile card owns the profile | 243 // For material design user menu, the active profile card owns the profile |
| 260 // name and photo. | 244 // name and photo. |
| 261 views::LabelButton* current_profile_card_; | 245 views::LabelButton* current_profile_card_; |
| 262 | 246 |
| 263 // Action buttons. | 247 // Action buttons. |
| 264 views::LabelButton* guest_profile_button_; | 248 views::LabelButton* guest_profile_button_; |
| 265 views::LabelButton* users_button_; | 249 views::LabelButton* users_button_; |
| 266 views::LabelButton* go_incognito_button_; | 250 views::LabelButton* go_incognito_button_; |
| 267 views::LabelButton* lock_button_; | 251 views::LabelButton* lock_button_; |
| 268 views::LabelButton* close_all_windows_button_; | 252 views::LabelButton* close_all_windows_button_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 292 // The GAIA service type provided in the response header. | 276 // The GAIA service type provided in the response header. |
| 293 signin::GAIAServiceType gaia_service_type_; | 277 signin::GAIAServiceType gaia_service_type_; |
| 294 | 278 |
| 295 // The current access point of sign in. | 279 // The current access point of sign in. |
| 296 const signin_metrics::AccessPoint access_point_; | 280 const signin_metrics::AccessPoint access_point_; |
| 297 | 281 |
| 298 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); | 282 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); |
| 299 }; | 283 }; |
| 300 | 284 |
| 301 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 285 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
| OLD | NEW |