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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
8 | 8 |
9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 - (IBAction)removeAccount:(id)sender { | 815 - (IBAction)removeAccount:(id)sender { |
816 DCHECK(!accountIdToRemove_.empty()); | 816 DCHECK(!accountIdToRemove_.empty()); |
817 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( | 817 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
818 browser_->profile())->RevokeCredentials(accountIdToRemove_); | 818 browser_->profile())->RevokeCredentials(accountIdToRemove_); |
819 accountIdToRemove_.clear(); | 819 accountIdToRemove_.clear(); |
820 | 820 |
821 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; | 821 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; |
822 } | 822 } |
823 | 823 |
824 - (IBAction)openTutorialLearnMoreURL:(id)sender { | 824 - (IBAction)openTutorialLearnMoreURL:(id)sender { |
| 825 ProfileMetrics::LogProfileUpgradeEnrollment( |
| 826 ProfileMetrics::PROFILE_ENROLLMENT_LAUNCH_LEARN_MORE); |
825 // TODO(guohui): update |learnMoreUrl| once it is decided. | 827 // TODO(guohui): update |learnMoreUrl| once it is decided. |
826 const GURL learnMoreUrl("https://support.google.com/chrome/?hl=en#to"); | 828 const GURL learnMoreUrl("https://support.google.com/chrome/?hl=en#to"); |
827 chrome::NavigateParams params(browser_->profile(), learnMoreUrl, | 829 chrome::NavigateParams params(browser_->profile(), learnMoreUrl, |
828 content::PAGE_TRANSITION_LINK); | 830 content::PAGE_TRANSITION_LINK); |
829 params.disposition = NEW_FOREGROUND_TAB; | 831 params.disposition = NEW_FOREGROUND_TAB; |
830 chrome::Navigate(¶ms); | 832 chrome::Navigate(¶ms); |
831 } | 833 } |
832 | 834 |
833 - (IBAction)enableNewProfileManagementPreview:(id)sender { | 835 - (IBAction)enableNewProfileManagementPreview:(id)sender { |
| 836 ProfileMetrics::LogProfileUpgradeEnrollment( |
| 837 ProfileMetrics::PROFILE_ENROLLMENT_ACCEPT_NEW_PROFILE_MGMT); |
834 profiles::EnableNewProfileManagementPreview(); | 838 profiles::EnableNewProfileManagementPreview(); |
835 } | 839 } |
836 | 840 |
837 - (IBAction)dismissTutorial:(id)sender { | 841 - (IBAction)dismissTutorial:(id)sender { |
| 842 ProfileMetrics::LogProfileUpgradeEnrollment( |
| 843 ProfileMetrics::PROFILE_ENROLLMENT_CLOSE_WELCOME_CARD); |
838 // If the user manually dismissed the tutorial, never show it again by setting | 844 // If the user manually dismissed the tutorial, never show it again by setting |
839 // the number of times shown to the maximum plus 1, so that later we could | 845 // the number of times shown to the maximum plus 1, so that later we could |
840 // distinguish between the dismiss case and the case when the tutorial is | 846 // distinguish between the dismiss case and the case when the tutorial is |
841 // indeed shown for the maximum number of times. | 847 // indeed shown for the maximum number of times. |
842 browser_->profile()->GetPrefs()->SetInteger( | 848 browser_->profile()->GetPrefs()->SetInteger( |
843 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); | 849 prefs::kProfileAvatarTutorialShown, kProfileAvatarTutorialShowMax + 1); |
844 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; | 850 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
845 } | 851 } |
846 | 852 |
847 - (IBAction)showSendFeedbackTutorial:(id)sender { | 853 - (IBAction)showSendFeedbackTutorial:(id)sender { |
| 854 ProfileMetrics::LogProfileUpgradeEnrollment( |
| 855 ProfileMetrics::PROFILE_ENROLLMENT_SEND_FEEDBACK); |
848 tutorialMode_ = profiles::TUTORIAL_MODE_SEND_FEEDBACK; | 856 tutorialMode_ = profiles::TUTORIAL_MODE_SEND_FEEDBACK; |
849 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; | 857 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; |
850 } | 858 } |
851 | 859 |
852 - (IBAction)showEndPreviewView:(id)sender { | 860 - (IBAction)showEndPreviewView:(id)sender { |
853 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_END_PREVIEW]; | 861 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_END_PREVIEW]; |
854 } | 862 } |
855 | 863 |
856 - (IBAction)sendFeedback:(id)sender { | 864 - (IBAction)sendFeedback:(id)sender { |
857 chrome::OpenFeedbackDialog(browser_); | 865 chrome::OpenFeedbackDialog(browser_); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 - (NSView*)buildProfileChooserView { | 940 - (NSView*)buildProfileChooserView { |
933 base::scoped_nsobject<NSView> container( | 941 base::scoped_nsobject<NSView> container( |
934 [[NSView alloc] initWithFrame:NSZeroRect]); | 942 [[NSView alloc] initWithFrame:NSZeroRect]); |
935 | 943 |
936 NSView* tutorialView = nil; | 944 NSView* tutorialView = nil; |
937 NSView* currentProfileView = nil; | 945 NSView* currentProfileView = nil; |
938 base::scoped_nsobject<NSMutableArray> otherProfiles( | 946 base::scoped_nsobject<NSMutableArray> otherProfiles( |
939 [[NSMutableArray alloc] init]); | 947 [[NSMutableArray alloc] init]); |
940 // Local and guest profiles cannot lock their profile. | 948 // Local and guest profiles cannot lock their profile. |
941 bool enableLock = false; | 949 bool enableLock = false; |
| 950 // Store the most recently displayed tutorial mode |
| 951 profiles::TutorialMode lastTutorialMode = tutorialMode_; |
942 | 952 |
943 // Loop over the profiles in reverse, so that they are sorted by their | 953 // Loop over the profiles in reverse, so that they are sorted by their |
944 // y-coordinate, and separate them into active and "other" profiles. | 954 // y-coordinate, and separate them into active and "other" profiles. |
945 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { | 955 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { |
946 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); | 956 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); |
947 if (item.active) { | 957 if (item.active) { |
948 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 958 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
949 tutorialView = [self buildPreviewTutorialIfNeeded:item]; | 959 tutorialView = [self buildPreviewTutorialIfNeeded:item]; |
950 currentProfileView = [self createCurrentProfileView:item]; | 960 currentProfileView = [self createCurrentProfileView:item]; |
951 enableLock = item.signed_in; | 961 enableLock = item.signed_in; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 yOffset += kVerticalSpacing; | 1014 yOffset += kVerticalSpacing; |
1005 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1015 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
1006 [container addSubview:currentProfileView]; | 1016 [container addSubview:currentProfileView]; |
1007 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; | 1017 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; |
1008 } | 1018 } |
1009 | 1019 |
1010 if (tutorialView) { | 1020 if (tutorialView) { |
1011 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1021 [tutorialView setFrameOrigin:NSMakePoint(0, yOffset)]; |
1012 [container addSubview:tutorialView]; | 1022 [container addSubview:tutorialView]; |
1013 yOffset = NSMaxY([tutorialView frame]); | 1023 yOffset = NSMaxY([tutorialView frame]); |
| 1024 if (!switches::IsNewProfileManagement() && |
| 1025 tutorialMode_ != lastTutorialMode) { |
| 1026 ProfileMetrics::LogProfileUpgradeEnrollment( |
| 1027 ProfileMetrics::PROFILE_ENROLLMENT_SHOW_PREVIEW_PROMO); |
| 1028 } |
1014 } else { | 1029 } else { |
1015 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1030 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
1016 } | 1031 } |
1017 | 1032 |
1018 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; | 1033 [container setFrameSize:NSMakeSize(kFixedMenuWidth, yOffset)]; |
1019 return container.autorelease();; | 1034 return container.autorelease();; |
1020 } | 1035 } |
1021 | 1036 |
1022 - (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item { | 1037 - (NSView*)buildPreviewTutorialIfNeeded:(const AvatarMenu::Item&)item { |
1023 if (!switches::IsNewProfileManagement()) { | 1038 if (!switches::IsNewProfileManagement()) { |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1695 IDR_CLOSE_1_P).ToNSImage()]; | 1710 IDR_CLOSE_1_P).ToNSImage()]; |
1696 [deleteButton setTarget:self]; | 1711 [deleteButton setTarget:self]; |
1697 [deleteButton setAction:@selector(showAccountRemovalView:)]; | 1712 [deleteButton setAction:@selector(showAccountRemovalView:)]; |
1698 [deleteButton setTag:tag]; | 1713 [deleteButton setTag:tag]; |
1699 | 1714 |
1700 [button addSubview:deleteButton]; | 1715 [button addSubview:deleteButton]; |
1701 return button.autorelease(); | 1716 return button.autorelease(); |
1702 } | 1717 } |
1703 | 1718 |
1704 @end | 1719 @end |
OLD | NEW |