| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/webui/options/manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/prefs/scoped_user_pref_update.h" | 10 #include "base/prefs/scoped_user_pref_update.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "chrome/browser/signin/signin_manager_factory.h" | 27 #include "chrome/browser/signin/signin_manager_factory.h" |
| 28 #include "chrome/browser/sync/profile_sync_service.h" | 28 #include "chrome/browser/sync/profile_sync_service.h" |
| 29 #include "chrome/browser/sync/profile_sync_service_factory.h" | 29 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 30 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
| 31 #include "chrome/browser/ui/webui/options/options_handlers_helper.h" | 31 #include "chrome/browser/ui/webui/options/options_handlers_helper.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/generated_resources.h" | 34 #include "chrome/grit/generated_resources.h" |
| 35 #include "chrome/grit/google_chrome_strings.h" | 35 #include "chrome/grit/google_chrome_strings.h" |
| 36 #include "components/signin/core/browser/signin_manager.h" | 36 #include "components/signin/core/browser/signin_manager.h" |
| 37 #include "components/signin/core/common/profile_management_switches.h" | |
| 38 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
| 40 #include "content/public/browser/web_ui.h" | 39 #include "content/public/browser/web_ui.h" |
| 41 #include "google_apis/gaia/gaia_auth_util.h" | 40 #include "google_apis/gaia/gaia_auth_util.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "ui/base/webui/web_ui_util.h" | 42 #include "ui/base/webui/web_ui_util.h" |
| 44 | 43 |
| 45 #if defined(ENABLE_SETTINGS_APP) | 44 #if defined(ENABLE_SETTINGS_APP) |
| 46 #include "chrome/browser/ui/app_list/app_list_service.h" | 45 #include "chrome/browser/ui/app_list/app_list_service.h" |
| 47 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 75 ProfileSyncServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); | 74 ProfileSyncServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); |
| 76 // Sync may be disabled in tests. | 75 // Sync may be disabled in tests. |
| 77 if (service) | 76 if (service) |
| 78 service->RemoveObserver(this); | 77 service->RemoveObserver(this); |
| 79 } | 78 } |
| 80 | 79 |
| 81 void ManageProfileHandler::GetLocalizedValues( | 80 void ManageProfileHandler::GetLocalizedValues( |
| 82 base::DictionaryValue* localized_strings) { | 81 base::DictionaryValue* localized_strings) { |
| 83 DCHECK(localized_strings); | 82 DCHECK(localized_strings); |
| 84 | 83 |
| 85 const bool using_new_profiles_ui = switches::IsNewAvatarMenu(); | |
| 86 | |
| 87 static OptionsStringResource resources[] = { | 84 static OptionsStringResource resources[] = { |
| 88 { "manageProfilesNameLabel", IDS_PROFILES_MANAGE_NAME_LABEL }, | 85 { "manageProfilesNameLabel", IDS_PROFILES_MANAGE_NAME_LABEL }, |
| 89 { "manageProfilesDuplicateNameError", | 86 { "manageProfilesDuplicateNameError", |
| 90 IDS_PROFILES_MANAGE_DUPLICATE_NAME_ERROR }, | 87 IDS_PROFILES_MANAGE_DUPLICATE_NAME_ERROR }, |
| 91 { "manageProfilesIconLabel", IDS_PROFILES_MANAGE_ICON_LABEL }, | 88 { "manageProfilesIconLabel", IDS_PROFILES_MANAGE_ICON_LABEL }, |
| 92 { "manageProfilesExistingSupervisedUser", | 89 { "manageProfilesExistingSupervisedUser", |
| 93 IDS_PROFILES_CREATE_EXISTING_SUPERVISED_USER_ERROR }, | 90 IDS_PROFILES_CREATE_EXISTING_SUPERVISED_USER_ERROR }, |
| 94 { "manageProfilesSupervisedSignedInLabel", | 91 { "manageProfilesSupervisedSignedInLabel", |
| 95 IDS_PROFILES_CREATE_SUPERVISED_SIGNED_IN_LABEL }, | 92 IDS_PROFILES_CREATE_SUPERVISED_SIGNED_IN_LABEL }, |
| 96 { "manageProfilesSupervisedNotSignedIn", | 93 { "manageProfilesSupervisedNotSignedIn", |
| 97 IDS_PROFILES_CREATE_SUPERVISED_NOT_SIGNED_IN_HTML }, | 94 IDS_PROFILES_CREATE_SUPERVISED_NOT_SIGNED_IN_HTML }, |
| 98 { "manageProfilesSupervisedAccountDetailsOutOfDate", | 95 { "manageProfilesSupervisedAccountDetailsOutOfDate", |
| 99 IDS_PROFILES_CREATE_SUPERVISED_ACCOUNT_DETAILS_OUT_OF_DATE_LABEL }, | 96 IDS_PROFILES_CREATE_SUPERVISED_ACCOUNT_DETAILS_OUT_OF_DATE_LABEL }, |
| 100 { "manageProfilesSupervisedSignInAgainLink", | 97 { "manageProfilesSupervisedSignInAgainLink", |
| 101 IDS_PROFILES_CREATE_SUPERVISED_SIGN_IN_AGAIN_LINK }, | 98 IDS_PROFILES_CREATE_SUPERVISED_SIGN_IN_AGAIN_LINK }, |
| 102 { "manageProfilesConfirm", using_new_profiles_ui ? IDS_SAVE : IDS_OK }, | 99 { "manageProfilesConfirm", IDS_SAVE }, |
| 103 { "deleteProfileTitle", using_new_profiles_ui ? | 100 { "deleteProfileTitle", IDS_NEW_PROFILES_DELETE_TITLE }, |
| 104 IDS_NEW_PROFILES_DELETE_TITLE : IDS_PROFILES_DELETE_TITLE }, | 101 { "deleteProfileOK", IDS_NEW_PROFILES_DELETE_OK_BUTTON_LABEL }, |
| 105 { "deleteProfileOK", using_new_profiles_ui ? | 102 { "deleteProfileMessage", IDS_NEW_PROFILES_DELETE_MESSAGE }, |
| 106 IDS_NEW_PROFILES_DELETE_OK_BUTTON_LABEL : | |
| 107 IDS_PROFILES_DELETE_OK_BUTTON_LABEL }, | |
| 108 { "deleteProfileMessage", using_new_profiles_ui ? | |
| 109 IDS_NEW_PROFILES_DELETE_MESSAGE : IDS_PROFILES_DELETE_MESSAGE }, | |
| 110 { "deleteSupervisedProfileAddendum", | 103 { "deleteSupervisedProfileAddendum", |
| 111 IDS_PROFILES_DELETE_SUPERVISED_ADDENDUM }, | 104 IDS_PROFILES_DELETE_SUPERVISED_ADDENDUM }, |
| 112 { "disconnectManagedProfileTitle", | 105 { "disconnectManagedProfileTitle", |
| 113 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TITLE }, | 106 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TITLE }, |
| 114 { "disconnectManagedProfileOK", | 107 { "disconnectManagedProfileOK", |
| 115 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_OK_BUTTON_LABEL }, | 108 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_OK_BUTTON_LABEL }, |
| 116 { "createProfileTitle", using_new_profiles_ui ? | 109 { "createProfileTitle", IDS_NEW_PROFILES_CREATE_TITLE }, |
| 117 IDS_NEW_PROFILES_CREATE_TITLE : IDS_PROFILES_CREATE_TITLE }, | |
| 118 { "createProfileInstructions", IDS_PROFILES_CREATE_INSTRUCTIONS }, | 110 { "createProfileInstructions", IDS_PROFILES_CREATE_INSTRUCTIONS }, |
| 119 { "createProfileConfirm", using_new_profiles_ui ? | 111 { "createProfileConfirm", IDS_ADD }, |
| 120 IDS_ADD : IDS_PROFILES_CREATE_CONFIRM }, | |
| 121 { "createProfileShortcutCheckbox", IDS_PROFILES_CREATE_SHORTCUT_CHECKBOX }, | 112 { "createProfileShortcutCheckbox", IDS_PROFILES_CREATE_SHORTCUT_CHECKBOX }, |
| 122 { "createProfileShortcutButton", IDS_PROFILES_CREATE_SHORTCUT_BUTTON }, | 113 { "createProfileShortcutButton", IDS_PROFILES_CREATE_SHORTCUT_BUTTON }, |
| 123 { "removeProfileShortcutButton", IDS_PROFILES_REMOVE_SHORTCUT_BUTTON }, | 114 { "removeProfileShortcutButton", IDS_PROFILES_REMOVE_SHORTCUT_BUTTON }, |
| 124 { "importExistingSupervisedUserLink", | 115 { "importExistingSupervisedUserLink", |
| 125 IDS_PROFILES_IMPORT_EXISTING_SUPERVISED_USER_LINK }, | 116 IDS_PROFILES_IMPORT_EXISTING_SUPERVISED_USER_LINK }, |
| 126 }; | 117 }; |
| 127 | 118 |
| 128 RegisterStrings(localized_strings, resources, arraysize(resources)); | 119 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 129 RegisterTitle(localized_strings, "manageProfile", | 120 RegisterTitle(localized_strings, "manageProfile", |
| 130 using_new_profiles_ui ? IDS_NEW_PROFILES_MANAGE_TITLE : | 121 IDS_NEW_PROFILES_MANAGE_TITLE); |
| 131 IDS_PROFILES_MANAGE_TITLE); | |
| 132 RegisterTitle(localized_strings, "createProfile", | 122 RegisterTitle(localized_strings, "createProfile", |
| 133 using_new_profiles_ui ? IDS_NEW_PROFILES_CREATE_TITLE : | 123 IDS_NEW_PROFILES_CREATE_TITLE); |
| 134 IDS_PROFILES_CREATE_TITLE); | |
| 135 | 124 |
| 136 localized_strings->SetBoolean("profileShortcutsEnabled", | 125 localized_strings->SetBoolean("profileShortcutsEnabled", |
| 137 ProfileShortcutManager::IsFeatureEnabled()); | 126 ProfileShortcutManager::IsFeatureEnabled()); |
| 138 | 127 |
| 139 GenerateSignedinUserSpecificStrings(localized_strings); | 128 GenerateSignedinUserSpecificStrings(localized_strings); |
| 140 } | 129 } |
| 141 | 130 |
| 142 void ManageProfileHandler::InitializeHandler() { | 131 void ManageProfileHandler::InitializeHandler() { |
| 143 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 132 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 144 content::NotificationService::AllSources()); | 133 content::NotificationService::AllSources()); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 | 529 |
| 541 // Update the UI buttons. | 530 // Update the UI buttons. |
| 542 OnHasProfileShortcuts(false); | 531 OnHasProfileShortcuts(false); |
| 543 } | 532 } |
| 544 | 533 |
| 545 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { | 534 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { |
| 546 profiles::UpdateGaiaProfilePhotoIfNeeded(Profile::FromWebUI(web_ui())); | 535 profiles::UpdateGaiaProfilePhotoIfNeeded(Profile::FromWebUI(web_ui())); |
| 547 } | 536 } |
| 548 | 537 |
| 549 } // namespace options | 538 } // namespace options |
| OLD | NEW |