| 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" |
| 11 #include "base/strings/string_util.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 15 #include "chrome/browser/lifetime/application_lifetime.h" | 16 #include "chrome/browser/lifetime/application_lifetime.h" |
| 16 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 17 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 17 #include "chrome/browser/profiles/avatar_menu.h" | 18 #include "chrome/browser/profiles/avatar_menu.h" |
| 18 #include "chrome/browser/profiles/avatar_menu_observer.h" | 19 #include "chrome/browser/profiles/avatar_menu_observer.h" |
| 19 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 20 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 20 #include "chrome/browser/profiles/profile_info_cache.h" | 21 #include "chrome/browser/profiles/profile_info_cache.h" |
| 21 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
| 22 #include "chrome/browser/profiles/profile_metrics.h" | 23 #include "chrome/browser/profiles/profile_metrics.h" |
| 23 #include "chrome/browser/profiles/profile_window.h" | 24 #include "chrome/browser/profiles/profile_window.h" |
| 24 #include "chrome/browser/profiles/profiles_state.h" | 25 #include "chrome/browser/profiles/profiles_state.h" |
| 25 #include "chrome/browser/signin/local_auth.h" | 26 #include "chrome/browser/signin/local_auth.h" |
| 26 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 27 #include "chrome/browser/signin/signin_header_helper.h" | 28 #include "chrome/browser/signin/signin_header_helper.h" |
| 28 #include "chrome/browser/signin/signin_manager_factory.h" | 29 #include "chrome/browser/signin/signin_manager_factory.h" |
| 29 #include "chrome/browser/signin/signin_promo.h" | 30 #include "chrome/browser/signin/signin_promo.h" |
| 30 #include "chrome/browser/signin/signin_ui_util.h" | 31 #include "chrome/browser/signin/signin_ui_util.h" |
| 31 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
| 32 #include "chrome/browser/ui/browser_commands.h" | 33 #include "chrome/browser/ui/browser_commands.h" |
| 33 #include "chrome/browser/ui/browser_dialogs.h" | |
| 34 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
| 35 #include "chrome/browser/ui/chrome_pages.h" | 35 #include "chrome/browser/ui/chrome_pages.h" |
| 36 #include "chrome/browser/ui/chrome_style.h" | 36 #include "chrome/browser/ui/chrome_style.h" |
| 37 #include "chrome/browser/ui/user_manager.h" |
| 37 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" | 38 #import "chrome/browser/ui/cocoa/hyperlink_text_view.h" |
| 38 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 39 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 39 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 40 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 40 #import "chrome/browser/ui/cocoa/profiles/user_manager_mac.h" | 41 #import "chrome/browser/ui/cocoa/profiles/user_manager_mac.h" |
| 41 #include "chrome/browser/ui/singleton_tabs.h" | 42 #include "chrome/browser/ui/singleton_tabs.h" |
| 42 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 43 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 43 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 44 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 44 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 45 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
| 46 #include "chrome/grit/chromium_strings.h" | 47 #include "chrome/grit/chromium_strings.h" |
| (...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 | 889 |
| 889 - (IBAction)switchToProfile:(id)sender { | 890 - (IBAction)switchToProfile:(id)sender { |
| 890 // Check the event flags to see if a new window should be created. | 891 // Check the event flags to see if a new window should be created. |
| 891 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( | 892 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( |
| 892 [NSApp currentEvent]) == NEW_WINDOW; | 893 [NSApp currentEvent]) == NEW_WINDOW; |
| 893 avatarMenu_->SwitchToProfile([sender tag], alwaysCreate, | 894 avatarMenu_->SwitchToProfile([sender tag], alwaysCreate, |
| 894 ProfileMetrics::SWITCH_PROFILE_ICON); | 895 ProfileMetrics::SWITCH_PROFILE_ICON); |
| 895 } | 896 } |
| 896 | 897 |
| 897 - (IBAction)showUserManager:(id)sender { | 898 - (IBAction)showUserManager:(id)sender { |
| 898 chrome::ShowUserManager(base::FilePath()); | 899 UserManager::Show(base::FilePath(), |
| 900 profiles::USER_MANAGER_NO_TUTORIAL, |
| 901 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 899 [self postActionPerformed: | 902 [self postActionPerformed: |
| 900 ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER]; | 903 ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER]; |
| 901 } | 904 } |
| 902 | 905 |
| 903 - (IBAction)exitGuest:(id)sender { | 906 - (IBAction)exitGuest:(id)sender { |
| 904 DCHECK(browser_->profile()->IsGuestSession()); | 907 DCHECK(browser_->profile()->IsGuestSession()); |
| 905 chrome::ShowUserManager(base::FilePath()); | 908 UserManager::Show(base::FilePath(), |
| 909 profiles::USER_MANAGER_NO_TUTORIAL, |
| 910 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 906 profiles::CloseGuestProfileWindows(); | 911 profiles::CloseGuestProfileWindows(); |
| 907 } | 912 } |
| 908 | 913 |
| 909 - (IBAction)goIncognito:(id)sender { | 914 - (IBAction)goIncognito:(id)sender { |
| 910 DCHECK([self shouldShowGoIncognito]); | 915 DCHECK([self shouldShowGoIncognito]); |
| 911 chrome::NewIncognitoWindow(browser_); | 916 chrome::NewIncognitoWindow(browser_); |
| 912 } | 917 } |
| 913 | 918 |
| 914 - (IBAction)showAccountManagement:(id)sender { | 919 - (IBAction)showAccountManagement:(id)sender { |
| 915 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; | 920 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 DCHECK(!accountIdToRemove_.empty()); | 974 DCHECK(!accountIdToRemove_.empty()); |
| 970 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( | 975 ProfileOAuth2TokenServiceFactory::GetPlatformSpecificForProfile( |
| 971 browser_->profile())->RevokeCredentials(accountIdToRemove_); | 976 browser_->profile())->RevokeCredentials(accountIdToRemove_); |
| 972 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT]; | 977 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT]; |
| 973 accountIdToRemove_.clear(); | 978 accountIdToRemove_.clear(); |
| 974 | 979 |
| 975 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; | 980 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; |
| 976 } | 981 } |
| 977 | 982 |
| 978 - (IBAction)seeWhatsNew:(id)sender { | 983 - (IBAction)seeWhatsNew:(id)sender { |
| 979 chrome::ShowUserManagerWithTutorial( | 984 UserManager::Show(base::FilePath(), |
| 980 profiles::USER_MANAGER_TUTORIAL_OVERVIEW); | 985 profiles::USER_MANAGER_TUTORIAL_OVERVIEW, |
| 986 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 981 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | 987 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
| 982 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW); | 988 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW); |
| 983 } | 989 } |
| 984 | 990 |
| 985 - (IBAction)showSwitchUserView:(id)sender { | 991 - (IBAction)showSwitchUserView:(id)sender { |
| 986 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_SWITCH_USER]; | 992 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_SWITCH_USER]; |
| 987 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | 993 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
| 988 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); | 994 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); |
| 989 } | 995 } |
| 990 | 996 |
| (...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2185 } | 2191 } |
| 2186 | 2192 |
| 2187 - (bool)shouldShowGoIncognito { | 2193 - (bool)shouldShowGoIncognito { |
| 2188 bool incognitoAvailable = | 2194 bool incognitoAvailable = |
| 2189 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2195 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2190 IncognitoModePrefs::DISABLED; | 2196 IncognitoModePrefs::DISABLED; |
| 2191 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2197 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
| 2192 } | 2198 } |
| 2193 | 2199 |
| 2194 @end | 2200 @end |
| OLD | NEW |