Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1309)

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 255203002: Implement end-preview flow with views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typo fixed Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_window.h" 14 #include "chrome/browser/profiles/profile_window.h"
15 #include "chrome/browser/profiles/profiles_state.h" 15 #include "chrome/browser/profiles/profiles_state.h"
16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 16 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
17 #include "chrome/browser/signin/signin_manager_factory.h" 17 #include "chrome/browser/signin/signin_manager_factory.h"
18 #include "chrome/browser/signin/signin_promo.h" 18 #include "chrome/browser/signin/signin_promo.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_commands.h"
20 #include "chrome/browser/ui/browser_dialogs.h" 21 #include "chrome/browser/ui/browser_dialogs.h"
21 #include "chrome/browser/ui/chrome_pages.h" 22 #include "chrome/browser/ui/chrome_pages.h"
22 #include "chrome/browser/ui/singleton_tabs.h" 23 #include "chrome/browser/ui/singleton_tabs.h"
23 #include "chrome/browser/ui/views/profiles/user_manager_view.h" 24 #include "chrome/browser/ui/views/profiles/user_manager_view.h"
24 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
25 #include "chrome/common/url_constants.h" 26 #include "chrome/common/url_constants.h"
26 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" 27 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h"
27 #include "components/signin/core/browser/profile_oauth2_token_service.h" 28 #include "components/signin/core/browser/profile_oauth2_token_service.h"
28 #include "components/signin/core/browser/signin_manager.h" 29 #include "components/signin/core/browser/signin_manager.h"
29 #include "components/signin/core/common/profile_management_switches.h" 30 #include "components/signin/core/common/profile_management_switches.h"
(...skipping 25 matching lines...) Expand all
55 namespace { 56 namespace {
56 57
57 // Helpers -------------------------------------------------------------------- 58 // Helpers --------------------------------------------------------------------
58 59
59 const int kFixedMenuWidth = 250; 60 const int kFixedMenuWidth = 250;
60 const int kButtonHeight = 29; 61 const int kButtonHeight = 29;
61 const int kProfileAvatarTutorialShowMax = 5; 62 const int kProfileAvatarTutorialShowMax = 5;
62 const int kFixedGaiaViewHeight = 400; 63 const int kFixedGaiaViewHeight = 400;
63 const int kFixedGaiaViewWidth = 360; 64 const int kFixedGaiaViewWidth = 360;
64 const int kFixedAccountRemovalViewWidth = 280; 65 const int kFixedAccountRemovalViewWidth = 280;
66 const int kFixedEndPreviewViewWidth = 280;
65 const int kLargeImageSide = 88; 67 const int kLargeImageSide = 88;
66 68
67 // Creates a GridLayout with a single column. This ensures that all the child 69 // Creates a GridLayout with a single column. This ensures that all the child
68 // views added get auto-expanded to fill the full width of the bubble. 70 // views added get auto-expanded to fill the full width of the bubble.
69 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { 71 views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) {
70 views::GridLayout* layout = new views::GridLayout(view); 72 views::GridLayout* layout = new views::GridLayout(view);
71 view->SetLayoutManager(layout); 73 view->SetLayoutManager(layout);
72 74
73 views::ColumnSet* columns = layout->AddColumnSet(0); 75 views::ColumnSet* columns = layout->AddColumnSet(0);
74 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 76 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 382 }
381 383
382 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 384 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
383 views::BubbleBorder::Arrow arrow, 385 views::BubbleBorder::Arrow arrow,
384 const gfx::Rect& anchor_rect, 386 const gfx::Rect& anchor_rect,
385 Browser* browser, 387 Browser* browser,
386 BubbleViewMode view_mode) 388 BubbleViewMode view_mode)
387 : BubbleDelegateView(anchor_view, arrow), 389 : BubbleDelegateView(anchor_view, arrow),
388 browser_(browser), 390 browser_(browser),
389 view_mode_(view_mode), 391 view_mode_(view_mode),
390 tutorial_showing_(false) { 392 tutorial_mode_(TUTORIAL_MODE_NONE) {
391 // Reset the default margins inherited from the BubbleDelegateView. 393 // Reset the default margins inherited from the BubbleDelegateView.
392 set_margins(gfx::Insets()); 394 set_margins(gfx::Insets());
393 395
394 ResetView(); 396 ResetView();
395 397
396 set_background(views::Background::CreateSolidBackground( 398 set_background(views::Background::CreateSolidBackground(
397 GetNativeTheme()->GetSystemColor( 399 GetNativeTheme()->GetSystemColor(
398 ui::NativeTheme::kColorId_DialogBackground))); 400 ui::NativeTheme::kColorId_DialogBackground)));
399 401
400 avatar_menu_.reset(new AvatarMenu( 402 avatar_menu_.reset(new AvatarMenu(
401 &g_browser_process->profile_manager()->GetProfileInfoCache(), 403 &g_browser_process->profile_manager()->GetProfileInfoCache(),
402 this, 404 this,
403 browser_)); 405 browser_));
404 avatar_menu_->RebuildMenu(); 406 avatar_menu_->RebuildMenu();
405 407
406 ProfileOAuth2TokenService* oauth2_token_service = 408 ProfileOAuth2TokenService* oauth2_token_service =
407 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); 409 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile());
408 if (oauth2_token_service) 410 if (oauth2_token_service)
409 oauth2_token_service->AddObserver(this); 411 oauth2_token_service->AddObserver(this);
410 } 412 }
411 413
412 ProfileChooserView::~ProfileChooserView() { 414 ProfileChooserView::~ProfileChooserView() {
413 ProfileOAuth2TokenService* oauth2_token_service = 415 ProfileOAuth2TokenService* oauth2_token_service =
414 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); 416 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile());
415 if (oauth2_token_service) 417 if (oauth2_token_service)
416 oauth2_token_service->RemoveObserver(this); 418 oauth2_token_service->RemoveObserver(this);
417 } 419 }
418 420
419 void ProfileChooserView::ResetView() { 421 void ProfileChooserView::ResetView() {
422 question_mark_button_ = NULL;
420 manage_accounts_link_ = NULL; 423 manage_accounts_link_ = NULL;
421 signin_current_profile_link_ = NULL; 424 signin_current_profile_link_ = NULL;
422 users_button_ = NULL; 425 users_button_ = NULL;
423 lock_button_ = NULL; 426 lock_button_ = NULL;
424 add_account_link_ = NULL; 427 add_account_link_ = NULL;
425 current_profile_photo_ = NULL; 428 current_profile_photo_ = NULL;
426 current_profile_name_ = NULL; 429 current_profile_name_ = NULL;
427 tutorial_ok_button_ = NULL; 430 tutorial_ok_button_ = NULL;
428 tutorial_learn_more_link_ = NULL; 431 tutorial_learn_more_link_ = NULL;
429 tutorial_enable_new_profile_management_button_ = NULL; 432 tutorial_enable_new_profile_management_button_ = NULL;
433 tutorial_end_preview_link_ = NULL;
434 tutorial_send_feedback_button_ = NULL;
435 end_preview_and_relaunch_button_ = NULL;
436 end_preview_cancel_button_ = NULL;
437 remove_account_and_relaunch_button_ = NULL;
430 account_removal_cancel_button_ = NULL; 438 account_removal_cancel_button_ = NULL;
431 gaia_signin_cancel_button_ = NULL; 439 gaia_signin_cancel_button_ = NULL;
432 open_other_profile_indexes_map_.clear(); 440 open_other_profile_indexes_map_.clear();
433 current_profile_accounts_map_.clear(); 441 current_profile_accounts_map_.clear();
434 tutorial_showing_ = false; 442 tutorial_mode_ = TUTORIAL_MODE_NONE;
435 } 443 }
436 444
437 void ProfileChooserView::Init() { 445 void ProfileChooserView::Init() {
438 ShowView(view_mode_, avatar_menu_.get()); 446 ShowView(view_mode_, avatar_menu_.get());
439 } 447 }
440 448
441 void ProfileChooserView::OnAvatarMenuChanged( 449 void ProfileChooserView::OnAvatarMenuChanged(
442 AvatarMenu* avatar_menu) { 450 AvatarMenu* avatar_menu) {
443 // Refresh the view with the new menu. We can't just update the local copy 451 // Refresh the view with the new menu. We can't just update the local copy
444 // as this may have been triggered by a sign out action, in which case 452 // as this may have been triggered by a sign out action, in which case
(...skipping 22 matching lines...) Expand all
467 void ProfileChooserView::ShowView(BubbleViewMode view_to_display, 475 void ProfileChooserView::ShowView(BubbleViewMode view_to_display,
468 AvatarMenu* avatar_menu) { 476 AvatarMenu* avatar_menu) {
469 // The account management view should only be displayed if the active profile 477 // The account management view should only be displayed if the active profile
470 // is signed in. 478 // is signed in.
471 if (view_to_display == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { 479 if (view_to_display == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
472 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( 480 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt(
473 avatar_menu->GetActiveProfileIndex()); 481 avatar_menu->GetActiveProfileIndex());
474 DCHECK(active_item.signed_in); 482 DCHECK(active_item.signed_in);
475 } 483 }
476 484
477 // Records if the "mirror enabled" tutorial card is currently shown before 485 // Records the last tutorial mode.
478 // resetting the view. 486 TutorialMode last_tutorial_mode = tutorial_mode_;
479 bool tutorial_shown = tutorial_showing_;
480 ResetView(); 487 ResetView();
481 RemoveAllChildViews(true); 488 RemoveAllChildViews(true);
482 view_mode_ = view_to_display; 489 view_mode_ = view_to_display;
483 490
484 views::GridLayout* layout; 491 views::GridLayout* layout;
485 views::View* sub_view; 492 views::View* sub_view;
486 switch (view_mode_) { 493 switch (view_mode_) {
487 case BUBBLE_VIEW_MODE_GAIA_SIGNIN: 494 case BUBBLE_VIEW_MODE_GAIA_SIGNIN:
488 case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: 495 case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
489 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); 496 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth);
490 sub_view = CreateGaiaSigninView( 497 sub_view = CreateGaiaSigninView(
491 view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); 498 view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT);
492 break; 499 break;
493 case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: 500 case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL:
494 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); 501 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth);
495 sub_view = CreateAccountRemovalView(); 502 sub_view = CreateAccountRemovalView();
496 break; 503 break;
504 case BUBBLE_VIEW_MODE_END_PREVIEW:
505 layout = CreateSingleColumnLayout(this, kFixedEndPreviewViewWidth);
506 sub_view = CreateEndPreviewView();
507 break;
497 default: 508 default:
498 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); 509 layout = CreateSingleColumnLayout(this, kFixedMenuWidth);
499 sub_view = CreateProfileChooserView(avatar_menu, tutorial_shown); 510 sub_view = CreateProfileChooserView(avatar_menu, last_tutorial_mode);
500 } 511 }
501 layout->StartRow(1, 0); 512 layout->StartRow(1, 0);
502 layout->AddView(sub_view); 513 layout->AddView(sub_view);
503 Layout(); 514 Layout();
504 if (GetBubbleFrameView()) 515 if (GetBubbleFrameView())
505 SizeToContents(); 516 SizeToContents();
506 } 517 }
507 518
508 void ProfileChooserView::WindowClosing() { 519 void ProfileChooserView::WindowClosing() {
509 DCHECK_EQ(profile_bubble_, this); 520 DCHECK_EQ(profile_bubble_, this);
(...skipping 27 matching lines...) Expand all
537 } else if (sender == account_removal_cancel_button_) { 548 } else if (sender == account_removal_cancel_button_) {
538 account_id_to_remove_.clear(); 549 account_id_to_remove_.clear();
539 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 550 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
540 } else if (sender == gaia_signin_cancel_button_) { 551 } else if (sender == gaia_signin_cancel_button_) {
541 std::string primary_account = 552 std::string primary_account =
542 SigninManagerFactory::GetForProfile(browser_->profile())-> 553 SigninManagerFactory::GetForProfile(browser_->profile())->
543 GetAuthenticatedUsername(); 554 GetAuthenticatedUsername();
544 ShowView(primary_account.empty() ? BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 555 ShowView(primary_account.empty() ? BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
545 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, 556 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
546 avatar_menu_.get()); 557 avatar_menu_.get());
558 } else if (sender == question_mark_button_) {
559 tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK;
560 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
561 } else if (sender == tutorial_send_feedback_button_) {
562 chrome::OpenFeedbackDialog(browser_);
563 } else if (sender == end_preview_and_relaunch_button_) {
564 profiles::DisableNewProfileManagementPreview();
565 } else if (sender == end_preview_cancel_button_) {
566 tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK;
567 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
547 } else if (current_profile_photo_ && 568 } else if (current_profile_photo_ &&
548 sender == current_profile_photo_->change_photo_button()) { 569 sender == current_profile_photo_->change_photo_button()) {
549 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); 570 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex());
550 } else if (sender == signin_current_profile_link_) { 571 } else if (sender == signin_current_profile_link_) {
551 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); 572 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get());
552 } else { 573 } else {
553 // Either one of the "other profiles", or one of the profile accounts 574 // Either one of the "other profiles", or one of the profile accounts
554 // buttons was pressed. 575 // buttons was pressed.
555 ButtonIndexes::const_iterator profile_match = 576 ButtonIndexes::const_iterator profile_match =
556 open_other_profile_indexes_map_.find(sender); 577 open_other_profile_indexes_map_.find(sender);
(...skipping 30 matching lines...) Expand all
587 // This link can either mean show/hide the account management view, 608 // This link can either mean show/hide the account management view,
588 // depending on which view it is displayed. ShowView() will DCHECK if 609 // depending on which view it is displayed. ShowView() will DCHECK if
589 // the account management view is displayed for non signed-in users. 610 // the account management view is displayed for non signed-in users.
590 ShowView( 611 ShowView(
591 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? 612 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ?
592 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 613 BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
593 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, 614 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT,
594 avatar_menu_.get()); 615 avatar_menu_.get());
595 } else if (sender == add_account_link_) { 616 } else if (sender == add_account_link_) {
596 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); 617 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get());
597 } else { 618 } else if (sender == tutorial_learn_more_link_) {
598 DCHECK(sender == tutorial_learn_more_link_);
599 // TODO(guohui): update |learn_more_url| once it is decided. 619 // TODO(guohui): update |learn_more_url| once it is decided.
600 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); 620 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to");
601 chrome::NavigateParams params( 621 chrome::NavigateParams params(
602 browser_->profile(), 622 browser_->profile(),
603 lear_more_url, 623 lear_more_url,
604 content::PAGE_TRANSITION_LINK); 624 content::PAGE_TRANSITION_LINK);
605 params.disposition = NEW_FOREGROUND_TAB; 625 params.disposition = NEW_FOREGROUND_TAB;
606 chrome::Navigate(&params); 626 chrome::Navigate(&params);
627 } else {
628 DCHECK(sender == tutorial_end_preview_link_);
629 ShowView(BUBBLE_VIEW_MODE_END_PREVIEW, avatar_menu_.get());
607 } 630 }
608 } 631 }
609 632
610 void ProfileChooserView::StyledLabelLinkClicked( 633 void ProfileChooserView::StyledLabelLinkClicked(
611 const gfx::Range& range, int event_flags) { 634 const gfx::Range& range, int event_flags) {
612 chrome::ShowSettings(browser_); 635 chrome::ShowSettings(browser_);
613 } 636 }
614 637
615 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, 638 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender,
616 const ui::KeyEvent& key_event) { 639 const ui::KeyEvent& key_event) {
(...skipping 18 matching lines...) Expand all
635 return true; 658 return true;
636 659
637 profiles::UpdateProfileName(profile, new_profile_name); 660 profiles::UpdateProfileName(profile, new_profile_name);
638 current_profile_name_->ShowReadOnlyView(); 661 current_profile_name_->ShowReadOnlyView();
639 return true; 662 return true;
640 } 663 }
641 return false; 664 return false;
642 } 665 }
643 666
644 views::View* ProfileChooserView::CreateProfileChooserView( 667 views::View* ProfileChooserView::CreateProfileChooserView(
645 AvatarMenu* avatar_menu, bool tutorial_shown) { 668 AvatarMenu* avatar_menu, TutorialMode last_tutorial_mode) {
646 // TODO(guohui, noms): the view should be customized based on whether new 669 // TODO(guohui, noms): the view should be customized based on whether new
647 // profile management preview is enabled or not. 670 // profile management preview is enabled or not.
648 671
649 views::View* view = new views::View(); 672 views::View* view = new views::View();
650 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 673 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
651 // Separate items into active and alternatives. 674 // Separate items into active and alternatives.
652 Indexes other_profiles; 675 Indexes other_profiles;
653 views::View* tutorial_view = NULL; 676 views::View* tutorial_view = NULL;
654 views::View* current_profile_view = NULL; 677 views::View* current_profile_view = NULL;
655 views::View* current_profile_accounts = NULL; 678 views::View* current_profile_accounts = NULL;
656 views::View* option_buttons_view = NULL; 679 views::View* option_buttons_view = NULL;
680 bool is_new_profile_management = switches::IsNewProfileManagement();
657 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 681 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
658 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 682 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
659 if (item.active) { 683 if (item.active) {
660 option_buttons_view = CreateOptionsView(item.signed_in); 684 option_buttons_view = CreateOptionsView(item.signed_in);
661 current_profile_view = CreateCurrentProfileView(item, false); 685 current_profile_view = CreateCurrentProfileView(item, false);
662 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { 686 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
663 tutorial_view = switches::IsNewProfileManagement() ? 687 if (is_new_profile_management) {
664 CreatePreviewEnabledTutorialView(item, tutorial_shown) : 688 tutorial_view = last_tutorial_mode == TUTORIAL_MODE_SEND_FEEDBACK ?
665 CreateNewProfileManagementPreviewView(); 689 CreateSendPreviewFeedbackView() :
690 CreatePreviewEnabledTutorialView(
691 item, last_tutorial_mode == TUTORIAL_MODE_PREVIEW_ENABLED);
692 } else {
693 tutorial_view = CreateNewProfileManagementPreviewView();
694 }
666 } else { 695 } else {
667 current_profile_accounts = CreateCurrentProfileAccountsView(item); 696 current_profile_accounts = CreateCurrentProfileAccountsView(item);
668 } 697 }
669 } else { 698 } else {
670 other_profiles.push_back(i); 699 other_profiles.push_back(i);
671 } 700 }
672 } 701 }
673 702
674 if (tutorial_view) { 703 if (tutorial_view) {
675 layout->StartRow(1, 0); 704 layout->StartRow(1, 0);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // Do not show the tutorial if user has dismissed it. 750 // Do not show the tutorial if user has dismissed it.
722 if (show_count > kProfileAvatarTutorialShowMax) 751 if (show_count > kProfileAvatarTutorialShowMax)
723 return NULL; 752 return NULL;
724 753
725 if (!tutorial_shown) { 754 if (!tutorial_shown) {
726 if (show_count == kProfileAvatarTutorialShowMax) 755 if (show_count == kProfileAvatarTutorialShowMax)
727 return NULL; 756 return NULL;
728 profile->GetPrefs()->SetInteger( 757 profile->GetPrefs()->SetInteger(
729 prefs::kProfileAvatarTutorialShown, show_count + 1); 758 prefs::kProfileAvatarTutorialShown, show_count + 1);
730 } 759 }
731 tutorial_showing_ = true;
732 760
733 return CreateTutorialView( 761 return CreateTutorialView(
762 TUTORIAL_MODE_PREVIEW_ENABLED,
734 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE), 763 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE),
735 l10n_util::GetStringUTF16( 764 l10n_util::GetStringUTF16(
736 IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT), 765 IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT),
737 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), 766 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE),
738 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), 767 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON),
739 &tutorial_learn_more_link_, 768 &tutorial_learn_more_link_,
740 &tutorial_ok_button_); 769 &tutorial_ok_button_);
741 } 770 }
742 771
772 views::View* ProfileChooserView::CreateSendPreviewFeedbackView() {
773 return CreateTutorialView(
774 TUTORIAL_MODE_SEND_FEEDBACK,
775 l10n_util::GetStringUTF16(IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE),
776 l10n_util::GetStringUTF16(
777 IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT),
778 l10n_util::GetStringUTF16(IDS_PROFILES_END_PREVIEW),
779 l10n_util::GetStringUTF16(IDS_PROFILES_SEND_FEEDBACK_BUTTON),
780 &tutorial_end_preview_link_,
781 &tutorial_send_feedback_button_);
782 }
783
743 views::View* ProfileChooserView::CreateTutorialView( 784 views::View* ProfileChooserView::CreateTutorialView(
785 TutorialMode tutorial_mode,
744 const base::string16& title_text, 786 const base::string16& title_text,
745 const base::string16& content_text, 787 const base::string16& content_text,
746 const base::string16& link_text, 788 const base::string16& link_text,
747 const base::string16& button_text, 789 const base::string16& button_text,
748 views::Link** link, 790 views::Link** link,
749 views::LabelButton** button) { 791 views::LabelButton** button) {
792 tutorial_mode_ = tutorial_mode;
793
750 views::View* view = new views::View(); 794 views::View* view = new views::View();
751 view->set_background(views::Background::CreateSolidBackground( 795 view->set_background(views::Background::CreateSolidBackground(
752 profiles::kAvatarTutorialBackgroundColor)); 796 profiles::kAvatarTutorialBackgroundColor));
753 views::GridLayout* layout = CreateSingleColumnLayout(view, 797 views::GridLayout* layout = CreateSingleColumnLayout(view,
754 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); 798 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew);
755 layout->SetInsets(views::kButtonVEdgeMarginNew, 799 layout->SetInsets(views::kButtonVEdgeMarginNew,
756 views::kButtonHEdgeMarginNew, 800 views::kButtonHEdgeMarginNew,
757 views::kButtonVEdgeMarginNew, 801 views::kButtonVEdgeMarginNew,
758 views::kButtonHEdgeMarginNew); 802 views::kButtonHEdgeMarginNew);
759 803
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 layout->SetInsets(views::kButtonVEdgeMarginNew, 884 layout->SetInsets(views::kButtonVEdgeMarginNew,
841 views::kButtonHEdgeMarginNew, 885 views::kButtonHEdgeMarginNew,
842 views::kRelatedControlVerticalSpacing, 886 views::kRelatedControlVerticalSpacing,
843 views::kButtonHEdgeMarginNew); 887 views::kButtonHEdgeMarginNew);
844 888
845 // Profile icon, centered. 889 // Profile icon, centered.
846 float x_offset = (column_width - kLargeImageSide) / 2; 890 float x_offset = (column_width - kLargeImageSide) / 2;
847 current_profile_photo_ = new EditableProfilePhoto( 891 current_profile_photo_ = new EditableProfilePhoto(
848 this, avatar_item.icon, !is_guest, 892 this, avatar_item.icon, !is_guest,
849 gfx::Rect(x_offset, 0, kLargeImageSide, kLargeImageSide)); 893 gfx::Rect(x_offset, 0, kLargeImageSide, kLargeImageSide));
894
895 if (switches::IsNewProfileManagementPreviewEnabled()) {
896 question_mark_button_ = new views::ImageButton(this);
897 question_mark_button_->SetImageAlignment(
898 views::ImageButton::ALIGN_LEFT, views::ImageButton::ALIGN_MIDDLE);
899 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
900 question_mark_button_->SetImage(views::ImageButton::STATE_NORMAL,
901 rb->GetImageSkiaNamed(IDR_QUESTION_MARK));
902 gfx::Size preferred_size = question_mark_button_->GetPreferredSize();
903 question_mark_button_->SetBounds(
904 0, 0, preferred_size.width(), preferred_size.height());
905 current_profile_photo_->AddChildView(question_mark_button_);
906 }
907
850 layout->StartRow(1, 0); 908 layout->StartRow(1, 0);
851 layout->AddView(current_profile_photo_); 909 layout->AddView(current_profile_photo_);
852 910
853 // Profile name, centered. 911 // Profile name, centered.
854 current_profile_name_ = new EditableProfileName( 912 current_profile_name_ = new EditableProfileName(
855 this, profiles::GetAvatarNameForProfile(browser_->profile()), !is_guest); 913 this, profiles::GetAvatarNameForProfile(browser_->profile()), !is_guest);
856 layout->StartRow(1, 0); 914 layout->StartRow(1, 0);
857 layout->AddView(current_profile_name_); 915 layout->AddView(current_profile_name_);
858 916
859 if (is_guest) 917 if (is_guest)
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 layout->AddView(remove_account_and_relaunch_button_); 1199 layout->AddView(remove_account_and_relaunch_button_);
1142 } else { 1200 } else {
1143 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 1201 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
1144 } 1202 }
1145 1203
1146 return view; 1204 return view;
1147 } 1205 }
1148 1206
1149 views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() { 1207 views::View* ProfileChooserView::CreateNewProfileManagementPreviewView() {
1150 return CreateTutorialView( 1208 return CreateTutorialView(
1209 TUTORIAL_MODE_ENABLE_PREVIEW,
1151 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE), 1210 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_TITLE),
1152 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT), 1211 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_TUTORIAL_CONTENT_TEXT),
1153 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), 1212 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE),
1154 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_TRY_BUTTON), 1213 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_TRY_BUTTON),
1155 &tutorial_learn_more_link_, 1214 &tutorial_learn_more_link_,
1156 &tutorial_enable_new_profile_management_button_); 1215 &tutorial_enable_new_profile_management_button_);
1157 } 1216 }
1217
1218 views::View* ProfileChooserView::CreateEndPreviewView() {
1219 views::View* view = new views::View();
1220 views::GridLayout* layout = CreateSingleColumnLayout(
1221 view, kFixedAccountRemovalViewWidth - 2 * views::kButtonHEdgeMarginNew);
1222 layout->SetInsets(views::kButtonVEdgeMarginNew,
1223 views::kButtonHEdgeMarginNew,
1224 views::kButtonVEdgeMarginNew,
1225 views::kButtonHEdgeMarginNew);
1226
1227 // Adds title.
1228 layout->StartRow(1, 0);
1229 layout->AddView(new TitleCard(IDS_PROFILES_END_PREVIEW, this,
1230 &end_preview_cancel_button_));
1231 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing);
1232 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1233
1234 // Adds main text.
1235 views::Label* content_label = new views::Label(
1236 l10n_util::GetStringUTF16(IDS_PROFILES_END_PREVIEW_TEXT));
1237 content_label->SetMultiLine(true);
1238 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1239 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1240 const gfx::FontList& small_font_list =
1241 rb->GetFontList(ui::ResourceBundle::SmallFont);
1242 content_label->SetFontList(small_font_list);
1243 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1244 layout->AddView(content_label);
1245
1246 // Adds button.
1247 end_preview_and_relaunch_button_ = new views::BlueButton(
1248 this, l10n_util::GetStringUTF16(IDS_PROFILES_END_PREVIEW_AND_RELAUNCH));
1249 end_preview_and_relaunch_button_->SetHorizontalAlignment(
1250 gfx::ALIGN_CENTER);
1251 layout->StartRowWithPadding(
1252 1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1253 layout->AddView(end_preview_and_relaunch_button_);
1254
1255 return view;
1256 }
1257
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698