| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/signin/signin_create_profile_handler.h" | 5 #include "chrome/browser/ui/webui/signin/signin_create_profile_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 base::Unretained(this))); | 166 base::Unretained(this))); |
| 167 | 167 |
| 168 web_ui()->RegisterMessageCallback( | 168 web_ui()->RegisterMessageCallback( |
| 169 "requestSignedInProfiles", | 169 "requestSignedInProfiles", |
| 170 base::Bind(&SigninCreateProfileHandler::RequestSignedInProfiles, | 170 base::Bind(&SigninCreateProfileHandler::RequestSignedInProfiles, |
| 171 base::Unretained(this))); | 171 base::Unretained(this))); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void SigninCreateProfileHandler::RequestDefaultProfileIcons( | 174 void SigninCreateProfileHandler::RequestDefaultProfileIcons( |
| 175 const base::ListValue* args) { | 175 const base::ListValue* args) { |
| 176 base::ListValue image_url_list; | |
| 177 | |
| 178 // Add the default avatar icons. | |
| 179 size_t placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); | |
| 180 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount() && | |
| 181 i != placeholder_avatar_index; | |
| 182 i++) { | |
| 183 std::unique_ptr<base::DictionaryValue> avatar_info( | |
| 184 new base::DictionaryValue()); | |
| 185 avatar_info->SetString("url", profiles::GetDefaultAvatarIconUrl(i)); | |
| 186 avatar_info->SetString( | |
| 187 "label", | |
| 188 l10n_util::GetStringUTF16( | |
| 189 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i))); | |
| 190 | |
| 191 image_url_list.Append(std::move(avatar_info)); | |
| 192 } | |
| 193 | |
| 194 web_ui()->CallJavascriptFunctionUnsafe( | 176 web_ui()->CallJavascriptFunctionUnsafe( |
| 195 "cr.webUIListenerCallback", base::StringValue("profile-icons-received"), | 177 "cr.webUIListenerCallback", base::StringValue("profile-icons-received"), |
| 196 image_url_list); | 178 *profiles::GetDefaultProfileAvatarIconsAndLabels()); |
| 197 | 179 |
| 198 SendNewProfileDefaults(); | 180 SendNewProfileDefaults(); |
| 199 } | 181 } |
| 200 | 182 |
| 201 void SigninCreateProfileHandler::SendNewProfileDefaults() { | 183 void SigninCreateProfileHandler::SendNewProfileDefaults() { |
| 202 ProfileAttributesStorage& storage = | 184 ProfileAttributesStorage& storage = |
| 203 g_browser_process->profile_manager()->GetProfileAttributesStorage(); | 185 g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
| 204 base::DictionaryValue profile_info; | 186 base::DictionaryValue profile_info; |
| 205 profile_info.SetString("name", storage.ChooseNameForNewProfile(0)); | 187 profile_info.SetString("name", storage.ChooseNameForNewProfile(0)); |
| 206 | 188 |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 | 779 |
| 798 profiles::OpenBrowserWindowForProfile( | 780 profiles::OpenBrowserWindowForProfile( |
| 799 base::Bind(&SigninCreateProfileHandler::OnBrowserReadyCallback, | 781 base::Bind(&SigninCreateProfileHandler::OnBrowserReadyCallback, |
| 800 weak_ptr_factory_.GetWeakPtr()), | 782 weak_ptr_factory_.GetWeakPtr()), |
| 801 false, // Don't create a window if one already exists. | 783 false, // Don't create a window if one already exists. |
| 802 true, // Create a first run window. | 784 true, // Create a first run window. |
| 803 profile, | 785 profile, |
| 804 Profile::CREATE_STATUS_INITIALIZED); | 786 Profile::CREATE_STATUS_INITIALIZED); |
| 805 } | 787 } |
| 806 #endif | 788 #endif |
| OLD | NEW |