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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 }; | 378 }; |
379 | 379 |
380 // ProfileChooserView --------------------------------------------------------- | 380 // ProfileChooserView --------------------------------------------------------- |
381 | 381 |
382 // static | 382 // static |
383 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL; | 383 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL; |
384 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 384 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
385 | 385 |
386 // static | 386 // static |
387 void ProfileChooserView::ShowBubble( | 387 void ProfileChooserView::ShowBubble( |
388 BubbleViewMode view_mode, | 388 profiles::BubbleViewMode view_mode, |
389 views::View* anchor_view, | 389 views::View* anchor_view, |
390 views::BubbleBorder::Arrow arrow, | 390 views::BubbleBorder::Arrow arrow, |
391 views::BubbleBorder::BubbleAlignment border_alignment, | 391 views::BubbleBorder::BubbleAlignment border_alignment, |
392 const gfx::Rect& anchor_rect, | 392 const gfx::Rect& anchor_rect, |
393 Browser* browser) { | 393 Browser* browser) { |
394 if (IsShowing()) | 394 if (IsShowing()) |
395 return; | 395 return; |
396 | 396 |
397 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, anchor_rect, | 397 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, anchor_rect, |
398 browser, view_mode); | 398 browser, view_mode); |
(...skipping 12 matching lines...) Expand all Loading... | |
411 // static | 411 // static |
412 void ProfileChooserView::Hide() { | 412 void ProfileChooserView::Hide() { |
413 if (IsShowing()) | 413 if (IsShowing()) |
414 profile_bubble_->GetWidget()->Close(); | 414 profile_bubble_->GetWidget()->Close(); |
415 } | 415 } |
416 | 416 |
417 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 417 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
418 views::BubbleBorder::Arrow arrow, | 418 views::BubbleBorder::Arrow arrow, |
419 const gfx::Rect& anchor_rect, | 419 const gfx::Rect& anchor_rect, |
420 Browser* browser, | 420 Browser* browser, |
421 BubbleViewMode view_mode) | 421 profiles::BubbleViewMode view_mode) |
422 : BubbleDelegateView(anchor_view, arrow), | 422 : BubbleDelegateView(anchor_view, arrow), |
423 browser_(browser), | 423 browser_(browser), |
424 view_mode_(view_mode), | 424 view_mode_(view_mode), |
425 tutorial_mode_(TUTORIAL_MODE_NONE) { | 425 tutorial_mode_(TUTORIAL_MODE_NONE) { |
426 // Reset the default margins inherited from the BubbleDelegateView. | 426 // Reset the default margins inherited from the BubbleDelegateView. |
427 set_margins(gfx::Insets()); | 427 set_margins(gfx::Insets()); |
428 | 428 |
429 ResetView(); | 429 ResetView(); |
430 | 430 |
431 avatar_menu_.reset(new AvatarMenu( | 431 avatar_menu_.reset(new AvatarMenu( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 // Refresh the view with the new menu. We can't just update the local copy | 480 // 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 | 481 // as this may have been triggered by a sign out action, in which case |
482 // the view is being destroyed. | 482 // the view is being destroyed. |
483 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu); | 483 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu); |
484 } | 484 } |
485 | 485 |
486 void ProfileChooserView::OnRefreshTokenAvailable( | 486 void ProfileChooserView::OnRefreshTokenAvailable( |
487 const std::string& account_id) { | 487 const std::string& account_id) { |
488 // Refresh the account management view when a new account is added to the | 488 // Refresh the account management view when a new account is added to the |
489 // profile. | 489 // profile. |
490 if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || | 490 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || |
491 view_mode_ == BUBBLE_VIEW_MODE_GAIA_SIGNIN || | 491 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || |
492 view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) { | 492 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) { |
493 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 493 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
494 } | 494 } |
495 } | 495 } |
496 | 496 |
497 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { | 497 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { |
498 // Refresh the account management view when an account is removed from the | 498 // Refresh the account management view when an account is removed from the |
499 // profile. | 499 // profile. |
500 if (view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) | 500 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) |
501 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 501 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
502 } | 502 } |
503 | 503 |
504 void ProfileChooserView::ShowView(BubbleViewMode view_to_display, | 504 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, |
505 AvatarMenu* avatar_menu) { | 505 AvatarMenu* avatar_menu) { |
506 // The account management view should only be displayed if the active profile | 506 // The account management view should only be displayed if the active profile |
507 // is signed in. | 507 // is signed in. |
508 if (view_to_display == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { | 508 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
509 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( | 509 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( |
510 avatar_menu->GetActiveProfileIndex()); | 510 avatar_menu->GetActiveProfileIndex()); |
511 DCHECK(active_item.signed_in); | 511 DCHECK(active_item.signed_in); |
512 } | 512 } |
513 | 513 |
514 // Records the last tutorial mode. | 514 // Records the last tutorial mode. |
515 TutorialMode last_tutorial_mode = tutorial_mode_; | 515 profiles::TutorialMode last_tutorial_mode = tutorial_mode_; |
516 ResetView(); | 516 ResetView(); |
517 RemoveAllChildViews(true); | 517 RemoveAllChildViews(true); |
518 view_mode_ = view_to_display; | 518 view_mode_ = view_to_display; |
519 | 519 |
520 views::GridLayout* layout; | 520 views::GridLayout* layout; |
521 views::View* sub_view; | 521 views::View* sub_view; |
522 switch (view_mode_) { | 522 switch (view_mode_) { |
523 case BUBBLE_VIEW_MODE_GAIA_SIGNIN: | 523 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
524 case BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: | 524 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
525 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); | 525 layout = CreateSingleColumnLayout(this, kFixedGaiaViewWidth); |
526 sub_view = CreateGaiaSigninView( | 526 sub_view = CreateGaiaSigninView( |
527 view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); | 527 view_mode_ == BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); |
528 break; | 528 break; |
529 case BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: | 529 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
530 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); | 530 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); |
531 sub_view = CreateAccountRemovalView(); | 531 sub_view = CreateAccountRemovalView(); |
532 break; | 532 break; |
533 case BUBBLE_VIEW_MODE_END_PREVIEW: | 533 case profiles::BUBBLE_VIEW_MODE_END_PREVIEW: |
534 layout = CreateSingleColumnLayout(this, kFixedEndPreviewViewWidth); | 534 layout = CreateSingleColumnLayout(this, kFixedEndPreviewViewWidth); |
535 sub_view = CreateEndPreviewView(); | 535 sub_view = CreateEndPreviewView(); |
536 break; | 536 break; |
537 default: | 537 default: |
538 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 538 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); |
539 sub_view = CreateProfileChooserView(avatar_menu, last_tutorial_mode); | 539 sub_view = CreateProfileChooserView(avatar_menu, last_tutorial_mode); |
540 } | 540 } |
541 sub_view->set_background(views::Background::CreateSolidBackground( | 541 sub_view->set_background(views::Background::CreateSolidBackground( |
542 GetNativeTheme()->GetSystemColor( | 542 GetNativeTheme()->GetSystemColor( |
543 ui::NativeTheme::kColorId_DialogBackground))); | 543 ui::NativeTheme::kColorId_DialogBackground))); |
(...skipping 28 matching lines...) Expand all Loading... | |
572 } else if (sender == tutorial_ok_button_) { | 572 } else if (sender == tutorial_ok_button_) { |
573 // If the user manually dismissed the tutorial, never show it again by | 573 // If the user manually dismissed the tutorial, never show it again by |
574 // setting the number of times shown to the maximum plus 1, so that later we | 574 // setting the number of times shown to the maximum plus 1, so that later we |
575 // could distinguish between the dismiss case and the case when the tutorial | 575 // could distinguish between the dismiss case and the case when the tutorial |
576 // is indeed shown for the maximum number of times. | 576 // is indeed shown for the maximum number of times. |
577 browser_->profile()->GetPrefs()->SetInteger( | 577 browser_->profile()->GetPrefs()->SetInteger( |
578 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); | 578 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); |
579 | 579 |
580 ProfileMetrics::LogProfileUpgradeEnrollment( | 580 ProfileMetrics::LogProfileUpgradeEnrollment( |
581 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD); | 581 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD); |
582 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 582 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
583 } else if (sender == tutorial_enable_new_profile_management_button_) { | 583 } else if (sender == tutorial_enable_new_profile_management_button_) { |
584 ProfileMetrics::LogProfileUpgradeEnrollment( | 584 ProfileMetrics::LogProfileUpgradeEnrollment( |
585 ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT); | 585 ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT); |
586 profiles::EnableNewProfileManagementPreview(); | 586 profiles::EnableNewProfileManagementPreview(); |
587 } else if (sender == remove_account_button_) { | 587 } else if (sender == remove_account_button_) { |
588 RemoveAccount(); | 588 RemoveAccount(); |
589 } else if (sender == account_removal_cancel_button_) { | 589 } else if (sender == account_removal_cancel_button_) { |
590 account_id_to_remove_.clear(); | 590 account_id_to_remove_.clear(); |
591 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 591 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
592 } else if (sender == gaia_signin_cancel_button_) { | 592 } else if (sender == gaia_signin_cancel_button_) { |
593 std::string primary_account = | 593 std::string primary_account = |
594 SigninManagerFactory::GetForProfile(browser_->profile())-> | 594 SigninManagerFactory::GetForProfile(browser_->profile())-> |
595 GetAuthenticatedUsername(); | 595 GetAuthenticatedUsername(); |
596 ShowView(primary_account.empty() ? BUBBLE_VIEW_MODE_PROFILE_CHOOSER : | 596 ShowView(primary_account.empty() ? BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
597 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, | 597 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, |
598 avatar_menu_.get()); | 598 avatar_menu_.get()); |
599 } else if (sender == question_mark_button_) { | 599 } else if (sender == question_mark_button_) { |
600 tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK; | 600 tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK; |
601 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 601 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
602 } else if (sender == tutorial_send_feedback_button_) { | 602 } else if (sender == tutorial_send_feedback_button_) { |
603 ProfileMetrics::LogProfileUpgradeEnrollment( | 603 ProfileMetrics::LogProfileUpgradeEnrollment( |
604 ProfileMetrics::PROFILE_ENROLLMENT_SEND_FEEDBACK); | 604 ProfileMetrics::PROFILE_ENROLLMENT_SEND_FEEDBACK); |
605 chrome::OpenFeedbackDialog(browser_); | 605 chrome::OpenFeedbackDialog(browser_); |
606 } else if (sender == end_preview_and_relaunch_button_) { | 606 } else if (sender == end_preview_and_relaunch_button_) { |
607 ProfileMetrics::LogProfileUpgradeEnrollment( | 607 ProfileMetrics::LogProfileUpgradeEnrollment( |
608 ProfileMetrics::PROFILE_ENROLLMENT_DISABLE_NEW_PROFILE_MGMT); | 608 ProfileMetrics::PROFILE_ENROLLMENT_DISABLE_NEW_PROFILE_MGMT); |
609 profiles::DisableNewProfileManagementPreview(); | 609 profiles::DisableNewProfileManagementPreview(); |
610 } else if (sender == end_preview_cancel_button_) { | 610 } else if (sender == end_preview_cancel_button_) { |
611 tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK; | 611 tutorial_mode_ = TUTORIAL_MODE_SEND_FEEDBACK; |
612 ShowView(BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 612 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
613 } else if (current_profile_photo_ && | 613 } else if (current_profile_photo_ && |
614 sender == current_profile_photo_->change_photo_button()) { | 614 sender == current_profile_photo_->change_photo_button()) { |
615 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 615 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
616 } else if (sender == signin_current_profile_link_) { | 616 } else if (sender == signin_current_profile_link_) { |
617 // Only show the inline signin if the new UI flag is flipped. Otherwise, | 617 // Only show the inline signin if the new UI flag is flipped. Otherwise, |
618 // use the tab signin page. | 618 // use the tab signin page. |
619 if (switches::IsNewProfileManagement()) | 619 if (switches::IsNewProfileManagement()) |
620 ShowView(BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); | 620 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); |
621 else | 621 else |
622 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); | 622 chrome::ShowBrowserSignin(browser_, signin::SOURCE_MENU); |
623 } else { | 623 } else { |
624 // Either one of the "other profiles", or one of the profile accounts | 624 // Either one of the "other profiles", or one of the profile accounts |
625 // buttons was pressed. | 625 // buttons was pressed. |
626 ButtonIndexes::const_iterator profile_match = | 626 ButtonIndexes::const_iterator profile_match = |
627 open_other_profile_indexes_map_.find(sender); | 627 open_other_profile_indexes_map_.find(sender); |
628 if (profile_match != open_other_profile_indexes_map_.end()) { | 628 if (profile_match != open_other_profile_indexes_map_.end()) { |
629 avatar_menu_->SwitchToProfile( | 629 avatar_menu_->SwitchToProfile( |
630 profile_match->second, | 630 profile_match->second, |
631 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, | 631 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, |
632 ProfileMetrics::SWITCH_PROFILE_ICON); | 632 ProfileMetrics::SWITCH_PROFILE_ICON); |
633 } else { | 633 } else { |
634 // This was a profile accounts button. | 634 // This was a profile accounts button. |
635 AccountButtonIndexes::const_iterator account_match = | 635 AccountButtonIndexes::const_iterator account_match = |
636 current_profile_accounts_map_.find(sender); | 636 current_profile_accounts_map_.find(sender); |
637 DCHECK(account_match != current_profile_accounts_map_.end()); | 637 DCHECK(account_match != current_profile_accounts_map_.end()); |
638 account_id_to_remove_ = account_match->second; | 638 account_id_to_remove_ = account_match->second; |
639 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); | 639 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, avatar_menu_.get()); |
640 } | 640 } |
641 } | 641 } |
642 } | 642 } |
643 | 643 |
644 void ProfileChooserView::RemoveAccount() { | 644 void ProfileChooserView::RemoveAccount() { |
645 DCHECK(!account_id_to_remove_.empty()); | 645 DCHECK(!account_id_to_remove_.empty()); |
646 MutableProfileOAuth2TokenService* oauth2_token_service = | 646 MutableProfileOAuth2TokenService* oauth2_token_service = |
647 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( | 647 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
648 browser_->profile()); | 648 browser_->profile()); |
649 if (oauth2_token_service) | 649 if (oauth2_token_service) |
650 oauth2_token_service->RevokeCredentials(account_id_to_remove_); | 650 oauth2_token_service->RevokeCredentials(account_id_to_remove_); |
651 account_id_to_remove_.clear(); | 651 account_id_to_remove_.clear(); |
652 | 652 |
653 ShowView(BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 653 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
654 } | 654 } |
655 | 655 |
656 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { | 656 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { |
657 if (sender == manage_accounts_link_) { | 657 if (sender == manage_accounts_link_) { |
658 // This link can either mean show/hide the account management view, | 658 // This link can either mean show/hide the account management view, |
659 // depending on which view it is displayed. ShowView() will DCHECK if | 659 // depending on which view it is displayed. ShowView() will DCHECK if |
660 // the account management view is displayed for non signed-in users. | 660 // the account management view is displayed for non signed-in users. |
661 ShowView( | 661 ShowView( |
662 view_mode_ == BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? | 662 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? |
663 BUBBLE_VIEW_MODE_PROFILE_CHOOSER : | 663 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
664 BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, | 664 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, |
665 avatar_menu_.get()); | 665 avatar_menu_.get()); |
666 } else if (sender == add_account_link_) { | 666 } else if (sender == add_account_link_) { |
667 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 667 ShowView(BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
668 } else if (sender == tutorial_learn_more_link_) { | 668 } else if (sender == tutorial_learn_more_link_) { |
669 ProfileMetrics::LogProfileUpgradeEnrollment( | 669 ProfileMetrics::LogProfileUpgradeEnrollment( |
670 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); | 670 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); |
671 // TODO(guohui): update |learn_more_url| once it is decided. | 671 // TODO(guohui): update |learn_more_url| once it is decided. |
672 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); | 672 const GURL lear_more_url("https://support.google.com/chrome/?hl=en#to"); |
673 chrome::NavigateParams params( | 673 chrome::NavigateParams params( |
674 browser_->profile(), | 674 browser_->profile(), |
675 lear_more_url, | 675 lear_more_url, |
676 content::PAGE_TRANSITION_LINK); | 676 content::PAGE_TRANSITION_LINK); |
677 params.disposition = NEW_FOREGROUND_TAB; | 677 params.disposition = NEW_FOREGROUND_TAB; |
678 chrome::Navigate(¶ms); | 678 chrome::Navigate(¶ms); |
679 } else { | 679 } else { |
680 DCHECK(sender == tutorial_end_preview_link_); | 680 DCHECK(sender == tutorial_end_preview_link_); |
681 ShowView(BUBBLE_VIEW_MODE_END_PREVIEW, avatar_menu_.get()); | 681 ShowView(profiles::BUBBLE_VIEW_MODE_END_PREVIEW, avatar_menu_.get()); |
682 } | 682 } |
683 } | 683 } |
684 | 684 |
685 void ProfileChooserView::StyledLabelLinkClicked( | 685 void ProfileChooserView::StyledLabelLinkClicked( |
686 const gfx::Range& range, int event_flags) { | 686 const gfx::Range& range, int event_flags) { |
687 chrome::ShowSettings(browser_); | 687 chrome::ShowSettings(browser_); |
688 } | 688 } |
689 | 689 |
690 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, | 690 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, |
691 const ui::KeyEvent& key_event) { | 691 const ui::KeyEvent& key_event) { |
(...skipping 19 matching lines...) Expand all Loading... | |
711 | 711 |
712 profiles::UpdateProfileName(profile, new_profile_name); | 712 profiles::UpdateProfileName(profile, new_profile_name); |
713 current_profile_name_->ShowReadOnlyView(); | 713 current_profile_name_->ShowReadOnlyView(); |
714 return true; | 714 return true; |
715 } | 715 } |
716 return false; | 716 return false; |
717 } | 717 } |
718 | 718 |
719 views::View* ProfileChooserView::CreateProfileChooserView( | 719 views::View* ProfileChooserView::CreateProfileChooserView( |
720 AvatarMenu* avatar_menu, | 720 AvatarMenu* avatar_menu, |
721 TutorialMode last_tutorial_mode) { | 721 profiles::TutorialMode last_tutorial_mode) { |
722 // TODO(guohui, noms): the view should be customized based on whether new | 722 // TODO(guohui, noms): the view should be customized based on whether new |
723 // profile management preview is enabled or not. | 723 // profile management preview is enabled or not. |
724 | 724 |
725 views::View* view = new views::View(); | 725 views::View* view = new views::View(); |
726 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 726 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
727 // Separate items into active and alternatives. | 727 // Separate items into active and alternatives. |
728 Indexes other_profiles; | 728 Indexes other_profiles; |
729 views::View* tutorial_view = NULL; | 729 views::View* tutorial_view = NULL; |
730 views::View* current_profile_view = NULL; | 730 views::View* current_profile_view = NULL; |
731 views::View* current_profile_accounts = NULL; | 731 views::View* current_profile_accounts = NULL; |
732 views::View* option_buttons_view = NULL; | 732 views::View* option_buttons_view = NULL; |
733 bool is_new_profile_management = switches::IsNewProfileManagement(); | 733 bool is_new_profile_management = switches::IsNewProfileManagement(); |
734 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 734 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
735 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 735 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
736 if (item.active) { | 736 if (item.active) { |
737 option_buttons_view = CreateOptionsView(item.signed_in); | 737 option_buttons_view = CreateOptionsView(item.signed_in); |
738 current_profile_view = CreateCurrentProfileView(item, false); | 738 current_profile_view = CreateCurrentProfileView(item, false); |
739 if (view_mode_ == BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { | 739 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { |
740 if (is_new_profile_management) { | 740 if (is_new_profile_management) { |
741 tutorial_view = last_tutorial_mode == TUTORIAL_MODE_SEND_FEEDBACK ? | 741 tutorial_view = |
742 last_tutorial_mode == profiles::TUTORIAL_MODE_SEND_FEEDBACK ? | |
742 CreateSendPreviewFeedbackView() : | 743 CreateSendPreviewFeedbackView() : |
743 CreatePreviewEnabledTutorialView( | 744 CreatePreviewEnabledTutorialView( |
744 item, last_tutorial_mode == TUTORIAL_MODE_PREVIEW_ENABLED); | 745 item, |
746 last_tutorial_mode == | |
747 profiles::TUTORIAL_MODE_WELCOME); | |
msw
2014/05/21 19:42:47
nit: fits on the line above.
Mike Lerman
2014/05/21 19:53:10
Done.
| |
745 } else { | 748 } else { |
746 tutorial_view = CreateNewProfileManagementPreviewView(); | 749 tutorial_view = CreateNewProfileManagementPreviewView(); |
747 } | 750 } |
748 } else { | 751 } else { |
749 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 752 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
750 } | 753 } |
751 } else { | 754 } else { |
752 other_profiles.push_back(i); | 755 other_profiles.push_back(i); |
753 } | 756 } |
754 } | 757 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
811 return NULL; | 814 return NULL; |
812 | 815 |
813 if (!tutorial_shown) { | 816 if (!tutorial_shown) { |
814 if (show_count == kProfileAvatarTutorialShowMax) | 817 if (show_count == kProfileAvatarTutorialShowMax) |
815 return NULL; | 818 return NULL; |
816 profile->GetPrefs()->SetInteger( | 819 profile->GetPrefs()->SetInteger( |
817 prefs::kProfileAvatarTutorialShown, show_count + 1); | 820 prefs::kProfileAvatarTutorialShown, show_count + 1); |
818 } | 821 } |
819 | 822 |
820 return CreateTutorialView( | 823 return CreateTutorialView( |
821 TUTORIAL_MODE_PREVIEW_ENABLED, | 824 TUTORIAL_MODE_WELCOME, |
822 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE), | 825 l10n_util::GetStringUTF16(IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_TITLE), |
823 l10n_util::GetStringUTF16( | 826 l10n_util::GetStringUTF16( |
824 IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT), | 827 IDS_PROFILES_PREVIEW_ENABLED_TUTORIAL_CONTENT_TEXT), |
825 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), | 828 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), |
826 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), | 829 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), |
827 &tutorial_learn_more_link_, | 830 &tutorial_learn_more_link_, |
828 &tutorial_ok_button_); | 831 &tutorial_ok_button_); |
829 } | 832 } |
830 | 833 |
831 views::View* ProfileChooserView::CreateSendPreviewFeedbackView() { | 834 views::View* ProfileChooserView::CreateSendPreviewFeedbackView() { |
832 return CreateTutorialView( | 835 return CreateTutorialView( |
833 TUTORIAL_MODE_SEND_FEEDBACK, | 836 TUTORIAL_MODE_SEND_FEEDBACK, |
834 l10n_util::GetStringUTF16(IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE), | 837 l10n_util::GetStringUTF16(IDS_PROFILES_FEEDBACK_TUTORIAL_TITLE), |
835 l10n_util::GetStringUTF16( | 838 l10n_util::GetStringUTF16( |
836 IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT), | 839 IDS_PROFILES_FEEDBACK_TUTORIAL_CONTENT_TEXT), |
837 l10n_util::GetStringUTF16(IDS_PROFILES_END_PREVIEW), | 840 l10n_util::GetStringUTF16(IDS_PROFILES_END_PREVIEW), |
838 l10n_util::GetStringUTF16(IDS_PROFILES_SEND_FEEDBACK_BUTTON), | 841 l10n_util::GetStringUTF16(IDS_PROFILES_SEND_FEEDBACK_BUTTON), |
839 &tutorial_end_preview_link_, | 842 &tutorial_end_preview_link_, |
840 &tutorial_send_feedback_button_); | 843 &tutorial_send_feedback_button_); |
841 } | 844 } |
842 | 845 |
843 views::View* ProfileChooserView::CreateTutorialView( | 846 views::View* ProfileChooserView::CreateTutorialView( |
844 TutorialMode tutorial_mode, | 847 profiles::TutorialMode tutorial_mode, |
845 const base::string16& title_text, | 848 const base::string16& title_text, |
846 const base::string16& content_text, | 849 const base::string16& content_text, |
847 const base::string16& link_text, | 850 const base::string16& link_text, |
848 const base::string16& button_text, | 851 const base::string16& button_text, |
849 views::Link** link, | 852 views::Link** link, |
850 views::LabelButton** button) { | 853 views::LabelButton** button) { |
851 tutorial_mode_ = tutorial_mode; | 854 tutorial_mode_ = tutorial_mode; |
852 | 855 |
853 views::View* view = new views::View(); | 856 views::View* view = new views::View(); |
854 view->set_background(views::Background::CreateSolidBackground( | 857 view->set_background(views::Background::CreateSolidBackground( |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1304 layout->StartRowWithPadding( | 1307 layout->StartRowWithPadding( |
1305 1, 0, 0, views::kUnrelatedControlVerticalSpacing); | 1308 1, 0, 0, views::kUnrelatedControlVerticalSpacing); |
1306 layout->AddView(end_preview_and_relaunch_button_); | 1309 layout->AddView(end_preview_and_relaunch_button_); |
1307 | 1310 |
1308 TitleCard* title_card = new TitleCard( | 1311 TitleCard* title_card = new TitleCard( |
1309 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); | 1312 IDS_PROFILES_END_PREVIEW, this, &end_preview_cancel_button_); |
1310 return TitleCard::AddPaddedTitleCard( | 1313 return TitleCard::AddPaddedTitleCard( |
1311 view, title_card, kFixedAccountRemovalViewWidth); | 1314 view, title_card, kFixedAccountRemovalViewWidth); |
1312 } | 1315 } |
1313 | 1316 |
OLD | NEW |