| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 void ButtonPressed(views::Button* sender, const ui::Event& event) override; | 91 void ButtonPressed(views::Button* sender, const ui::Event& event) override; |
| 97 | 92 |
| 98 // views::LinkListener: | 93 // views::LinkListener: |
| 99 void LinkClicked(views::Link* sender, int event_flags) override; | 94 void LinkClicked(views::Link* sender, int event_flags) override; |
| 100 | 95 |
| 101 // views::StyledLabelListener: | 96 // views::StyledLabelListener: |
| 102 void StyledLabelLinkClicked(views::StyledLabel* label, | 97 void StyledLabelLinkClicked(views::StyledLabel* label, |
| 103 const gfx::Range& range, | 98 const gfx::Range& range, |
| 104 int event_flags) override; | 99 int event_flags) override; |
| 105 | 100 |
| 106 // views::TextfieldController: | |
| 107 bool HandleKeyEvent(views::Textfield* sender, | |
| 108 const ui::KeyEvent& key_event) override; | |
| 109 | |
| 110 // AvatarMenuObserver: | 101 // AvatarMenuObserver: |
| 111 void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override; | 102 void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override; |
| 112 | 103 |
| 113 // OAuth2TokenService::Observer overrides. | 104 // OAuth2TokenService::Observer overrides. |
| 114 void OnRefreshTokenAvailable(const std::string& account_id) override; | 105 void OnRefreshTokenAvailable(const std::string& account_id) override; |
| 115 void OnRefreshTokenRevoked(const std::string& account_id) override; | 106 void OnRefreshTokenRevoked(const std::string& account_id) override; |
| 116 | 107 |
| 117 static ProfileChooserView* profile_bubble_; | 108 static ProfileChooserView* profile_bubble_; |
| 118 | 109 |
| 119 // We normally close the bubble any time it becomes inactive but this can lead | 110 // We normally close the bubble any time it becomes inactive but this can lead |
| (...skipping 23 matching lines...) Expand all Loading... |
| 143 // bubble, options buttons, tutorials). | 134 // bubble, options buttons, tutorials). |
| 144 void PopulateCompleteProfileChooserView(views::GridLayout* layout, | 135 void PopulateCompleteProfileChooserView(views::GridLayout* layout, |
| 145 AvatarMenu* avatar_menu); | 136 AvatarMenu* avatar_menu); |
| 146 | 137 |
| 147 // Creates the main profile card for the profile |avatar_item|. |is_guest| | 138 // Creates the main profile card for the profile |avatar_item|. |is_guest| |
| 148 // is used to determine whether to show any Sign in/Sign out/Manage accounts | 139 // is used to determine whether to show any Sign in/Sign out/Manage accounts |
| 149 // links. | 140 // links. |
| 150 views::View* CreateCurrentProfileView( | 141 views::View* CreateCurrentProfileView( |
| 151 const AvatarMenu::Item& avatar_item, | 142 const AvatarMenu::Item& avatar_item, |
| 152 bool is_guest); | 143 bool is_guest); |
| 153 views::View* CreateMaterialDesignCurrentProfileView( | |
| 154 const AvatarMenu::Item& avatar_item, | |
| 155 bool is_guest); | |
| 156 views::View* CreateGuestProfileView(); | 144 views::View* CreateGuestProfileView(); |
| 157 views::View* CreateOtherProfilesView(const Indexes& avatars_to_show); | 145 views::View* CreateOtherProfilesView(const Indexes& avatars_to_show); |
| 158 views::View* CreateOptionsView(bool display_lock, AvatarMenu* avatar_menu); | 146 views::View* CreateOptionsView(bool display_lock, AvatarMenu* avatar_menu); |
| 159 views::View* CreateSupervisedUserDisclaimerView(); | 147 views::View* CreateSupervisedUserDisclaimerView(); |
| 160 | 148 |
| 161 // Account Management view for the profile |avatar_item|. | 149 // Account Management view for the profile |avatar_item|. |
| 162 views::View* CreateCurrentProfileAccountsView( | 150 views::View* CreateCurrentProfileAccountsView( |
| 163 const AvatarMenu::Item& avatar_item); | 151 const AvatarMenu::Item& avatar_item); |
| 164 void CreateAccountButton(views::GridLayout* layout, | 152 void CreateAccountButton(views::GridLayout* layout, |
| 165 const std::string& account_id, | 153 const std::string& account_id, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 views::LabelButton* sync_error_upgrade_button_; | 237 views::LabelButton* sync_error_upgrade_button_; |
| 250 views::LabelButton* sync_error_signin_again_button_; | 238 views::LabelButton* sync_error_signin_again_button_; |
| 251 views::LabelButton* sync_error_signout_button_; | 239 views::LabelButton* sync_error_signout_button_; |
| 252 | 240 |
| 253 // Links and buttons displayed in the active profile card. | 241 // Links and buttons displayed in the active profile card. |
| 254 views::Link* manage_accounts_link_; | 242 views::Link* manage_accounts_link_; |
| 255 views::LabelButton* manage_accounts_button_; | 243 views::LabelButton* manage_accounts_button_; |
| 256 views::LabelButton* signin_current_profile_button_; | 244 views::LabelButton* signin_current_profile_button_; |
| 257 views::LabelButton* auth_error_email_button_; | 245 views::LabelButton* auth_error_email_button_; |
| 258 | 246 |
| 259 // The profile name and photo in the active profile card in non-material- | |
| 260 // design user menu. Owned by the views hierarchy. | |
| 261 EditableProfilePhoto* current_profile_photo_; | |
| 262 EditableProfileName* current_profile_name_; | |
| 263 // For material design user menu, the active profile card owns the profile | 247 // For material design user menu, the active profile card owns the profile |
| 264 // name and photo. | 248 // name and photo. |
| 265 views::LabelButton* current_profile_card_; | 249 views::LabelButton* current_profile_card_; |
| 266 | 250 |
| 267 // Action buttons. | 251 // Action buttons. |
| 268 views::LabelButton* first_profile_button_; | 252 views::LabelButton* first_profile_button_; |
| 269 views::LabelButton* guest_profile_button_; | 253 views::LabelButton* guest_profile_button_; |
| 270 views::LabelButton* users_button_; | 254 views::LabelButton* users_button_; |
| 271 views::LabelButton* go_incognito_button_; | 255 views::LabelButton* go_incognito_button_; |
| 272 views::LabelButton* lock_button_; | 256 views::LabelButton* lock_button_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 297 // The GAIA service type provided in the response header. | 281 // The GAIA service type provided in the response header. |
| 298 signin::GAIAServiceType gaia_service_type_; | 282 signin::GAIAServiceType gaia_service_type_; |
| 299 | 283 |
| 300 // The current access point of sign in. | 284 // The current access point of sign in. |
| 301 const signin_metrics::AccessPoint access_point_; | 285 const signin_metrics::AccessPoint access_point_; |
| 302 | 286 |
| 303 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); | 287 DISALLOW_COPY_AND_ASSIGN(ProfileChooserView); |
| 304 }; | 288 }; |
| 305 | 289 |
| 306 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ | 290 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_CHOOSER_VIEW_H_ |
| OLD | NEW |