| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/settings/settings_manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/settings/settings_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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "chrome/browser/profiles/profile_metrics.h" | 21 #include "chrome/browser/profiles/profile_metrics.h" |
| 22 #include "chrome/browser/profiles/profile_shortcut_manager.h" | 22 #include "chrome/browser/profiles/profile_shortcut_manager.h" |
| 23 #include "chrome/browser/profiles/profile_window.h" | 23 #include "chrome/browser/profiles/profile_window.h" |
| 24 #include "chrome/browser/profiles/profiles_state.h" | 24 #include "chrome/browser/profiles/profiles_state.h" |
| 25 #include "chrome/browser/signin/signin_manager_factory.h" | 25 #include "chrome/browser/signin/signin_manager_factory.h" |
| 26 #include "chrome/browser/ui/browser_finder.h" | 26 #include "chrome/browser/ui/browser_finder.h" |
| 27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 29 #include "chrome/grit/chromium_strings.h" | 29 #include "chrome/grit/chromium_strings.h" |
| 30 #include "chrome/grit/generated_resources.h" | 30 #include "chrome/grit/generated_resources.h" |
| 31 #include "chrome/grit/settings_strings.h" |
| 31 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
| 32 #include "components/prefs/scoped_user_pref_update.h" | 33 #include "components/prefs/scoped_user_pref_update.h" |
| 33 #include "components/signin/core/browser/signin_manager.h" | 34 #include "components/signin/core/browser/signin_manager.h" |
| 34 #include "components/signin/core/common/profile_management_switches.h" | 35 #include "components/signin/core/common/profile_management_switches.h" |
| 35 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 36 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 37 #include "content/public/browser/web_ui.h" | 38 #include "content/public/browser/web_ui.h" |
| 38 #include "google_apis/gaia/gaia_auth_util.h" | 39 #include "google_apis/gaia/gaia_auth_util.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 40 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/base/webui/web_ui_util.h" | 41 #include "ui/base/webui/web_ui_util.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 101 |
| 101 std::unique_ptr<base::ListValue> ManageProfileHandler::GetAvailableIcons() { | 102 std::unique_ptr<base::ListValue> ManageProfileHandler::GetAvailableIcons() { |
| 102 std::unique_ptr<base::ListValue> image_url_list(new base::ListValue()); | 103 std::unique_ptr<base::ListValue> image_url_list(new base::ListValue()); |
| 103 | 104 |
| 104 // First add the GAIA picture if it is available. | 105 // First add the GAIA picture if it is available. |
| 105 ProfileAttributesEntry* entry; | 106 ProfileAttributesEntry* entry; |
| 106 if (g_browser_process->profile_manager()->GetProfileAttributesStorage(). | 107 if (g_browser_process->profile_manager()->GetProfileAttributesStorage(). |
| 107 GetProfileAttributesWithPath(profile_->GetPath(), &entry)) { | 108 GetProfileAttributesWithPath(profile_->GetPath(), &entry)) { |
| 108 const gfx::Image* icon = entry->GetGAIAPicture(); | 109 const gfx::Image* icon = entry->GetGAIAPicture(); |
| 109 if (icon) { | 110 if (icon) { |
| 111 std::unique_ptr<base::DictionaryValue> gaia_picture_info( |
| 112 new base::DictionaryValue()); |
| 110 gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true); | 113 gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true); |
| 111 gaia_picture_url_ = webui::GetBitmapDataUrl(icon2.AsBitmap()); | 114 gaia_picture_url_ = webui::GetBitmapDataUrl(icon2.AsBitmap()); |
| 112 image_url_list->AppendString(gaia_picture_url_); | 115 gaia_picture_info->SetString("url", gaia_picture_url_); |
| 116 gaia_picture_info->SetString( |
| 117 "label", |
| 118 l10n_util::GetStringUTF16(IDS_SETTINGS_CHANGE_PICTURE_PROFILE_PHOTO)); |
| 119 image_url_list->Append(std::move(gaia_picture_info)); |
| 113 } | 120 } |
| 114 } | 121 } |
| 115 | 122 |
| 116 // Next add the default avatar icons and names. | 123 // Next add the default avatar icons and names. |
| 117 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount(); i++) { | 124 size_t placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); |
| 118 std::string url = profiles::GetDefaultAvatarIconUrl(i); | 125 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount() && |
| 119 image_url_list->AppendString(url); | 126 i != placeholder_avatar_index; |
| 127 i++) { |
| 128 std::unique_ptr<base::DictionaryValue> avatar_info( |
| 129 new base::DictionaryValue()); |
| 130 avatar_info->SetString("url", profiles::GetDefaultAvatarIconUrl(i)); |
| 131 avatar_info->SetString( |
| 132 "label", l10n_util::GetStringUTF16( |
| 133 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i))); |
| 134 image_url_list->Append(std::move(avatar_info)); |
| 120 } | 135 } |
| 121 | 136 |
| 122 return image_url_list; | 137 return image_url_list; |
| 123 } | 138 } |
| 124 | 139 |
| 125 void ManageProfileHandler::HandleSetProfileIconAndName( | 140 void ManageProfileHandler::HandleSetProfileIconAndName( |
| 126 const base::ListValue* args) { | 141 const base::ListValue* args) { |
| 127 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 142 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 128 DCHECK(args); | 143 DCHECK(args); |
| 129 DCHECK_EQ(2u, args->GetSize()); | 144 DCHECK_EQ(2u, args->GetSize()); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 g_browser_process->profile_manager()->profile_shortcut_manager(); | 236 g_browser_process->profile_manager()->profile_shortcut_manager(); |
| 222 DCHECK(shortcut_manager); | 237 DCHECK(shortcut_manager); |
| 223 | 238 |
| 224 shortcut_manager->RemoveProfileShortcuts(profile_->GetPath()); | 239 shortcut_manager->RemoveProfileShortcuts(profile_->GetPath()); |
| 225 | 240 |
| 226 // Update the UI buttons. | 241 // Update the UI buttons. |
| 227 OnHasProfileShortcuts(false); | 242 OnHasProfileShortcuts(false); |
| 228 } | 243 } |
| 229 | 244 |
| 230 } // namespace settings | 245 } // namespace settings |
| OLD | NEW |