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

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

Issue 476993002: [Profiles] Fix the usage of custom/default names and avatars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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/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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 "ManageProfileOverlay.showDisconnectManagedProfileDialog", replacements); 321 "ManageProfileOverlay.showDisconnectManagedProfileDialog", replacements);
322 } 322 }
323 323
324 void ManageProfileHandler::SetProfileIconAndName(const base::ListValue* args) { 324 void ManageProfileHandler::SetProfileIconAndName(const base::ListValue* args) {
325 DCHECK(args); 325 DCHECK(args);
326 326
327 base::FilePath profile_file_path; 327 base::FilePath profile_file_path;
328 if (!GetProfilePathFromArgs(args, &profile_file_path)) 328 if (!GetProfilePathFromArgs(args, &profile_file_path))
329 return; 329 return;
330 330
331 ProfileInfoCache& cache =
332 g_browser_process->profile_manager()->GetProfileInfoCache();
333 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path);
334 if (profile_index == std::string::npos)
335 return;
336
337 Profile* profile = 331 Profile* profile =
338 g_browser_process->profile_manager()->GetProfile(profile_file_path); 332 g_browser_process->profile_manager()->GetProfile(profile_file_path);
339 if (!profile) 333 if (!profile)
340 return; 334 return;
341 335
342 std::string icon_url; 336 std::string icon_url;
343 if (!args->GetString(1, &icon_url)) 337 if (!args->GetString(1, &icon_url))
344 return; 338 return;
345 339
340 PrefService* pref_service = profile->GetPrefs();
341 // Updating the profile preferences will cause the cache to be updated.
342
346 // Metrics logging variable. 343 // Metrics logging variable.
347 bool previously_using_gaia_icon = 344 bool previously_using_gaia_icon =
348 cache.IsUsingGAIAPictureOfProfileAtIndex(profile_index); 345 pref_service->GetBoolean(prefs::kProfileUsingGAIAAvatar);
349 346
350 size_t new_icon_index; 347 size_t new_icon_index;
351 if (icon_url == gaia_picture_url_) { 348 if (icon_url == gaia_picture_url_) {
352 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); 349 pref_service->SetBoolean(prefs::kProfileUsingDefaultAvatar, false);
350 pref_service->SetBoolean(prefs::kProfileUsingGAIAAvatar, true);
353 if (!previously_using_gaia_icon) { 351 if (!previously_using_gaia_icon) {
354 // Only log if they changed to the GAIA photo. 352 // Only log if they changed to the GAIA photo.
355 // Selection of GAIA photo as avatar is logged as part of the function 353 // Selection of GAIA photo as avatar is logged as part of the function
356 // below. 354 // below.
357 ProfileMetrics::LogProfileSwitchGaia(ProfileMetrics::GAIA_OPT_IN); 355 ProfileMetrics::LogProfileSwitchGaia(ProfileMetrics::GAIA_OPT_IN);
358 } 356 }
359 } else if (profiles::IsDefaultAvatarIconUrl(icon_url, &new_icon_index)) { 357 } else if (profiles::IsDefaultAvatarIconUrl(icon_url, &new_icon_index)) {
360 ProfileMetrics::LogProfileAvatarSelection(new_icon_index); 358 ProfileMetrics::LogProfileAvatarSelection(new_icon_index);
361 PrefService* pref_service = profile->GetPrefs();
362 // Updating the profile preference will cause the cache to be updated for
363 // this preference.
364 pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); 359 pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index);
365 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false); 360 pref_service->SetBoolean(prefs::kProfileUsingDefaultAvatar, false);
361 pref_service->SetBoolean(prefs::kProfileUsingGAIAAvatar, false);
366 } 362 }
367 ProfileMetrics::LogProfileUpdate(profile_file_path); 363 ProfileMetrics::LogProfileUpdate(profile_file_path);
368 364
369 if (profile->IsSupervised()) 365 if (profile->IsSupervised())
370 return; 366 return;
371 367
372 base::string16 new_profile_name; 368 base::string16 new_profile_name;
373 if (!args->GetString(2, &new_profile_name)) 369 if (!args->GetString(2, &new_profile_name))
374 return; 370 return;
375 371
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 521
526 // Update the UI buttons. 522 // Update the UI buttons.
527 OnHasProfileShortcuts(false); 523 OnHasProfileShortcuts(false);
528 } 524 }
529 525
530 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) { 526 void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) {
531 profiles::UpdateGaiaProfilePhotoIfNeeded(Profile::FromWebUI(web_ui())); 527 profiles::UpdateGaiaProfilePhotoIfNeeded(Profile::FromWebUI(web_ui()));
532 } 528 }
533 529
534 } // namespace options 530 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698