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

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

Issue 8711002: Add GAIA picture to Settings profile overlay (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 9 years 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
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/personal_options_handler.h" 5 #include "chrome/browser/ui/webui/options/personal_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/stl_util.h" 13 #include "base/stl_util.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/value_conversions.h" 16 #include "base/value_conversions.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/google/google_util.h" 20 #include "chrome/browser/google/google_util.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_info_cache.h" 22 #include "chrome/browser/profiles/profile_info_cache.h"
23 #include "chrome/browser/profiles/profile_info_util.h"
23 #include "chrome/browser/profiles/profile_manager.h" 24 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 25 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/sync_setup_flow.h" 26 #include "chrome/browser/sync/sync_setup_flow.h"
26 #include "chrome/browser/sync/sync_ui_util.h" 27 #include "chrome/browser/sync/sync_ui_util.h"
27 #include "chrome/browser/themes/theme_service.h" 28 #include "chrome/browser/themes/theme_service.h"
28 #include "chrome/browser/themes/theme_service_factory.h" 29 #include "chrome/browser/themes/theme_service_factory.h"
30 #include "chrome/browser/ui/webui/web_ui_util.h"
29 #include "chrome/common/chrome_notification_types.h" 31 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/net/gaia/google_service_auth_error.h" 34 #include "chrome/common/net/gaia/google_service_auth_error.h"
33 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
34 #include "content/browser/tab_contents/tab_contents.h" 36 #include "content/browser/tab_contents/tab_contents.h"
35 #include "content/browser/user_metrics.h" 37 #include "content/browser/user_metrics.h"
36 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
37 #include "grit/chromium_strings.h" 39 #include "grit/chromium_strings.h"
38 #include "grit/generated_resources.h" 40 #include "grit/generated_resources.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 #endif 403 #endif
402 404
403 void PersonalOptionsHandler::SendProfilesInfo() { 405 void PersonalOptionsHandler::SendProfilesInfo() {
404 ProfileInfoCache& cache = 406 ProfileInfoCache& cache =
405 g_browser_process->profile_manager()->GetProfileInfoCache(); 407 g_browser_process->profile_manager()->GetProfileInfoCache();
406 ListValue profile_info_list; 408 ListValue profile_info_list;
407 FilePath current_profile_path = 409 FilePath current_profile_path =
408 web_ui_->tab_contents()->browser_context()->GetPath(); 410 web_ui_->tab_contents()->browser_context()->GetPath();
409 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { 411 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) {
410 DictionaryValue* profile_value = new DictionaryValue(); 412 DictionaryValue* profile_value = new DictionaryValue();
411 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i);
412 FilePath profile_path = cache.GetPathOfProfileAtIndex(i); 413 FilePath profile_path = cache.GetPathOfProfileAtIndex(i);
413 profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i)); 414 profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i));
414 profile_value->SetString("iconURL",
415 cache.GetDefaultAvatarIconUrl(icon_index));
416 profile_value->Set("filePath", base::CreateFilePathValue(profile_path)); 415 profile_value->Set("filePath", base::CreateFilePathValue(profile_path));
417 profile_value->SetBoolean("isCurrentProfile", 416 profile_value->SetBoolean("isCurrentProfile",
418 profile_path == current_profile_path); 417 profile_path == current_profile_path);
418
419 bool is_gaia_picture =
420 cache.IsUsingGAIAPictureOfProfileAtIndex(i) &&
421 cache.GetGAIAPictureOfProfileAtIndex(i);
422 if (is_gaia_picture) {
423 gfx::Image icon = profiles::GetAvatarIconForWebUI(
424 cache.GetAvatarIconOfProfileAtIndex(i), true);
425 profile_value->SetString("iconURL", web_ui_util::GetImageDataUrl(icon));
426 } else {
427 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i);
428 profile_value->SetString("iconURL",
429 cache.GetDefaultAvatarIconUrl(icon_index));
430 }
431
419 profile_info_list.Append(profile_value); 432 profile_info_list.Append(profile_value);
420 } 433 }
421 434
422 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo", 435 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo",
423 profile_info_list); 436 profile_info_list);
424 } 437 }
425 438
426 void PersonalOptionsHandler::CreateProfile(const ListValue* args) { 439 void PersonalOptionsHandler::CreateProfile(const ListValue* args) {
427 ProfileManager::CreateMultiProfileAsync(); 440 ProfileManager::CreateMultiProfileAsync();
428 } 441 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698