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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
25 #include "chrome/browser/ui/browser_commands.h" | 25 #include "chrome/browser/ui/browser_commands.h" |
26 #include "chrome/browser/ui/browser_dialogs.h" | 26 #include "chrome/browser/ui/browser_dialogs.h" |
27 #include "chrome/browser/ui/chrome_pages.h" | 27 #include "chrome/browser/ui/chrome_pages.h" |
28 #include "chrome/browser/ui/singleton_tabs.h" | 28 #include "chrome/browser/ui/singleton_tabs.h" |
29 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 29 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
30 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 30 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
31 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 31 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
| 34 #include "chrome/grit/chromium_strings.h" |
| 35 #include "chrome/grit/generated_resources.h" |
34 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" | 36 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" |
35 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 37 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
36 #include "components/signin/core/browser/signin_error_controller.h" | 38 #include "components/signin/core/browser/signin_error_controller.h" |
37 #include "components/signin/core/browser/signin_manager.h" | 39 #include "components/signin/core/browser/signin_manager.h" |
38 #include "components/signin/core/common/profile_management_switches.h" | 40 #include "components/signin/core/common/profile_management_switches.h" |
39 #include "grit/chromium_strings.h" | |
40 #include "grit/generated_resources.h" | |
41 #include "grit/theme_resources.h" | 41 #include "grit/theme_resources.h" |
42 #include "third_party/skia/include/core/SkColor.h" | 42 #include "third_party/skia/include/core/SkColor.h" |
43 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
44 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
45 #include "ui/gfx/canvas.h" | 45 #include "ui/gfx/canvas.h" |
46 #include "ui/gfx/image/image.h" | 46 #include "ui/gfx/image/image.h" |
47 #include "ui/gfx/image/image_skia.h" | 47 #include "ui/gfx/image/image_skia.h" |
48 #include "ui/gfx/path.h" | 48 #include "ui/gfx/path.h" |
49 #include "ui/gfx/skia_util.h" | 49 #include "ui/gfx/skia_util.h" |
50 #include "ui/gfx/text_elider.h" | 50 #include "ui/gfx/text_elider.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 | 192 |
193 protected: | 193 protected: |
194 virtual void Layout() OVERRIDE { | 194 virtual void Layout() OVERRIDE { |
195 // This layout trick keeps the text left-aligned and the icon right-aligned. | 195 // This layout trick keeps the text left-aligned and the icon right-aligned. |
196 SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 196 SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
197 views::LabelButton::Layout(); | 197 views::LabelButton::Layout(); |
198 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 198 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
199 } | 199 } |
200 | 200 |
| 201 private: |
201 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); | 202 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); |
202 }; | 203 }; |
203 | 204 |
204 // EditableProfilePhoto ------------------------------------------------- | 205 // EditableProfilePhoto ------------------------------------------------- |
205 | 206 |
206 // A custom Image control that shows a "change" button when moused over. | 207 // A custom Image control that shows a "change" button when moused over. |
207 class EditableProfilePhoto : public views::LabelButton { | 208 class EditableProfilePhoto : public views::LabelButton { |
208 public: | 209 public: |
209 EditableProfilePhoto(views::ButtonListener* listener, | 210 EditableProfilePhoto(views::ButtonListener* listener, |
210 const gfx::Image& icon, | 211 const gfx::Image& icon, |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 layout->StartRowWithPadding(1, 1, 0, views::kRelatedControlVerticalSpacing); | 447 layout->StartRowWithPadding(1, 1, 0, views::kRelatedControlVerticalSpacing); |
447 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 448 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
448 | 449 |
449 layout->StartRow(1, 1); | 450 layout->StartRow(1, 1); |
450 layout->AddView(view); | 451 layout->AddView(view); |
451 | 452 |
452 return titled_view; | 453 return titled_view; |
453 } | 454 } |
454 | 455 |
455 private: | 456 private: |
456 virtual void Layout() OVERRIDE{ | 457 virtual void Layout() OVERRIDE { |
457 int back_button_width = back_button_->GetPreferredSize().width(); | 458 int back_button_width = back_button_->GetPreferredSize().width(); |
458 back_button_->SetBounds(0, 0, back_button_width, height()); | 459 back_button_->SetBounds(0, 0, back_button_width, height()); |
459 int label_padding = back_button_width + views::kButtonHEdgeMarginNew; | 460 int label_padding = back_button_width + views::kButtonHEdgeMarginNew; |
460 int label_width = width() - 2 * label_padding; | 461 int label_width = width() - 2 * label_padding; |
461 DCHECK_GT(label_width, 0); | 462 DCHECK_GT(label_width, 0); |
462 title_label_->SetBounds(label_padding, 0, label_width, height()); | 463 title_label_->SetBounds(label_padding, 0, label_width, height()); |
463 } | 464 } |
464 | 465 |
465 virtual gfx::Size GetPreferredSize() const OVERRIDE{ | 466 virtual gfx::Size GetPreferredSize() const OVERRIDE { |
466 int height = std::max(title_label_->GetPreferredSize().height(), | 467 int height = std::max(title_label_->GetPreferredSize().height(), |
467 back_button_->GetPreferredSize().height()); | 468 back_button_->GetPreferredSize().height()); |
468 return gfx::Size(width(), height); | 469 return gfx::Size(width(), height); |
469 } | 470 } |
470 | 471 |
471 views::ImageButton* back_button_; | 472 views::ImageButton* back_button_; |
472 views::Label* title_label_; | 473 views::Label* title_label_; |
473 | 474 |
474 DISALLOW_COPY_AND_ASSIGN(TitleCard); | 475 DISALLOW_COPY_AND_ASSIGN(TitleCard); |
475 }; | 476 }; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 avatar_menu_.get()); | 824 avatar_menu_.get()); |
824 } else if (sender == add_account_link_) { | 825 } else if (sender == add_account_link_) { |
825 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 826 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
826 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); | 827 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); |
827 } else if (sender == tutorial_sync_settings_link_) { | 828 } else if (sender == tutorial_sync_settings_link_) { |
828 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 829 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
829 SyncConfirmationUIClosed(true /* configure_sync_first */); | 830 SyncConfirmationUIClosed(true /* configure_sync_first */); |
830 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 831 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
831 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 832 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
832 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); | 833 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); |
833 } else if (sender == tutorial_not_you_link_){ | 834 } else if (sender == tutorial_not_you_link_) { |
834 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | 835 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
835 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); | 836 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); |
836 ShowView(profiles::BUBBLE_VIEW_MODE_SWITCH_USER, avatar_menu_.get()); | 837 ShowView(profiles::BUBBLE_VIEW_MODE_SWITCH_USER, avatar_menu_.get()); |
837 } else { | 838 } else { |
838 DCHECK(sender == tutorial_learn_more_link_); | 839 DCHECK(sender == tutorial_learn_more_link_); |
839 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); | 840 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); |
840 } | 841 } |
841 } | 842 } |
842 | 843 |
843 void ProfileChooserView::StyledLabelLinkClicked( | 844 void ProfileChooserView::StyledLabelLinkClicked( |
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 } | 1502 } |
1502 | 1503 |
1503 TitleCard* title_card = new TitleCard( | 1504 TitleCard* title_card = new TitleCard( |
1504 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), | 1505 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), |
1505 this, &account_removal_cancel_button_); | 1506 this, &account_removal_cancel_button_); |
1506 return TitleCard::AddPaddedTitleCard(view, title_card, | 1507 return TitleCard::AddPaddedTitleCard(view, title_card, |
1507 kFixedAccountRemovalViewWidth); | 1508 kFixedAccountRemovalViewWidth); |
1508 } | 1509 } |
1509 | 1510 |
1510 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded( | 1511 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded( |
1511 bool tutorial_shown, const AvatarMenu::Item& avatar_item){ | 1512 bool tutorial_shown, const AvatarMenu::Item& avatar_item) { |
1512 Profile* profile = browser_->profile(); | 1513 Profile* profile = browser_->profile(); |
1513 | 1514 |
1514 const int show_count = profile->GetPrefs()->GetInteger( | 1515 const int show_count = profile->GetPrefs()->GetInteger( |
1515 prefs::kProfileAvatarTutorialShown); | 1516 prefs::kProfileAvatarTutorialShown); |
1516 // Do not show the tutorial if user has dismissed it. | 1517 // Do not show the tutorial if user has dismissed it. |
1517 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax) | 1518 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
1518 return NULL; | 1519 return NULL; |
1519 | 1520 |
1520 if (!tutorial_shown) { | 1521 if (!tutorial_shown) { |
1521 if (show_count == signin_ui_util::kUpgradeWelcomeTutorialShowMax) | 1522 if (show_count == signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1640 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1640 IncognitoModePrefs::DISABLED; | 1641 IncognitoModePrefs::DISABLED; |
1641 return incognito_available && !browser_->profile()->IsGuestSession(); | 1642 return incognito_available && !browser_->profile()->IsGuestSession(); |
1642 } | 1643 } |
1643 | 1644 |
1644 void ProfileChooserView::PostActionPerformed( | 1645 void ProfileChooserView::PostActionPerformed( |
1645 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1646 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1646 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1647 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1647 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1648 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1648 } | 1649 } |
OLD | NEW |