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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 211
212 void ManageProfileHandler::OnProfileWasRemoved( 212 void ManageProfileHandler::OnProfileWasRemoved(
213 const base::FilePath& profile_path, 213 const base::FilePath& profile_path,
214 const base::string16& profile_name) { 214 const base::string16& profile_name) {
215 SendExistingProfileNames(); 215 SendExistingProfileNames();
216 } 216 }
217 217
218 void ManageProfileHandler::OnProfileNameChanged( 218 void ManageProfileHandler::OnProfileNameChanged(
219 const base::FilePath& profile_path, 219 const base::FilePath& profile_path,
220 const base::string16& old_profile_name) { 220 const base::string16& old_profile_name) {
221 base::StringValue value(kManageProfileIdentifier); 221 base::Value value(kManageProfileIdentifier);
222 SendProfileIconsAndNames(value); 222 SendProfileIconsAndNames(value);
223 } 223 }
224 224
225 void ManageProfileHandler::OnProfileAvatarChanged( 225 void ManageProfileHandler::OnProfileAvatarChanged(
226 const base::FilePath& profile_path) { 226 const base::FilePath& profile_path) {
227 base::StringValue value(kManageProfileIdentifier); 227 base::Value value(kManageProfileIdentifier);
228 SendProfileIconsAndNames(value); 228 SendProfileIconsAndNames(value);
229 } 229 }
230 230
231 void ManageProfileHandler::OnStateChanged(syncer::SyncService* sync) { 231 void ManageProfileHandler::OnStateChanged(syncer::SyncService* sync) {
232 RequestCreateProfileUpdate(NULL); 232 RequestCreateProfileUpdate(NULL);
233 } 233 }
234 234
235 void ManageProfileHandler::GenerateSignedinUserSpecificStrings( 235 void ManageProfileHandler::GenerateSignedinUserSpecificStrings(
236 base::DictionaryValue* dictionary) { 236 base::DictionaryValue* dictionary) {
237 std::string username; 237 std::string username;
(...skipping 28 matching lines...) Expand all
266 base::UTF8ToUTF16(chrome::kSyncGoogleDashboardURL))); 266 base::UTF8ToUTF16(chrome::kSyncGoogleDashboardURL)));
267 } 267 }
268 268
269 void ManageProfileHandler::RequestDefaultProfileIcons( 269 void ManageProfileHandler::RequestDefaultProfileIcons(
270 const base::ListValue* args) { 270 const base::ListValue* args) {
271 std::string mode; 271 std::string mode;
272 bool ok = args->GetString(0, &mode); 272 bool ok = args->GetString(0, &mode);
273 DCHECK(ok); 273 DCHECK(ok);
274 DCHECK(mode == kCreateProfileIdentifier || mode == kManageProfileIdentifier); 274 DCHECK(mode == kCreateProfileIdentifier || mode == kManageProfileIdentifier);
275 if (ok) { 275 if (ok) {
276 base::StringValue value(mode); 276 base::Value value(mode);
277 SendProfileIconsAndNames(value); 277 SendProfileIconsAndNames(value);
278 } 278 }
279 } 279 }
280 280
281 void ManageProfileHandler::RequestNewProfileDefaults( 281 void ManageProfileHandler::RequestNewProfileDefaults(
282 const base::ListValue* args) { 282 const base::ListValue* args) {
283 const ProfileAttributesStorage& storage = 283 const ProfileAttributesStorage& storage =
284 g_browser_process->profile_manager()->GetProfileAttributesStorage(); 284 g_browser_process->profile_manager()->GetProfileAttributesStorage();
285 const size_t icon_index = storage.ChooseAvatarIconIndexForNewProfile(); 285 const size_t icon_index = storage.ChooseAvatarIconIndexForNewProfile();
286 286
287 base::DictionaryValue profile_info; 287 base::DictionaryValue profile_info;
288 profile_info.SetString("name", storage.ChooseNameForNewProfile(icon_index)); 288 profile_info.SetString("name", storage.ChooseNameForNewProfile(icon_index));
289 profile_info.SetString("iconURL", 289 profile_info.SetString("iconURL",
290 profiles::GetDefaultAvatarIconUrl(icon_index)); 290 profiles::GetDefaultAvatarIconUrl(icon_index));
291 291
292 web_ui()->CallJavascriptFunctionUnsafe( 292 web_ui()->CallJavascriptFunctionUnsafe(
293 "ManageProfileOverlay.receiveNewProfileDefaults", profile_info); 293 "ManageProfileOverlay.receiveNewProfileDefaults", profile_info);
294 } 294 }
295 295
296 void ManageProfileHandler::SendProfileIconsAndNames( 296 void ManageProfileHandler::SendProfileIconsAndNames(const base::Value& mode) {
297 const base::StringValue& mode) {
298 base::ListValue image_url_list; 297 base::ListValue image_url_list;
299 base::ListValue default_name_list; 298 base::ListValue default_name_list;
300 299
301 ProfileAttributesStorage& storage = 300 ProfileAttributesStorage& storage =
302 g_browser_process->profile_manager()->GetProfileAttributesStorage(); 301 g_browser_process->profile_manager()->GetProfileAttributesStorage();
303 302
304 // In manage mode, first add the GAIA picture if it is available. No GAIA 303 // In manage mode, first add the GAIA picture if it is available. No GAIA
305 // picture in create mode. 304 // picture in create mode.
306 if (mode.GetString() == kManageProfileIdentifier) { 305 if (mode.GetString() == kManageProfileIdentifier) {
307 Profile* profile = Profile::FromWebUI(web_ui()); 306 Profile* profile = Profile::FromWebUI(web_ui());
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 // text field. This will display either the GAIA given name, if available, 427 // text field. This will display either the GAIA given name, if available,
429 // or the first name. 428 // or the first name.
430 ProfileAttributesEntry* entry = nullptr; 429 ProfileAttributesEntry* entry = nullptr;
431 if (!g_browser_process->profile_manager()->GetProfileAttributesStorage(). 430 if (!g_browser_process->profile_manager()->GetProfileAttributesStorage().
432 GetProfileAttributesWithPath(profile_file_path, &entry)) 431 GetProfileAttributesWithPath(profile_file_path, &entry))
433 return; 432 return;
434 base::string16 gaia_name = entry->GetName(); 433 base::string16 gaia_name = entry->GetName();
435 if (gaia_name.empty()) 434 if (gaia_name.empty())
436 return; 435 return;
437 436
438 base::StringValue gaia_name_value(gaia_name); 437 base::Value gaia_name_value(gaia_name);
439 base::StringValue mode_value(kManageProfileIdentifier); 438 base::Value mode_value(kManageProfileIdentifier);
440 web_ui()->CallJavascriptFunctionUnsafe("ManageProfileOverlay.setProfileName", 439 web_ui()->CallJavascriptFunctionUnsafe("ManageProfileOverlay.setProfileName",
441 gaia_name_value, mode_value); 440 gaia_name_value, mode_value);
442 } 441 }
443 442
444 void ManageProfileHandler::RequestHasProfileShortcuts( 443 void ManageProfileHandler::RequestHasProfileShortcuts(
445 const base::ListValue* args) { 444 const base::ListValue* args) {
446 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 445 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
447 DCHECK(ProfileShortcutManager::IsFeatureEnabled()); 446 DCHECK(ProfileShortcutManager::IsFeatureEnabled());
448 447
449 base::FilePath profile_file_path; 448 base::FilePath profile_file_path;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 // |service| might be null if Sync is disabled from the command line. 480 // |service| might be null if Sync is disabled from the command line.
482 if (service) 481 if (service)
483 state = service->GetAuthError().state(); 482 state = service->GetAuthError().state();
484 483
485 bool has_error = (!service || 484 bool has_error = (!service ||
486 state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS || 485 state == GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS ||
487 state == GoogleServiceAuthError::USER_NOT_SIGNED_UP || 486 state == GoogleServiceAuthError::USER_NOT_SIGNED_UP ||
488 state == GoogleServiceAuthError::ACCOUNT_DELETED || 487 state == GoogleServiceAuthError::ACCOUNT_DELETED ||
489 state == GoogleServiceAuthError::ACCOUNT_DISABLED); 488 state == GoogleServiceAuthError::ACCOUNT_DISABLED);
490 web_ui()->CallJavascriptFunctionUnsafe( 489 web_ui()->CallJavascriptFunctionUnsafe(
491 "CreateProfileOverlay.updateSignedInStatus", base::StringValue(username), 490 "CreateProfileOverlay.updateSignedInStatus", base::Value(username),
492 base::Value(has_error)); 491 base::Value(has_error));
493 492
494 OnCreateSupervisedUserPrefChange(); 493 OnCreateSupervisedUserPrefChange();
495 } 494 }
496 495
497 void ManageProfileHandler::OnCreateSupervisedUserPrefChange() { 496 void ManageProfileHandler::OnCreateSupervisedUserPrefChange() {
498 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 497 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
499 base::Value allowed(prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed)); 498 base::Value allowed(prefs->GetBoolean(prefs::kSupervisedUserCreationAllowed));
500 web_ui()->CallJavascriptFunctionUnsafe( 499 web_ui()->CallJavascriptFunctionUnsafe(
501 "CreateProfileOverlay.updateSupervisedUsersAllowed", allowed); 500 "CreateProfileOverlay.updateSupervisedUsersAllowed", allowed);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 538
540 // Update the UI buttons. 539 // Update the UI buttons.
541 OnHasProfileShortcuts(false); 540 OnHasProfileShortcuts(false);
542 } 541 }
543 542
544 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { 543 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) {
545 profiles::UpdateGaiaProfileInfoIfNeeded(Profile::FromWebUI(web_ui())); 544 profiles::UpdateGaiaProfileInfoIfNeeded(Profile::FromWebUI(web_ui()));
546 } 545 }
547 546
548 } // namespace options 547 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698