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

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

Issue 8511064: GAIA Profile info prototype (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 9 years, 1 month 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') | chrome/chrome_browser.gypi » ('j') | 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_manager.h" 23 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 24 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/sync_setup_flow.h" 25 #include "chrome/browser/sync/sync_setup_flow.h"
26 #include "chrome/browser/sync/sync_ui_util.h" 26 #include "chrome/browser/sync/sync_ui_util.h"
27 #include "chrome/browser/themes/theme_service.h" 27 #include "chrome/browser/themes/theme_service.h"
28 #include "chrome/browser/themes/theme_service_factory.h" 28 #include "chrome/browser/themes/theme_service_factory.h"
29 #include "chrome/browser/ui/webui/web_ui_util.h"
29 #include "chrome/common/chrome_notification_types.h" 30 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
32 #include "chrome/common/net/gaia/google_service_auth_error.h" 33 #include "chrome/common/net/gaia/google_service_auth_error.h"
33 #include "chrome/common/url_constants.h" 34 #include "chrome/common/url_constants.h"
34 #include "content/browser/tab_contents/tab_contents.h" 35 #include "content/browser/tab_contents/tab_contents.h"
35 #include "content/browser/user_metrics.h" 36 #include "content/browser/user_metrics.h"
36 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
37 #include "grit/chromium_strings.h" 38 #include "grit/chromium_strings.h"
38 #include "grit/generated_resources.h" 39 #include "grit/generated_resources.h"
39 #include "grit/locale_settings.h" 40 #include "grit/locale_settings.h"
40 #include "grit/theme_resources.h" 41 #include "grit/theme_resources.h"
41 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
42 43
43 #if defined(OS_CHROMEOS) 44 #if defined(OS_CHROMEOS)
44 #include "chrome/browser/chromeos/login/user_manager.h" 45 #include "chrome/browser/chromeos/login/user_manager.h"
45 #include "chrome/browser/chromeos/options/take_photo_dialog.h" 46 #include "chrome/browser/chromeos/options/take_photo_dialog.h"
46 #include "chrome/browser/ui/browser_window.h" 47 #include "chrome/browser/ui/browser_window.h"
47 #include "chrome/browser/ui/views/window.h" 48 #include "chrome/browser/ui/views/window.h"
48 #include "third_party/skia/include/core/SkBitmap.h" 49 #include "third_party/skia/include/core/SkBitmap.h"
49 #endif // defined(OS_CHROMEOS) 50 #endif // defined(OS_CHROMEOS)
50 #if defined(TOOLKIT_GTK) 51 #if defined(TOOLKIT_GTK)
51 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 52 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
52 #endif // defined(TOOLKIT_GTK) 53 #endif // defined(TOOLKIT_GTK)
53 54
55 #include "skia/ext/image_operations.h"
56 #include "ui/gfx/canvas_skia.h"
57
58 SkBitmap FixGAIABmp(const SkBitmap& bmp) {
59 SkBitmap rimage = skia::ImageOperations::Resize(
60 bmp, skia::ImageOperations::RESIZE_BEST, 29, 29);
61
62 gfx::CanvasSkia canvas(38, 31, false);
63 canvas.DrawBitmapInt(rimage, 4, 1);
64 return canvas.ExtractBitmap();
65 }
66
54 PersonalOptionsHandler::PersonalOptionsHandler() { 67 PersonalOptionsHandler::PersonalOptionsHandler() {
55 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); 68 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled();
56 #if defined(OS_CHROMEOS) 69 #if defined(OS_CHROMEOS)
57 registrar_.Add(this, 70 registrar_.Add(this,
58 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, 71 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED,
59 content::NotificationService::AllSources()); 72 content::NotificationService::AllSources());
60 #endif 73 #endif
61 } 74 }
62 75
63 PersonalOptionsHandler::~PersonalOptionsHandler() { 76 PersonalOptionsHandler::~PersonalOptionsHandler() {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 #endif 414 #endif
402 415
403 void PersonalOptionsHandler::SendProfilesInfo() { 416 void PersonalOptionsHandler::SendProfilesInfo() {
404 ProfileInfoCache& cache = 417 ProfileInfoCache& cache =
405 g_browser_process->profile_manager()->GetProfileInfoCache(); 418 g_browser_process->profile_manager()->GetProfileInfoCache();
406 ListValue profile_info_list; 419 ListValue profile_info_list;
407 FilePath current_profile_path = 420 FilePath current_profile_path =
408 web_ui_->tab_contents()->browser_context()->GetPath(); 421 web_ui_->tab_contents()->browser_context()->GetPath();
409 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { 422 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) {
410 DictionaryValue* profile_value = new DictionaryValue(); 423 DictionaryValue* profile_value = new DictionaryValue();
411 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i);
412 FilePath profile_path = cache.GetPathOfProfileAtIndex(i); 424 FilePath profile_path = cache.GetPathOfProfileAtIndex(i);
413 profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i)); 425 profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i));
414 profile_value->SetString("iconURL", 426
415 cache.GetDefaultAvatarIconUrl(icon_index)); 427 std::string bmp_url;
428 if (!cache.IsUsingCustomAvatarIconForProfileAtIndex(i)) {
429 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i);
430 bmp_url = cache.GetDefaultAvatarIconUrl(icon_index);
431 } else {
432 SkBitmap bmp = cache.GetGAIAPictureOfProfileAtIndex(i);
433 SkBitmap bmp2 = FixGAIABmp(bmp);
434 bmp_url = web_ui_util::GetImageDataUrl(bmp2);
435 }
436 profile_value->SetString("iconURL", bmp_url);
437
416 profile_value->Set("filePath", base::CreateFilePathValue(profile_path)); 438 profile_value->Set("filePath", base::CreateFilePathValue(profile_path));
417 profile_value->SetBoolean("isCurrentProfile", 439 profile_value->SetBoolean("isCurrentProfile",
418 profile_path == current_profile_path); 440 profile_path == current_profile_path);
419 profile_info_list.Append(profile_value); 441 profile_info_list.Append(profile_value);
420 } 442 }
421 443
422 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo", 444 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo",
423 profile_info_list); 445 profile_info_list);
424 } 446 }
425 447
426 void PersonalOptionsHandler::CreateProfile(const ListValue* args) { 448 void PersonalOptionsHandler::CreateProfile(const ListValue* args) {
427 ProfileManager::CreateMultiProfileAsync(); 449 ProfileManager::CreateMultiProfileAsync();
428 } 450 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/manage_profile_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698