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

Side by Side Diff: chrome/browser/ui/webui/options/manage_profile_handler.cc

Issue 225523004: Updates the UI and reenables the fix introduced in commit 256939 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes chromeos_rel test failure and includes a rebase 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
OLDNEW
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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 17 matching lines...) Expand all
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 "components/signin/core/browser/signin_manager.h" 34 #include "components/signin/core/browser/signin_manager.h"
35 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/notification_service.h" 36 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/web_ui.h" 37 #include "content/public/browser/web_ui.h"
38 #include "google_apis/gaia/gaia_auth_util.h"
38 #include "grit/generated_resources.h" 39 #include "grit/generated_resources.h"
39 #include "grit/google_chrome_strings.h" 40 #include "grit/google_chrome_strings.h"
40 #include "ui/base/l10n/l10n_util.h" 41 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/base/webui/web_ui_util.h" 42 #include "ui/base/webui/web_ui_util.h"
42 43
43 #if defined(ENABLE_SETTINGS_APP) 44 #if defined(ENABLE_SETTINGS_APP)
44 #include "chrome/browser/ui/app_list/app_list_service.h" 45 #include "chrome/browser/ui/app_list/app_list_service.h"
45 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
46 #endif 47 #endif
47 48
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 { "manageProfilesManagedNotSignedInLink", 99 { "manageProfilesManagedNotSignedInLink",
99 IDS_PROFILES_CREATE_MANAGED_NOT_SIGNED_IN_LINK }, 100 IDS_PROFILES_CREATE_MANAGED_NOT_SIGNED_IN_LINK },
100 { "deleteProfileTitle", IDS_PROFILES_DELETE_TITLE }, 101 { "deleteProfileTitle", IDS_PROFILES_DELETE_TITLE },
101 { "deleteProfileOK", IDS_PROFILES_DELETE_OK_BUTTON_LABEL }, 102 { "deleteProfileOK", IDS_PROFILES_DELETE_OK_BUTTON_LABEL },
102 { "deleteProfileMessage", IDS_PROFILES_DELETE_MESSAGE }, 103 { "deleteProfileMessage", IDS_PROFILES_DELETE_MESSAGE },
103 { "deleteManagedProfileAddendum", IDS_PROFILES_DELETE_MANAGED_ADDENDUM }, 104 { "deleteManagedProfileAddendum", IDS_PROFILES_DELETE_MANAGED_ADDENDUM },
104 { "disconnectManagedProfileTitle", 105 { "disconnectManagedProfileTitle",
105 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TITLE }, 106 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TITLE },
106 { "disconnectManagedProfileOK", 107 { "disconnectManagedProfileOK",
107 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_OK_BUTTON_LABEL }, 108 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_OK_BUTTON_LABEL },
108 { "disconnectManagedProfileText",
109 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TEXT },
110 { "disconnectManagedProfileLearnMore",
111 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_LEARN_MORE },
112 { "createProfileTitle", IDS_PROFILES_CREATE_TITLE }, 109 { "createProfileTitle", IDS_PROFILES_CREATE_TITLE },
113 { "createProfileInstructions", IDS_PROFILES_CREATE_INSTRUCTIONS }, 110 { "createProfileInstructions", IDS_PROFILES_CREATE_INSTRUCTIONS },
114 { "createProfileConfirm", IDS_PROFILES_CREATE_CONFIRM }, 111 { "createProfileConfirm", IDS_PROFILES_CREATE_CONFIRM },
115 { "createProfileShortcutCheckbox", IDS_PROFILES_CREATE_SHORTCUT_CHECKBOX }, 112 { "createProfileShortcutCheckbox", IDS_PROFILES_CREATE_SHORTCUT_CHECKBOX },
116 { "createProfileShortcutButton", IDS_PROFILES_CREATE_SHORTCUT_BUTTON }, 113 { "createProfileShortcutButton", IDS_PROFILES_CREATE_SHORTCUT_BUTTON },
117 { "removeProfileShortcutButton", IDS_PROFILES_REMOVE_SHORTCUT_BUTTON }, 114 { "removeProfileShortcutButton", IDS_PROFILES_REMOVE_SHORTCUT_BUTTON },
118 { "importExistingManagedUserLink", 115 { "importExistingManagedUserLink",
119 IDS_PROFILES_IMPORT_EXISTING_MANAGED_USER_LINK }, 116 IDS_PROFILES_IMPORT_EXISTING_MANAGED_USER_LINK },
120 { "signInToImportManagedUsers", 117 { "signInToImportManagedUsers",
121 IDS_PROFILES_IMPORT_MANAGED_USER_NOT_SIGNED_IN }, 118 IDS_PROFILES_IMPORT_MANAGED_USER_NOT_SIGNED_IN },
122 }; 119 };
123 120
124 RegisterStrings(localized_strings, resources, arraysize(resources)); 121 RegisterStrings(localized_strings, resources, arraysize(resources));
125 RegisterTitle(localized_strings, "manageProfile", 122 RegisterTitle(localized_strings, "manageProfile",
126 IDS_PROFILES_MANAGE_TITLE); 123 IDS_PROFILES_MANAGE_TITLE);
127 RegisterTitle(localized_strings, "createProfile", 124 RegisterTitle(localized_strings, "createProfile",
128 IDS_PROFILES_CREATE_TITLE); 125 IDS_PROFILES_CREATE_TITLE);
129 126
130 localized_strings->SetBoolean("profileShortcutsEnabled", 127 localized_strings->SetBoolean("profileShortcutsEnabled",
131 ProfileShortcutManager::IsFeatureEnabled()); 128 ProfileShortcutManager::IsFeatureEnabled());
132 129
133 localized_strings->SetString("enterpriseManagedAccountHelpURL", 130 GenerateSignedinUserSpecificStrings(localized_strings);
134 chrome::kEnterpriseManagedAccountHelpURL);
135 } 131 }
136 132
137 void ManageProfileHandler::InitializeHandler() { 133 void ManageProfileHandler::InitializeHandler() {
138 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, 134 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
139 content::NotificationService::AllSources()); 135 content::NotificationService::AllSources());
140 136
141 Profile* profile = Profile::FromWebUI(web_ui()); 137 Profile* profile = Profile::FromWebUI(web_ui());
142 pref_change_registrar_.Init(profile->GetPrefs()); 138 pref_change_registrar_.Init(profile->GetPrefs());
143 pref_change_registrar_.Add( 139 pref_change_registrar_.Add(
144 prefs::kManagedUserCreationAllowed, 140 prefs::kManagedUserCreationAllowed,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 SendExistingProfileNames(); 196 SendExistingProfileNames();
201 base::StringValue value(kManageProfileIdentifier); 197 base::StringValue value(kManageProfileIdentifier);
202 SendProfileIconsAndNames(value); 198 SendProfileIconsAndNames(value);
203 } 199 }
204 } 200 }
205 201
206 void ManageProfileHandler::OnStateChanged() { 202 void ManageProfileHandler::OnStateChanged() {
207 RequestCreateProfileUpdate(NULL); 203 RequestCreateProfileUpdate(NULL);
208 } 204 }
209 205
206 void ManageProfileHandler::GenerateSignedinUserSpecificStrings(
207 base::DictionaryValue* dictionary) {
208 #if !defined(OS_CHROMEOS)
209 Profile* profile = Profile::FromWebUI(web_ui());
210 DCHECK(profile);
211 SigninManagerBase* manager = SigninManagerFactory::GetForProfile(profile);
212 DCHECK(manager);
213 std::string username = manager->GetAuthenticatedUsername();
214 std::string domain_name;
215 // If there is no one logged in or if the profile name is empty then the
216 // domain name is empty. This happens in browser tests.
217 if (!username.empty())
218 domain_name = "<span id=disconnect-managed-profile-domain-name>" +
219 gaia::ExtractDomainName(username) + "</span>";
220
221 dictionary->SetString(
222 "disconnectManagedProfileDomainInformation",
223 l10n_util::GetStringFUTF16(
224 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_DOMAIN_INFORMATION,
225 base::ASCIIToUTF16(domain_name)));
226
227 dictionary->SetString(
228 "disconnectManagedProfileText",
229 l10n_util::GetStringFUTF16(
230 IDS_PROFILES_DISCONNECT_MANAGED_PROFILE_TEXT,
231 base::UTF8ToUTF16(username),
232 base::UTF8ToUTF16(chrome::kSyncGoogleDashboardURL)));
233 #else
234 dictionary->SetString("disconnectManagedProfileDomainInformation",
235 base::string16());
236 dictionary->SetString("disconnectManagedProfileText",
237 base::string16());
238 #endif
239 }
240
210 void ManageProfileHandler::RequestDefaultProfileIcons( 241 void ManageProfileHandler::RequestDefaultProfileIcons(
211 const base::ListValue* args) { 242 const base::ListValue* args) {
212 std::string mode; 243 std::string mode;
213 bool ok = args->GetString(0, &mode); 244 bool ok = args->GetString(0, &mode);
214 DCHECK(ok); 245 DCHECK(ok);
215 DCHECK(mode == kCreateProfileIdentifier || mode == kManageProfileIdentifier); 246 DCHECK(mode == kCreateProfileIdentifier || mode == kManageProfileIdentifier);
216 if (ok) { 247 if (ok) {
217 base::StringValue value(mode); 248 base::StringValue value(mode);
218 SendProfileIconsAndNames(value); 249 SendProfileIconsAndNames(value);
219 } 250 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 ProfileSyncService* service = 458 ProfileSyncService* service =
428 ProfileSyncServiceFactory::GetForProfile(profile); 459 ProfileSyncServiceFactory::GetForProfile(profile);
429 GoogleServiceAuthError::State state = service->GetAuthError().state(); 460 GoogleServiceAuthError::State state = service->GetAuthError().state();
430 bool has_error = (state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || 461 bool has_error = (state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
431 state == GoogleServiceAuthError::USER_NOT_SIGNED_UP || 462 state == GoogleServiceAuthError::USER_NOT_SIGNED_UP ||
432 state == GoogleServiceAuthError::ACCOUNT_DELETED || 463 state == GoogleServiceAuthError::ACCOUNT_DELETED ||
433 state == GoogleServiceAuthError::ACCOUNT_DISABLED); 464 state == GoogleServiceAuthError::ACCOUNT_DISABLED);
434 web_ui()->CallJavascriptFunction("CreateProfileOverlay.updateSignedInStatus", 465 web_ui()->CallJavascriptFunction("CreateProfileOverlay.updateSignedInStatus",
435 base::StringValue(username), 466 base::StringValue(username),
436 base::FundamentalValue(has_error)); 467 base::FundamentalValue(has_error));
468
469 base::DictionaryValue replacements;
470 GenerateSignedinUserSpecificStrings(&replacements);
471 web_ui()->CallJavascriptFunction("loadTimeData.overrideValues", replacements);
472
437 OnCreateManagedUserPrefChange(); 473 OnCreateManagedUserPrefChange();
438 } 474 }
439 475
440 void ManageProfileHandler::OnCreateManagedUserPrefChange() { 476 void ManageProfileHandler::OnCreateManagedUserPrefChange() {
441 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 477 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
442 base::FundamentalValue allowed( 478 base::FundamentalValue allowed(
443 prefs->GetBoolean(prefs::kManagedUserCreationAllowed)); 479 prefs->GetBoolean(prefs::kManagedUserCreationAllowed));
444 web_ui()->CallJavascriptFunction( 480 web_ui()->CallJavascriptFunction(
445 "CreateProfileOverlay.updateManagedUsersAllowed", allowed); 481 "CreateProfileOverlay.updateManagedUsersAllowed", allowed);
446 } 482 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 g_browser_process->profile_manager()->profile_shortcut_manager(); 515 g_browser_process->profile_manager()->profile_shortcut_manager();
480 DCHECK(shortcut_manager); 516 DCHECK(shortcut_manager);
481 517
482 shortcut_manager->RemoveProfileShortcuts(profile_file_path); 518 shortcut_manager->RemoveProfileShortcuts(profile_file_path);
483 519
484 // Update the UI buttons. 520 // Update the UI buttons.
485 OnHasProfileShortcuts(false); 521 OnHasProfileShortcuts(false);
486 } 522 }
487 523
488 } // namespace options 524 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.h ('k') | chrome/browser/ui/webui/options/options_ui_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698