| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/options2/manage_profile_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/manage_profile_handler2.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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // First add the GAIA picture if it's available. | 101 // First add the GAIA picture if it's available. |
| 102 ProfileInfoCache& cache = | 102 ProfileInfoCache& cache = |
| 103 g_browser_process->profile_manager()->GetProfileInfoCache(); | 103 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 104 Profile* profile = Profile::FromWebUI(web_ui()); | 104 Profile* profile = Profile::FromWebUI(web_ui()); |
| 105 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 105 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 106 if (profile_index != std::string::npos) { | 106 if (profile_index != std::string::npos) { |
| 107 const gfx::Image* icon = | 107 const gfx::Image* icon = |
| 108 cache.GetGAIAPictureOfProfileAtIndex(profile_index); | 108 cache.GetGAIAPictureOfProfileAtIndex(profile_index); |
| 109 if (icon) { | 109 if (icon) { |
| 110 gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true); | 110 gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true); |
| 111 gaia_picture_url_ = web_ui_util::GetImageDataUrl(*icon2.ToSkBitmap()); | 111 gaia_picture_url_ = web_ui_util::GetImageDataUrl(*icon2.ToImageSkia()); |
| 112 image_url_list.Append(Value::CreateStringValue(gaia_picture_url_)); | 112 image_url_list.Append(Value::CreateStringValue(gaia_picture_url_)); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Next add the default avatar icons. | 116 // Next add the default avatar icons. |
| 117 for (size_t i = 0; i < ProfileInfoCache::GetDefaultAvatarIconCount(); i++) { | 117 for (size_t i = 0; i < ProfileInfoCache::GetDefaultAvatarIconCount(); i++) { |
| 118 std::string url = ProfileInfoCache::GetDefaultAvatarIconUrl(i); | 118 std::string url = ProfileInfoCache::GetDefaultAvatarIconUrl(i); |
| 119 image_url_list.Append(Value::CreateStringValue(url)); | 119 image_url_list.Append(Value::CreateStringValue(url)); |
| 120 } | 120 } |
| 121 | 121 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 profile_value.Set("filePath", base::CreateFilePathValue(profile_path)); | 261 profile_value.Set("filePath", base::CreateFilePathValue(profile_path)); |
| 262 profile_value.SetBoolean("isCurrentProfile", is_current_profile); | 262 profile_value.SetBoolean("isCurrentProfile", is_current_profile); |
| 263 | 263 |
| 264 bool is_gaia_picture = | 264 bool is_gaia_picture = |
| 265 cache.IsUsingGAIAPictureOfProfileAtIndex(index) && | 265 cache.IsUsingGAIAPictureOfProfileAtIndex(index) && |
| 266 cache.GetGAIAPictureOfProfileAtIndex(index); | 266 cache.GetGAIAPictureOfProfileAtIndex(index); |
| 267 if (is_gaia_picture) { | 267 if (is_gaia_picture) { |
| 268 gfx::Image icon = profiles::GetAvatarIconForWebUI( | 268 gfx::Image icon = profiles::GetAvatarIconForWebUI( |
| 269 cache.GetAvatarIconOfProfileAtIndex(index), true); | 269 cache.GetAvatarIconOfProfileAtIndex(index), true); |
| 270 profile_value.SetString("iconURL", | 270 profile_value.SetString("iconURL", |
| 271 web_ui_util::GetImageDataUrl(*icon.ToSkBitmap())); | 271 web_ui_util::GetImageDataUrl(*icon.ToImageSkia())); |
| 272 } else { | 272 } else { |
| 273 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(index); | 273 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(index); |
| 274 profile_value.SetString("iconURL", | 274 profile_value.SetString("iconURL", |
| 275 cache.GetDefaultAvatarIconUrl(icon_index)); | 275 cache.GetDefaultAvatarIconUrl(icon_index)); |
| 276 } | 276 } |
| 277 | 277 |
| 278 web_ui()->CallJavascriptFunction("ManageProfileOverlay.setProfileInfo", | 278 web_ui()->CallJavascriptFunction("ManageProfileOverlay.setProfileInfo", |
| 279 profile_value); | 279 profile_value); |
| 280 | 280 |
| 281 // Ensure that we have the most up to date GAIA picture. | 281 // Ensure that we have the most up to date GAIA picture. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 string16 gaia_name = cache.GetGAIANameOfProfileAtIndex(i); | 319 string16 gaia_name = cache.GetGAIANameOfProfileAtIndex(i); |
| 320 if (gaia_name.empty()) | 320 if (gaia_name.empty()) |
| 321 return; | 321 return; |
| 322 | 322 |
| 323 StringValue gaia_name_value(gaia_name); | 323 StringValue gaia_name_value(gaia_name); |
| 324 web_ui()->CallJavascriptFunction("ManageProfileOverlay.setProfileName", | 324 web_ui()->CallJavascriptFunction("ManageProfileOverlay.setProfileName", |
| 325 gaia_name_value); | 325 gaia_name_value); |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace options2 | 328 } // namespace options2 |
| OLD | NEW |