OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/webui/options2/personal_options_handler.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" |
| 12 #include "base/path_service.h" |
| 13 #include "base/stl_util.h" |
| 14 #include "base/string_number_conversions.h" |
| 15 #include "base/utf_string_conversions.h" |
| 16 #include "base/value_conversions.h" |
| 17 #include "base/values.h" |
| 18 #include "build/build_config.h" |
| 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/google/google_util.h" |
| 21 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/profiles/profile_info_cache.h" |
| 23 #include "chrome/browser/profiles/profile_info_util.h" |
| 24 #include "chrome/browser/profiles/profile_manager.h" |
| 25 #include "chrome/browser/sync/profile_sync_service.h" |
| 26 #include "chrome/browser/sync/sync_setup_flow.h" |
| 27 #include "chrome/browser/sync/sync_ui_util.h" |
| 28 #include "chrome/browser/themes/theme_service.h" |
| 29 #include "chrome/browser/themes/theme_service_factory.h" |
| 30 #include "chrome/browser/ui/webui/web_ui_util.h" |
| 31 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/chrome_paths.h" |
| 33 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 35 #include "chrome/common/url_constants.h" |
| 36 #include "content/browser/tab_contents/tab_contents.h" |
| 37 #include "content/public/browser/notification_service.h" |
| 38 #include "content/public/browser/user_metrics.h" |
| 39 #include "grit/chromium_strings.h" |
| 40 #include "grit/generated_resources.h" |
| 41 #include "grit/locale_settings.h" |
| 42 #include "grit/theme_resources.h" |
| 43 #include "ui/base/l10n/l10n_util.h" |
| 44 |
| 45 #if defined(OS_CHROMEOS) |
| 46 #include "chrome/browser/chromeos/login/user_manager.h" |
| 47 #include "chrome/browser/chromeos/options/take_photo_dialog.h" |
| 48 #include "chrome/browser/ui/browser_window.h" |
| 49 #include "chrome/browser/ui/views/window.h" |
| 50 #include "third_party/skia/include/core/SkBitmap.h" |
| 51 #endif // defined(OS_CHROMEOS) |
| 52 #if defined(TOOLKIT_GTK) |
| 53 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 54 #endif // defined(TOOLKIT_GTK) |
| 55 |
| 56 using content::UserMetricsAction; |
| 57 |
| 58 PersonalOptionsHandler::PersonalOptionsHandler() { |
| 59 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); |
| 60 #if defined(OS_CHROMEOS) |
| 61 registrar_.Add(this, |
| 62 chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
| 63 content::NotificationService::AllSources()); |
| 64 #endif |
| 65 } |
| 66 |
| 67 PersonalOptionsHandler::~PersonalOptionsHandler() { |
| 68 ProfileSyncService* sync_service = |
| 69 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); |
| 70 if (sync_service) |
| 71 sync_service->RemoveObserver(this); |
| 72 } |
| 73 |
| 74 void PersonalOptionsHandler::GetLocalizedValues( |
| 75 DictionaryValue* localized_strings) { |
| 76 DCHECK(localized_strings); |
| 77 |
| 78 RegisterTitle(localized_strings, "personalPage", |
| 79 IDS_OPTIONS_CONTENT_TAB_LABEL); |
| 80 |
| 81 |
| 82 localized_strings->SetString( |
| 83 "syncOverview", |
| 84 l10n_util::GetStringFUTF16(IDS_SYNC_OVERVIEW, |
| 85 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 86 localized_strings->SetString("syncSection", |
| 87 l10n_util::GetStringUTF16(IDS_SYNC_OPTIONS_GROUP_NAME)); |
| 88 localized_strings->SetString("customizeSync", |
| 89 l10n_util::GetStringUTF16(IDS_SYNC_CUSTOMIZE_BUTTON_LABEL)); |
| 90 localized_strings->SetString("syncLearnMoreURL", |
| 91 google_util::StringAppendGoogleLocaleParam(chrome::kSyncLearnMoreURL)); |
| 92 |
| 93 localized_strings->SetString("profiles", |
| 94 l10n_util::GetStringUTF16(IDS_PROFILES_OPTIONS_GROUP_NAME)); |
| 95 localized_strings->SetString("profilesCreate", |
| 96 l10n_util::GetStringUTF16(IDS_PROFILES_CREATE_BUTTON_LABEL)); |
| 97 localized_strings->SetString("profilesManage", |
| 98 l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_BUTTON_LABEL)); |
| 99 localized_strings->SetString("profilesDelete", |
| 100 l10n_util::GetStringUTF16(IDS_PROFILES_DELETE_BUTTON_LABEL)); |
| 101 localized_strings->SetString("profilesDeleteSingle", |
| 102 l10n_util::GetStringUTF16(IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL)); |
| 103 localized_strings->SetString("profilesListItemCurrent", |
| 104 l10n_util::GetStringUTF16(IDS_PROFILES_LIST_ITEM_CURRENT)); |
| 105 localized_strings->SetString("profilesSingleUser", |
| 106 l10n_util::GetStringFUTF16(IDS_PROFILES_SINGLE_USER_MESSAGE, |
| 107 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 108 |
| 109 localized_strings->SetString("passwords", |
| 110 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_GROUP_NAME)); |
| 111 localized_strings->SetString("passwordsAskToSave", |
| 112 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_ASKTOSAVE)); |
| 113 localized_strings->SetString("passwordsNeverSave", |
| 114 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_NEVERSAVE)); |
| 115 localized_strings->SetString("manage_passwords", |
| 116 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS)); |
| 117 #if defined(OS_MACOSX) |
| 118 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 119 if (profile_manager->GetNumberOfProfiles() > 1) { |
| 120 localized_strings->SetString("macPasswordsWarning", |
| 121 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); |
| 122 } |
| 123 #endif |
| 124 localized_strings->SetString("autologinEnabled", |
| 125 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_AUTOLOGIN)); |
| 126 |
| 127 localized_strings->SetString("autofill", |
| 128 l10n_util::GetStringUTF16(IDS_AUTOFILL_SETTING_WINDOWS_GROUP_NAME)); |
| 129 localized_strings->SetString("autofillEnabled", |
| 130 l10n_util::GetStringUTF16(IDS_OPTIONS_AUTOFILL_ENABLE)); |
| 131 localized_strings->SetString("manageAutofillSettings", |
| 132 l10n_util::GetStringUTF16(IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS)); |
| 133 |
| 134 localized_strings->SetString("browsingData", |
| 135 l10n_util::GetStringUTF16(IDS_OPTIONS_BROWSING_DATA_GROUP_NAME)); |
| 136 localized_strings->SetString("importData", |
| 137 l10n_util::GetStringUTF16(IDS_OPTIONS_IMPORT_DATA_BUTTON)); |
| 138 |
| 139 localized_strings->SetString("themesGallery", |
| 140 l10n_util::GetStringUTF16(IDS_THEMES_GALLERY_BUTTON)); |
| 141 localized_strings->SetString("themesGalleryURL", |
| 142 l10n_util::GetStringUTF16(IDS_THEMES_GALLERY_URL)); |
| 143 |
| 144 #if defined(TOOLKIT_GTK) |
| 145 localized_strings->SetString("appearance", |
| 146 l10n_util::GetStringUTF16(IDS_APPEARANCE_GROUP_NAME)); |
| 147 localized_strings->SetString("themesGTKButton", |
| 148 l10n_util::GetStringUTF16(IDS_THEMES_GTK_BUTTON)); |
| 149 localized_strings->SetString("themesSetClassic", |
| 150 l10n_util::GetStringUTF16(IDS_THEMES_SET_CLASSIC)); |
| 151 localized_strings->SetString("showWindowDecorations", |
| 152 l10n_util::GetStringUTF16(IDS_SHOW_WINDOW_DECORATIONS_RADIO)); |
| 153 localized_strings->SetString("hideWindowDecorations", |
| 154 l10n_util::GetStringUTF16(IDS_HIDE_WINDOW_DECORATIONS_RADIO)); |
| 155 #else |
| 156 localized_strings->SetString("themes", |
| 157 l10n_util::GetStringUTF16(IDS_THEMES_GROUP_NAME)); |
| 158 localized_strings->SetString("themesReset", |
| 159 l10n_util::GetStringUTF16(IDS_THEMES_RESET_BUTTON)); |
| 160 #endif |
| 161 |
| 162 // Sync select control. |
| 163 ListValue* sync_select_list = new ListValue; |
| 164 ListValue* datatypes = new ListValue; |
| 165 datatypes->Append(Value::CreateBooleanValue(false)); |
| 166 datatypes->Append( |
| 167 Value::CreateStringValue( |
| 168 l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_SELECT_DATATYPES))); |
| 169 sync_select_list->Append(datatypes); |
| 170 ListValue* everything = new ListValue; |
| 171 everything->Append(Value::CreateBooleanValue(true)); |
| 172 everything->Append( |
| 173 Value::CreateStringValue( |
| 174 l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_SELECT_EVERYTHING))); |
| 175 sync_select_list->Append(everything); |
| 176 localized_strings->Set("syncSelectList", sync_select_list); |
| 177 |
| 178 // Sync page. |
| 179 localized_strings->SetString("syncPage", |
| 180 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SYNC_SECTION_TITLE)); |
| 181 localized_strings->SetString("sync_title", |
| 182 l10n_util::GetStringUTF16(IDS_CUSTOMIZE_SYNC_DESCRIPTION)); |
| 183 localized_strings->SetString("syncsettings", |
| 184 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_PREFERENCES)); |
| 185 localized_strings->SetString("syncbookmarks", |
| 186 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_BOOKMARKS)); |
| 187 localized_strings->SetString("synctypedurls", |
| 188 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_TYPED_URLS)); |
| 189 localized_strings->SetString("syncpasswords", |
| 190 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_PASSWORDS)); |
| 191 localized_strings->SetString("syncextensions", |
| 192 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_EXTENSIONS)); |
| 193 localized_strings->SetString("syncautofill", |
| 194 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_AUTOFILL)); |
| 195 localized_strings->SetString("syncthemes", |
| 196 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_THEMES)); |
| 197 localized_strings->SetString("syncapps", |
| 198 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_APPS)); |
| 199 localized_strings->SetString("syncsessions", |
| 200 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_TABS)); |
| 201 |
| 202 #if defined(OS_CHROMEOS) |
| 203 localized_strings->SetString("account", |
| 204 l10n_util::GetStringUTF16(IDS_OPTIONS_PERSONAL_ACCOUNT_GROUP_NAME)); |
| 205 localized_strings->SetString("enableScreenlock", |
| 206 l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX)); |
| 207 localized_strings->SetString("changePicture", |
| 208 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE)); |
| 209 if (chromeos::UserManager::Get()->user_is_logged_in()) { |
| 210 localized_strings->SetString("username", |
| 211 chromeos::UserManager::Get()->logged_in_user().email()); |
| 212 } |
| 213 #endif |
| 214 } |
| 215 |
| 216 void PersonalOptionsHandler::RegisterMessages() { |
| 217 DCHECK(web_ui_); |
| 218 web_ui_->RegisterMessageCallback( |
| 219 "themesReset", |
| 220 base::Bind(&PersonalOptionsHandler::ThemesReset, |
| 221 base::Unretained(this))); |
| 222 #if defined(TOOLKIT_GTK) |
| 223 web_ui_->RegisterMessageCallback( |
| 224 "themesSetGTK", |
| 225 base::Bind(&PersonalOptionsHandler::ThemesSetGTK, |
| 226 base::Unretained(this))); |
| 227 #endif |
| 228 web_ui_->RegisterMessageCallback( |
| 229 "createProfile", |
| 230 base::Bind(&PersonalOptionsHandler::CreateProfile, |
| 231 base::Unretained(this))); |
| 232 } |
| 233 |
| 234 void PersonalOptionsHandler::Observe( |
| 235 int type, |
| 236 const content::NotificationSource& source, |
| 237 const content::NotificationDetails& details) { |
| 238 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
| 239 ObserveThemeChanged(); |
| 240 } else if (multiprofile_ && |
| 241 type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { |
| 242 SendProfilesInfo(); |
| 243 #if defined(OS_CHROMEOS) |
| 244 } else if (type == chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) { |
| 245 UpdateAccountPicture(); |
| 246 #endif |
| 247 } else { |
| 248 OptionsPage2UIHandler::Observe(type, source, details); |
| 249 } |
| 250 } |
| 251 |
| 252 void PersonalOptionsHandler::OnStateChanged() { |
| 253 string16 status_label; |
| 254 string16 link_label; |
| 255 ProfileSyncService* service = |
| 256 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); |
| 257 DCHECK(service); |
| 258 bool managed = service->IsManaged(); |
| 259 bool sync_setup_completed = service->HasSyncSetupCompleted(); |
| 260 bool status_has_error = sync_ui_util::GetStatusLabels( |
| 261 service, sync_ui_util::WITH_HTML, &status_label, &link_label) == |
| 262 sync_ui_util::SYNC_ERROR; |
| 263 |
| 264 string16 start_stop_button_label; |
| 265 bool is_start_stop_button_visible = false; |
| 266 bool is_start_stop_button_enabled = false; |
| 267 if (sync_setup_completed) { |
| 268 start_stop_button_label = |
| 269 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_BUTTON_LABEL); |
| 270 #if defined(OS_CHROMEOS) |
| 271 is_start_stop_button_visible = false; |
| 272 #else |
| 273 is_start_stop_button_visible = true; |
| 274 #endif // defined(OS_CHROMEOS) |
| 275 is_start_stop_button_enabled = !managed; |
| 276 } else if (service->SetupInProgress()) { |
| 277 start_stop_button_label = |
| 278 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS); |
| 279 is_start_stop_button_visible = true; |
| 280 is_start_stop_button_enabled = false; |
| 281 } else { |
| 282 start_stop_button_label = |
| 283 l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, |
| 284 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)); |
| 285 is_start_stop_button_visible = true; |
| 286 is_start_stop_button_enabled = !managed; |
| 287 } |
| 288 |
| 289 scoped_ptr<Value> completed(Value::CreateBooleanValue(sync_setup_completed)); |
| 290 web_ui_->CallJavascriptFunction("PersonalOptions.setSyncSetupCompleted", |
| 291 *completed); |
| 292 |
| 293 scoped_ptr<Value> label(Value::CreateStringValue(status_label)); |
| 294 web_ui_->CallJavascriptFunction("PersonalOptions.setSyncStatus", *label); |
| 295 |
| 296 scoped_ptr<Value> enabled( |
| 297 Value::CreateBooleanValue(is_start_stop_button_enabled)); |
| 298 web_ui_->CallJavascriptFunction("PersonalOptions.setStartStopButtonEnabled", |
| 299 *enabled); |
| 300 |
| 301 scoped_ptr<Value> visible( |
| 302 Value::CreateBooleanValue(is_start_stop_button_visible)); |
| 303 web_ui_->CallJavascriptFunction("PersonalOptions.setStartStopButtonVisible", |
| 304 *visible); |
| 305 |
| 306 label.reset(Value::CreateStringValue(start_stop_button_label)); |
| 307 web_ui_->CallJavascriptFunction("PersonalOptions.setStartStopButtonLabel", |
| 308 *label); |
| 309 |
| 310 label.reset(Value::CreateStringValue(link_label)); |
| 311 web_ui_->CallJavascriptFunction("PersonalOptions.setSyncActionLinkLabel", |
| 312 *label); |
| 313 |
| 314 enabled.reset(Value::CreateBooleanValue(!managed)); |
| 315 web_ui_->CallJavascriptFunction("PersonalOptions.setSyncActionLinkEnabled", |
| 316 *enabled); |
| 317 |
| 318 visible.reset(Value::CreateBooleanValue(status_has_error)); |
| 319 web_ui_->CallJavascriptFunction("PersonalOptions.setSyncStatusErrorVisible", |
| 320 *visible); |
| 321 |
| 322 enabled.reset(Value::CreateBooleanValue( |
| 323 !service->unrecoverable_error_detected())); |
| 324 web_ui_->CallJavascriptFunction( |
| 325 "PersonalOptions.setCustomizeSyncButtonEnabled", |
| 326 *enabled); |
| 327 |
| 328 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin)) { |
| 329 visible.reset(Value::CreateBooleanValue( |
| 330 service->AreCredentialsAvailable())); |
| 331 web_ui_->CallJavascriptFunction("PersonalOptions.setAutoLoginVisible", |
| 332 *visible); |
| 333 } |
| 334 |
| 335 // Set profile creation text and button if multi-profiles switch is on. |
| 336 visible.reset(Value::CreateBooleanValue(multiprofile_)); |
| 337 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesSectionVisible", |
| 338 *visible); |
| 339 if (multiprofile_) |
| 340 SendProfilesInfo(); |
| 341 } |
| 342 |
| 343 void PersonalOptionsHandler::ObserveThemeChanged() { |
| 344 Profile* profile = Profile::FromWebUI(web_ui_); |
| 345 #if defined(TOOLKIT_GTK) |
| 346 GtkThemeService* theme_service = GtkThemeService::GetFrom(profile); |
| 347 bool is_gtk_theme = theme_service->UsingNativeTheme(); |
| 348 base::FundamentalValue gtk_enabled(!is_gtk_theme); |
| 349 web_ui_->CallJavascriptFunction( |
| 350 "options.PersonalOptions.setGtkThemeButtonEnabled", gtk_enabled); |
| 351 #else |
| 352 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); |
| 353 bool is_gtk_theme = false; |
| 354 #endif |
| 355 |
| 356 bool is_classic_theme = !is_gtk_theme && theme_service->UsingDefaultTheme(); |
| 357 base::FundamentalValue enabled(!is_classic_theme); |
| 358 web_ui_->CallJavascriptFunction( |
| 359 "options.PersonalOptions.setThemesResetButtonEnabled", enabled); |
| 360 } |
| 361 |
| 362 void PersonalOptionsHandler::Initialize() { |
| 363 Profile* profile = Profile::FromWebUI(web_ui_); |
| 364 |
| 365 // Listen for theme installation. |
| 366 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 367 content::Source<ThemeService>( |
| 368 ThemeServiceFactory::GetForProfile(profile))); |
| 369 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 370 content::NotificationService::AllSources()); |
| 371 ObserveThemeChanged(); |
| 372 |
| 373 ProfileSyncService* sync_service = profile->GetProfileSyncService(); |
| 374 if (sync_service) { |
| 375 sync_service->AddObserver(this); |
| 376 OnStateChanged(); |
| 377 } else { |
| 378 web_ui_->CallJavascriptFunction("options.PersonalOptions.hideSyncSection"); |
| 379 } |
| 380 } |
| 381 |
| 382 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { |
| 383 content::RecordAction(UserMetricsAction("Options_ThemesReset")); |
| 384 Profile* profile = Profile::FromWebUI(web_ui_); |
| 385 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); |
| 386 } |
| 387 |
| 388 #if defined(TOOLKIT_GTK) |
| 389 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { |
| 390 content::RecordAction(UserMetricsAction("Options_GtkThemeSet")); |
| 391 Profile* profile = Profile::FromWebUI(web_ui_); |
| 392 ThemeServiceFactory::GetForProfile(profile)->SetNativeTheme(); |
| 393 } |
| 394 #endif |
| 395 |
| 396 #if defined(OS_CHROMEOS) |
| 397 void PersonalOptionsHandler::UpdateAccountPicture() { |
| 398 std::string email = chromeos::UserManager::Get()->logged_in_user().email(); |
| 399 if (!email.empty()) { |
| 400 web_ui_->CallJavascriptFunction("PersonalOptions.updateAccountPicture"); |
| 401 base::StringValue email_value(email); |
| 402 web_ui_->CallJavascriptFunction("AccountsOptions.updateAccountPicture", |
| 403 email_value); |
| 404 } |
| 405 } |
| 406 #endif |
| 407 |
| 408 void PersonalOptionsHandler::SendProfilesInfo() { |
| 409 ProfileInfoCache& cache = |
| 410 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 411 ListValue profile_info_list; |
| 412 FilePath current_profile_path = |
| 413 web_ui_->tab_contents()->browser_context()->GetPath(); |
| 414 for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) { |
| 415 DictionaryValue* profile_value = new DictionaryValue(); |
| 416 FilePath profile_path = cache.GetPathOfProfileAtIndex(i); |
| 417 profile_value->SetString("name", cache.GetNameOfProfileAtIndex(i)); |
| 418 profile_value->Set("filePath", base::CreateFilePathValue(profile_path)); |
| 419 profile_value->SetBoolean("isCurrentProfile", |
| 420 profile_path == current_profile_path); |
| 421 |
| 422 bool is_gaia_picture = |
| 423 cache.IsUsingGAIAPictureOfProfileAtIndex(i) && |
| 424 cache.GetGAIAPictureOfProfileAtIndex(i); |
| 425 if (is_gaia_picture) { |
| 426 gfx::Image icon = profiles::GetAvatarIconForWebUI( |
| 427 cache.GetAvatarIconOfProfileAtIndex(i), true); |
| 428 profile_value->SetString("iconURL", web_ui_util::GetImageDataUrl(icon)); |
| 429 } else { |
| 430 size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(i); |
| 431 profile_value->SetString("iconURL", |
| 432 cache.GetDefaultAvatarIconUrl(icon_index)); |
| 433 } |
| 434 |
| 435 profile_info_list.Append(profile_value); |
| 436 } |
| 437 |
| 438 web_ui_->CallJavascriptFunction("PersonalOptions.setProfilesInfo", |
| 439 profile_info_list); |
| 440 } |
| 441 |
| 442 void PersonalOptionsHandler::CreateProfile(const ListValue* args) { |
| 443 ProfileManager::CreateMultiProfileAsync(); |
| 444 } |
OLD | NEW |