| OLD | NEW |
| 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/callback.h" | 10 #include "base/callback.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 localized_strings->SetString("enableScreenlock", | 185 localized_strings->SetString("enableScreenlock", |
| 186 l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX)); | 186 l10n_util::GetStringUTF16(IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX)); |
| 187 localized_strings->SetString("changePicture", | 187 localized_strings->SetString("changePicture", |
| 188 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE)); | 188 l10n_util::GetStringUTF16(IDS_OPTIONS_CHANGE_PICTURE)); |
| 189 #endif | 189 #endif |
| 190 } | 190 } |
| 191 | 191 |
| 192 void PersonalOptionsHandler::RegisterMessages() { | 192 void PersonalOptionsHandler::RegisterMessages() { |
| 193 DCHECK(web_ui_); | 193 DCHECK(web_ui_); |
| 194 web_ui_->RegisterMessageCallback( | 194 web_ui_->RegisterMessageCallback( |
| 195 "showSyncActionDialog", | |
| 196 NewCallback(this, &PersonalOptionsHandler::ShowSyncActionDialog)); | |
| 197 web_ui_->RegisterMessageCallback( | |
| 198 "showSyncLoginDialog", | |
| 199 NewCallback(this, &PersonalOptionsHandler::ShowSyncLoginDialog)); | |
| 200 web_ui_->RegisterMessageCallback( | |
| 201 "showCustomizeSyncDialog", | |
| 202 NewCallback(this, &PersonalOptionsHandler::ShowCustomizeSyncDialog)); | |
| 203 web_ui_->RegisterMessageCallback( | |
| 204 "themesReset", | 195 "themesReset", |
| 205 NewCallback(this, &PersonalOptionsHandler::ThemesReset)); | 196 NewCallback(this, &PersonalOptionsHandler::ThemesReset)); |
| 206 #if defined(TOOLKIT_GTK) | 197 #if defined(TOOLKIT_GTK) |
| 207 web_ui_->RegisterMessageCallback( | 198 web_ui_->RegisterMessageCallback( |
| 208 "themesSetGTK", | 199 "themesSetGTK", |
| 209 NewCallback(this, &PersonalOptionsHandler::ThemesSetGTK)); | 200 NewCallback(this, &PersonalOptionsHandler::ThemesSetGTK)); |
| 210 #endif | 201 #endif |
| 211 #if defined(OS_CHROMEOS) | 202 #if defined(OS_CHROMEOS) |
| 212 web_ui_->RegisterMessageCallback( | 203 web_ui_->RegisterMessageCallback( |
| 213 "loadAccountPicture", | 204 "loadAccountPicture", |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 DictionaryValue args; | 370 DictionaryValue args; |
| 380 SyncSetupFlow::GetArgsForConfigure(sync_service, &args); | 371 SyncSetupFlow::GetArgsForConfigure(sync_service, &args); |
| 381 | 372 |
| 382 web_ui_->CallJavascriptFunction("PersonalOptions.setRegisteredDataTypes", | 373 web_ui_->CallJavascriptFunction("PersonalOptions.setRegisteredDataTypes", |
| 383 args); | 374 args); |
| 384 } else { | 375 } else { |
| 385 web_ui_->CallJavascriptFunction("options.PersonalOptions.hideSyncSection"); | 376 web_ui_->CallJavascriptFunction("options.PersonalOptions.hideSyncSection"); |
| 386 } | 377 } |
| 387 } | 378 } |
| 388 | 379 |
| 389 void PersonalOptionsHandler::ShowSyncActionDialog(const ListValue* args) { | |
| 390 ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService(); | |
| 391 DCHECK(service); | |
| 392 service->ShowErrorUI(web_ui_); | |
| 393 } | |
| 394 | |
| 395 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) { | |
| 396 ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService(); | |
| 397 DCHECK(service); | |
| 398 service->ShowLoginDialog(web_ui_); | |
| 399 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS); | |
| 400 } | |
| 401 | |
| 402 void PersonalOptionsHandler::ShowCustomizeSyncDialog(const ListValue* args) { | |
| 403 ProfileSyncService* service = web_ui_->GetProfile()->GetProfileSyncService(); | |
| 404 DCHECK(service); | |
| 405 service->ShowConfigure(web_ui_, false); | |
| 406 } | |
| 407 | |
| 408 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { | 380 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { |
| 409 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset")); | 381 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset")); |
| 410 ThemeServiceFactory::GetForProfile(web_ui_->GetProfile())->UseDefaultTheme(); | 382 ThemeServiceFactory::GetForProfile(web_ui_->GetProfile())->UseDefaultTheme(); |
| 411 } | 383 } |
| 412 | 384 |
| 413 #if defined(TOOLKIT_GTK) | 385 #if defined(TOOLKIT_GTK) |
| 414 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { | 386 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { |
| 415 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet")); | 387 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet")); |
| 416 ThemeServiceFactory::GetForProfile(web_ui_->GetProfile())->SetNativeTheme(); | 388 ThemeServiceFactory::GetForProfile(web_ui_->GetProfile())->SetNativeTheme(); |
| 417 } | 389 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 433 timestamp)); | 405 timestamp)); |
| 434 web_ui_->CallJavascriptFunction("PersonalOptions.setAccountPicture", | 406 web_ui_->CallJavascriptFunction("PersonalOptions.setAccountPicture", |
| 435 image_url); | 407 image_url); |
| 436 | 408 |
| 437 StringValue email_value(email); | 409 StringValue email_value(email); |
| 438 web_ui_->CallJavascriptFunction("AccountsOptions.updateAccountPicture", | 410 web_ui_->CallJavascriptFunction("AccountsOptions.updateAccountPicture", |
| 439 email_value, image_url); | 411 email_value, image_url); |
| 440 } | 412 } |
| 441 } | 413 } |
| 442 #endif | 414 #endif |
| OLD | NEW |