| 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 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" | 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/lifetime/application_lifetime.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
| 11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 12 #include "chrome/browser/profiles/profile_info_cache.h" | 12 #include "chrome/browser/profiles/profile_info_cache.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/profiles/profile_metrics.h" | 14 #include "chrome/browser/profiles/profile_metrics.h" |
| 15 #include "chrome/browser/profiles/profile_window.h" | 15 #include "chrome/browser/profiles/profile_window.h" |
| 16 #include "chrome/browser/profiles/profiles_state.h" | 16 #include "chrome/browser/profiles/profiles_state.h" |
| 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 18 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
| 19 #include "chrome/browser/signin/signin_promo.h" | 19 #include "chrome/browser/signin/signin_promo.h" |
| 20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
| 21 #include "chrome/browser/ui/browser_commands.h" | 21 #include "chrome/browser/ui/browser_commands.h" |
| 22 #include "chrome/browser/ui/browser_dialogs.h" | 22 #include "chrome/browser/ui/browser_dialogs.h" |
| 23 #include "chrome/browser/ui/chrome_pages.h" | 23 #include "chrome/browser/ui/chrome_pages.h" |
| 24 #include "chrome/browser/ui/singleton_tabs.h" | 24 #include "chrome/browser/ui/singleton_tabs.h" |
| 25 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 25 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
| 26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" | 28 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" |
| 29 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 29 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 30 #include "components/signin/core/browser/signin_error_controller.h" |
| 30 #include "components/signin/core/browser/signin_manager.h" | 31 #include "components/signin/core/browser/signin_manager.h" |
| 31 #include "components/signin/core/common/profile_management_switches.h" | 32 #include "components/signin/core/common/profile_management_switches.h" |
| 32 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
| 33 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
| 34 #include "grit/theme_resources.h" | 35 #include "grit/theme_resources.h" |
| 35 #include "third_party/skia/include/core/SkColor.h" | 36 #include "third_party/skia/include/core/SkColor.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "ui/base/resource/resource_bundle.h" | 38 #include "ui/base/resource/resource_bundle.h" |
| 38 #include "ui/gfx/canvas.h" | 39 #include "ui/gfx/canvas.h" |
| 39 #include "ui/gfx/image/image.h" | 40 #include "ui/gfx/image/image.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 90 } |
| 90 | 91 |
| 91 gfx::ImageSkia CreateSquarePlaceholderImage(int size) { | 92 gfx::ImageSkia CreateSquarePlaceholderImage(int size) { |
| 92 SkBitmap bitmap; | 93 SkBitmap bitmap; |
| 93 bitmap.setConfig(SkBitmap::kA8_Config, size, size); | 94 bitmap.setConfig(SkBitmap::kA8_Config, size, size); |
| 94 bitmap.allocPixels(); | 95 bitmap.allocPixels(); |
| 95 bitmap.eraseARGB(0, 0, 0, 0); | 96 bitmap.eraseARGB(0, 0, 0, 0); |
| 96 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 97 return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| 97 } | 98 } |
| 98 | 99 |
| 100 bool HasAuthError(Profile* profile) { |
| 101 SigninErrorController* error = |
| 102 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> |
| 103 signin_error_controller(); |
| 104 return error && error->HasError(); |
| 105 } |
| 106 |
| 107 std::string GetAuthErrorAccountId(Profile* profile) { |
| 108 SigninErrorController* error = |
| 109 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> |
| 110 signin_error_controller(); |
| 111 if (!error) |
| 112 return std::string(); |
| 113 |
| 114 return error->error_account_id(); |
| 115 } |
| 116 |
| 117 std::string GetAuthErrorUsername(Profile* profile) { |
| 118 SigninErrorController* error = |
| 119 ProfileOAuth2TokenServiceFactory::GetForProfile(profile)-> |
| 120 signin_error_controller(); |
| 121 if (!error) |
| 122 return std::string(); |
| 123 |
| 124 return error->error_username(); |
| 125 } |
| 126 |
| 99 // BackgroundColorHoverButton ------------------------------------------------- | 127 // BackgroundColorHoverButton ------------------------------------------------- |
| 100 | 128 |
| 101 // A custom button that allows for setting a background color when hovered over. | 129 // A custom button that allows for setting a background color when hovered over. |
| 102 class BackgroundColorHoverButton : public views::LabelButton { | 130 class BackgroundColorHoverButton : public views::LabelButton { |
| 103 public: | 131 public: |
| 104 BackgroundColorHoverButton(views::ButtonListener* listener, | 132 BackgroundColorHoverButton(views::ButtonListener* listener, |
| 105 const base::string16& text, | 133 const base::string16& text, |
| 106 const gfx::ImageSkia& normal_icon, | 134 const gfx::ImageSkia& normal_icon, |
| 107 const gfx::ImageSkia& hover_icon); | 135 const gfx::ImageSkia& hover_icon); |
| 108 virtual ~BackgroundColorHoverButton(); | 136 virtual ~BackgroundColorHoverButton(); |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 tutorial_learn_more_link_ = NULL; | 488 tutorial_learn_more_link_ = NULL; |
| 461 tutorial_enable_new_profile_management_button_ = NULL; | 489 tutorial_enable_new_profile_management_button_ = NULL; |
| 462 tutorial_end_preview_link_ = NULL; | 490 tutorial_end_preview_link_ = NULL; |
| 463 tutorial_send_feedback_button_ = NULL; | 491 tutorial_send_feedback_button_ = NULL; |
| 464 end_preview_and_relaunch_button_ = NULL; | 492 end_preview_and_relaunch_button_ = NULL; |
| 465 end_preview_cancel_button_ = NULL; | 493 end_preview_cancel_button_ = NULL; |
| 466 remove_account_button_ = NULL; | 494 remove_account_button_ = NULL; |
| 467 account_removal_cancel_button_ = NULL; | 495 account_removal_cancel_button_ = NULL; |
| 468 gaia_signin_cancel_button_ = NULL; | 496 gaia_signin_cancel_button_ = NULL; |
| 469 open_other_profile_indexes_map_.clear(); | 497 open_other_profile_indexes_map_.clear(); |
| 470 current_profile_accounts_map_.clear(); | 498 delete_account_button_map_.clear(); |
| 499 reauth_account_button_map_.clear(); |
| 471 tutorial_mode_ = TUTORIAL_MODE_NONE; | 500 tutorial_mode_ = TUTORIAL_MODE_NONE; |
| 472 } | 501 } |
| 473 | 502 |
| 474 void ProfileChooserView::Init() { | 503 void ProfileChooserView::Init() { |
| 504 // If view mode is PROFILE_CHOOSER but there is an auth error, force |
| 505 // ACCOUNT_MANAGEMENT mode. |
| 506 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER && |
| 507 HasAuthError(browser_->profile())) { |
| 508 view_mode_ = BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; |
| 509 } |
| 510 |
| 475 ShowView(view_mode_, avatar_menu_.get()); | 511 ShowView(view_mode_, avatar_menu_.get()); |
| 476 } | 512 } |
| 477 | 513 |
| 478 void ProfileChooserView::OnAvatarMenuChanged( | 514 void ProfileChooserView::OnAvatarMenuChanged( |
| 479 AvatarMenu* avatar_menu) { | 515 AvatarMenu* avatar_menu) { |
| 480 // Refresh the view with the new menu. We can't just update the local copy | 516 // Refresh the view with the new menu. We can't just update the local copy |
| 481 // as this may have been triggered by a sign out action, in which case | 517 // as this may have been triggered by a sign out action, in which case |
| 482 // the view is being destroyed. | 518 // the view is being destroyed. |
| 483 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu); | 519 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu); |
| 484 } | 520 } |
| 485 | 521 |
| 486 void ProfileChooserView::OnRefreshTokenAvailable( | 522 void ProfileChooserView::OnRefreshTokenAvailable( |
| 487 const std::string& account_id) { | 523 const std::string& account_id) { |
| 488 // Refresh the account management view when a new account is added to the | 524 // Refresh the account management view when a new account is added to the |
| 489 // profile. | 525 // profile. |
| 490 if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || | 526 if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || |
| 491 view_mode_ == BUBBLE_VIEW_MODE_GAIA_SIGNIN || | 527 view_mode_ == BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
| 492 view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) { | 528 view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
| 529 view_mode_ == BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
| 493 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 530 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
| 494 } | 531 } |
| 495 } | 532 } |
| 496 | 533 |
| 497 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { | 534 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { |
| 498 // Refresh the account management view when an account is removed from the | 535 // Refresh the account management view when an account is removed from the |
| 499 // profile. | 536 // profile. |
| 500 if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) | 537 if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) |
| 501 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 538 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
| 502 } | 539 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 515 TutorialMode last_tutorial_mode = tutorial_mode_; | 552 TutorialMode last_tutorial_mode = tutorial_mode_; |
| 516 ResetView(); | 553 ResetView(); |
| 517 RemoveAllChildViews(true); | 554 RemoveAllChildViews(true); |
| 518 view_mode_ = view_to_display; | 555 view_mode_ = view_to_display; |
| 519 | 556 |
| 520 views::GridLayout* layout; | 557 views::GridLayout* layout; |
| 521 views::View* sub_view; | 558 views::View* sub_view; |
| 522 switch (view_mode_) { | 559 switch (view_mode_) { |
| 523 case BUBBLE_VIEW_MODE_GAIA_SIGNIN: | 560 case BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
| 524 case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: | 561 case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
| 562 case BUBBLE_VIEW_MODE_GAIA_REAUTH: |
| 525 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); | 563 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); |
| 526 sub_view = CreateGaiaSigninView( | 564 sub_view = CreateGaiaSigninView(); |
| 527 view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); | |
| 528 break; | 565 break; |
| 529 case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: | 566 case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
| 530 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); | 567 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); |
| 531 sub_view = CreateAccountRemovalView(); | 568 sub_view = CreateAccountRemovalView(); |
| 532 break; | 569 break; |
| 533 case BUBBLE_VIEW_MODE_END_PREVIEW: | 570 case BUBBLE_VIEW_MODE_END_PREVIEW: |
| 534 layout = CreateSingleColumnLayout(this, kFixedEndPreviewViewWidth); | 571 layout = CreateSingleColumnLayout(this, kFixedEndPreviewViewWidth); |
| 535 sub_view = CreateEndPreviewView(); | 572 sub_view = CreateEndPreviewView(); |
| 536 break; | 573 break; |
| 537 default: | 574 default: |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 ButtonIndexes::const_iterator profile_match = | 663 ButtonIndexes::const_iterator profile_match = |
| 627 open_other_profile_indexes_map_.find(sender); | 664 open_other_profile_indexes_map_.find(sender); |
| 628 if (profile_match != open_other_profile_indexes_map_.end()) { | 665 if (profile_match != open_other_profile_indexes_map_.end()) { |
| 629 avatar_menu_->SwitchToProfile( | 666 avatar_menu_->SwitchToProfile( |
| 630 profile_match->second, | 667 profile_match->second, |
| 631 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, | 668 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, |
| 632 ProfileMetrics::SWITCH_PROFILE_ICON); | 669 ProfileMetrics::SWITCH_PROFILE_ICON); |
| 633 } else { | 670 } else { |
| 634 // This was a profile accounts button. | 671 // This was a profile accounts button. |
| 635 AccountButtonIndexes::const_iterator account_match = | 672 AccountButtonIndexes::const_iterator account_match = |
| 636 current_profile_accounts_map_.find(sender); | 673 delete_account_button_map_.find(sender); |
| 637 DCHECK(account_match != current_profile_accounts_map_.end()); | 674 if (account_match != delete_account_button_map_.end()) { |
| 638 account_id_to_remove_ = account_match->second; | 675 account_id_to_remove_ = account_match->second; |
| 639 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); | 676 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); |
| 677 } else { |
| 678 account_match = reauth_account_button_map_.find(sender); |
| 679 DCHECK(account_match != reauth_account_button_map_.end()); |
| 680 ShowView(BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); |
| 681 } |
| 640 } | 682 } |
| 641 } | 683 } |
| 642 } | 684 } |
| 643 | 685 |
| 644 void ProfileChooserView::RemoveAccount() { | 686 void ProfileChooserView::RemoveAccount() { |
| 645 DCHECK(!account_id_to_remove_.empty()); | 687 DCHECK(!account_id_to_remove_.empty()); |
| 646 MutableProfileOAuth2TokenService* oauth2_token_service = | 688 MutableProfileOAuth2TokenService* oauth2_token_service = |
| 647 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( | 689 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
| 648 browser_->profile()); | 690 browser_->profile()); |
| 649 if (oauth2_token_service) | 691 if (oauth2_token_service) |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1114 profiles::kAvatarBubbleAccountsBackgroundColor)); | 1156 profiles::kAvatarBubbleAccountsBackgroundColor)); |
| 1115 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 1157 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
| 1116 | 1158 |
| 1117 Profile* profile = browser_->profile(); | 1159 Profile* profile = browser_->profile(); |
| 1118 std::string primary_account = | 1160 std::string primary_account = |
| 1119 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); | 1161 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedUsername(); |
| 1120 DCHECK(!primary_account.empty()); | 1162 DCHECK(!primary_account.empty()); |
| 1121 std::vector<std::string>accounts = | 1163 std::vector<std::string>accounts = |
| 1122 profiles::GetSecondaryAccountsForProfile(profile, primary_account); | 1164 profiles::GetSecondaryAccountsForProfile(profile, primary_account); |
| 1123 | 1165 |
| 1166 // Get state of authentication error, if any. |
| 1167 std::string error_account_id = GetAuthErrorAccountId(profile); |
| 1168 |
| 1124 // The primary account should always be listed first. | 1169 // The primary account should always be listed first. |
| 1125 // TODO(rogerta): we still need to further differentiate the primary account | 1170 // TODO(rogerta): we still need to further differentiate the primary account |
| 1126 // from the others in the UI, so more work is likely required here: | 1171 // from the others in the UI, so more work is likely required here: |
| 1127 // crbug.com/311124. | 1172 // crbug.com/311124. |
| 1128 CreateAccountButton(layout, primary_account, true, kFixedMenuWidth); | 1173 CreateAccountButton(layout, primary_account, true, |
| 1174 error_account_id == primary_account, kFixedMenuWidth); |
| 1129 for (size_t i = 0; i < accounts.size(); ++i) | 1175 for (size_t i = 0; i < accounts.size(); ++i) |
| 1130 CreateAccountButton(layout, accounts[i], false, kFixedMenuWidth); | 1176 CreateAccountButton(layout, accounts[i], false, |
| 1177 error_account_id == accounts[i], kFixedMenuWidth); |
| 1131 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 1178 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 1132 | 1179 |
| 1133 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( | 1180 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( |
| 1134 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); | 1181 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); |
| 1135 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( | 1182 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( |
| 1136 0, views::kButtonVEdgeMarginNew, | 1183 0, views::kButtonVEdgeMarginNew, |
| 1137 views::kRelatedControlVerticalSpacing, 0)); | 1184 views::kRelatedControlVerticalSpacing, 0)); |
| 1138 layout->StartRow(1, 0); | 1185 layout->StartRow(1, 0); |
| 1139 layout->AddView(add_account_link_); | 1186 layout->AddView(add_account_link_); |
| 1140 return view; | 1187 return view; |
| 1141 } | 1188 } |
| 1142 | 1189 |
| 1143 void ProfileChooserView::CreateAccountButton(views::GridLayout* layout, | 1190 void ProfileChooserView::CreateAccountButton(views::GridLayout* layout, |
| 1144 const std::string& account, | 1191 const std::string& account, |
| 1145 bool is_primary_account, | 1192 bool is_primary_account, |
| 1193 bool reauth_required, |
| 1146 int width) { | 1194 int width) { |
| 1147 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1195 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 1148 const gfx::ImageSkia* default_image = | 1196 const gfx::ImageSkia* delete_default_image = |
| 1149 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia(); | 1197 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia(); |
| 1150 int kDeleteButtonWidth = default_image->width(); | 1198 const int kDeleteButtonWidth = delete_default_image->width(); |
| 1199 const gfx::ImageSkia* warning_default_image = reauth_required ? |
| 1200 rb->GetImageNamed(IDR_WARNING).ToImageSkia() : NULL; |
| 1201 const int kWarningButtonWidth = reauth_required ? |
| 1202 warning_default_image->width() + views::kRelatedButtonHSpacing : 0; |
| 1151 int available_width = width - | 1203 int available_width = width - |
| 1152 kDeleteButtonWidth - views::kButtonHEdgeMarginNew; | 1204 kDeleteButtonWidth - kWarningButtonWidth - views::kButtonHEdgeMarginNew; |
| 1153 | 1205 |
| 1154 views::LabelButton* email_button = new BackgroundColorHoverButton( | 1206 views::LabelButton* email_button = new BackgroundColorHoverButton( |
| 1155 NULL, | 1207 NULL, |
| 1156 gfx::ElideEmail(base::UTF8ToUTF16(account), | 1208 gfx::ElideEmail(base::UTF8ToUTF16(account), |
| 1157 rb->GetFontList(ui::ResourceBundle::BaseFont), | 1209 rb->GetFontList(ui::ResourceBundle::BaseFont), |
| 1158 available_width), | 1210 available_width), |
| 1159 gfx::ImageSkia(), | 1211 gfx::ImageSkia(), |
| 1160 gfx::ImageSkia()); | 1212 gfx::ImageSkia()); |
| 1161 layout->StartRow(1, 0); | 1213 layout->StartRow(1, 0); |
| 1162 layout->AddView(email_button); | 1214 layout->AddView(email_button); |
| 1163 | 1215 |
| 1164 // Delete button. | 1216 // Delete button. |
| 1165 views::ImageButton* delete_button = new views::ImageButton(this); | 1217 views::ImageButton* delete_button = new views::ImageButton(this); |
| 1166 delete_button->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, | 1218 delete_button->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, |
| 1167 views::ImageButton::ALIGN_MIDDLE); | 1219 views::ImageButton::ALIGN_MIDDLE); |
| 1168 delete_button->SetImage(views::ImageButton::STATE_NORMAL, | 1220 delete_button->SetImage(views::ImageButton::STATE_NORMAL, |
| 1169 default_image); | 1221 delete_default_image); |
| 1170 delete_button->SetImage(views::ImageButton::STATE_HOVERED, | 1222 delete_button->SetImage(views::ImageButton::STATE_HOVERED, |
| 1171 rb->GetImageSkiaNamed(IDR_CLOSE_1_H)); | 1223 rb->GetImageSkiaNamed(IDR_CLOSE_1_H)); |
| 1172 delete_button->SetImage(views::ImageButton::STATE_PRESSED, | 1224 delete_button->SetImage(views::ImageButton::STATE_PRESSED, |
| 1173 rb->GetImageSkiaNamed(IDR_CLOSE_1_P)); | 1225 rb->GetImageSkiaNamed(IDR_CLOSE_1_P)); |
| 1174 delete_button->SetBounds( | 1226 delete_button->SetBounds( |
| 1175 available_width, 0, kDeleteButtonWidth, kButtonHeight); | 1227 available_width + kWarningButtonWidth, 0, |
| 1228 kDeleteButtonWidth, kButtonHeight); |
| 1176 | 1229 |
| 1177 email_button->set_notify_enter_exit_on_child(true); | 1230 email_button->set_notify_enter_exit_on_child(true); |
| 1178 email_button->AddChildView(delete_button); | 1231 email_button->AddChildView(delete_button); |
| 1179 | 1232 |
| 1180 // Save the original email address, as the button text could be elided. | 1233 // Save the original email address, as the button text could be elided. |
| 1181 current_profile_accounts_map_[delete_button] = account; | 1234 delete_account_button_map_[delete_button] = account; |
| 1235 |
| 1236 // Warning button. |
| 1237 if (reauth_required) { |
| 1238 views::ImageButton* reauth_button = new views::ImageButton(this); |
| 1239 reauth_button->SetImageAlignment(views::ImageButton::ALIGN_LEFT, |
| 1240 views::ImageButton::ALIGN_MIDDLE); |
| 1241 reauth_button->SetImage(views::ImageButton::STATE_NORMAL, |
| 1242 warning_default_image); |
| 1243 reauth_button->SetBounds( |
| 1244 available_width, 0, kWarningButtonWidth, kButtonHeight); |
| 1245 |
| 1246 email_button->AddChildView(reauth_button); |
| 1247 reauth_account_button_map_[reauth_button] = account; |
| 1248 } |
| 1182 } | 1249 } |
| 1183 | 1250 |
| 1184 views::View* ProfileChooserView::CreateGaiaSigninView( | 1251 views::View* ProfileChooserView::CreateGaiaSigninView() { |
| 1185 bool add_secondary_account) { | 1252 GURL url; |
| 1253 int message_id; |
| 1254 |
| 1255 switch (view_mode_) { |
| 1256 case BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
| 1257 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_SIGN_IN, |
| 1258 false /* auto_close */, |
| 1259 true /* is_constrained */); |
| 1260 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; |
| 1261 break; |
| 1262 case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
| 1263 url = signin::GetPromoURL(signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, |
| 1264 false /* auto_close */, |
| 1265 true /* is_constrained */); |
| 1266 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; |
| 1267 break; |
| 1268 case BUBBLE_VIEW_MODE_GAIA_REAUTH: { |
| 1269 DCHECK(HasAuthError(browser_->profile())); |
| 1270 url = signin::GetReauthURL(browser_->profile(), |
| 1271 GetAuthErrorUsername(browser_->profile())); |
| 1272 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; |
| 1273 break; |
| 1274 } |
| 1275 default: |
| 1276 NOTREACHED() << "Called with invalid mode=" << view_mode_; |
| 1277 return NULL; |
| 1278 } |
| 1279 |
| 1186 // Adds Gaia signin webview | 1280 // Adds Gaia signin webview |
| 1187 Profile* profile = browser_->profile(); | 1281 Profile* profile = browser_->profile(); |
| 1188 views::WebView* web_view = new views::WebView(profile); | 1282 views::WebView* web_view = new views::WebView(profile); |
| 1189 signin::Source source = add_secondary_account ? | |
| 1190 signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT : | |
| 1191 signin::SOURCE_AVATAR_BUBBLE_SIGN_IN; | |
| 1192 GURL url(signin::GetPromoURL( | |
| 1193 source, false /* auto_close */, true /* is_constrained */)); | |
| 1194 web_view->LoadInitialURL(url); | 1283 web_view->LoadInitialURL(url); |
| 1195 web_view->SetPreferredSize( | 1284 web_view->SetPreferredSize( |
| 1196 gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight)); | 1285 gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight)); |
| 1197 | 1286 |
| 1198 TitleCard* title_card = new TitleCard( | 1287 TitleCard* title_card = new TitleCard(message_id, this, |
| 1199 add_secondary_account ? IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE : | 1288 &gaia_signin_cancel_button_); |
| 1200 IDS_PROFILES_GAIA_SIGNIN_TITLE, | |
| 1201 this, &gaia_signin_cancel_button_); | |
| 1202 return TitleCard::AddPaddedTitleCard( | 1289 return TitleCard::AddPaddedTitleCard( |
| 1203 web_view, title_card, kFixedGaiaViewWidth); | 1290 web_view, title_card, kFixedGaiaViewWidth); |
| 1204 } | 1291 } |
| 1205 | 1292 |
| 1206 views::View* ProfileChooserView::CreateAccountRemovalView() { | 1293 views::View* ProfileChooserView::CreateAccountRemovalView() { |
| 1207 views::View* view = new views::View(); | 1294 views::View* view = new views::View(); |
| 1208 views::GridLayout* layout = CreateSingleColumnLayout( | 1295 views::GridLayout* layout = CreateSingleColumnLayout( |
| 1209 view, kFixedAccountRemovalViewWidth - 2 * views::kButtonHEdgeMarginNew); | 1296 view, kFixedAccountRemovalViewWidth - 2 * views::kButtonHEdgeMarginNew); |
| 1210 layout->SetInsets(0, | 1297 layout->SetInsets(0, |
| 1211 views::kButtonHEdgeMarginNew, | 1298 views::kButtonHEdgeMarginNew, |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 layout->StartRowWithPadding( | 1391 layout->StartRowWithPadding( |
| 1305 1, 0, 0, views::kUnrelatedControlVerticalSpacing); | 1392 1, 0, 0, views::kUnrelatedControlVerticalSpacing); |
| 1306 layout->AddView(end_preview_and_relaunch_button_); | 1393 layout->AddView(end_preview_and_relaunch_button_); |
| 1307 | 1394 |
| 1308 TitleCard* title_card = new TitleCard( | 1395 TitleCard* title_card = new TitleCard( |
| 1309 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); | 1396 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); |
| 1310 return TitleCard::AddPaddedTitleCard( | 1397 return TitleCard::AddPaddedTitleCard( |
| 1311 view, title_card, kFixedAccountRemovalViewWidth); | 1398 view, title_card, kFixedAccountRemovalViewWidth); |
| 1312 } | 1399 } |
| 1313 | 1400 |
| OLD | NEW |