Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/dom_ui/options/personal_options_handler.h" | 5 #include "chrome/browser/dom_ui/options/personal_options_handler.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 l10n_util::GetStringUTF16(IDS_THEMES_DEFAULT_THEME_LABEL)); | 113 l10n_util::GetStringUTF16(IDS_THEMES_DEFAULT_THEME_LABEL)); |
| 114 #endif | 114 #endif |
| 115 } | 115 } |
| 116 | 116 |
| 117 void PersonalOptionsHandler::RegisterMessages() { | 117 void PersonalOptionsHandler::RegisterMessages() { |
| 118 DCHECK(dom_ui_); | 118 DCHECK(dom_ui_); |
| 119 dom_ui_->RegisterMessageCallback( | 119 dom_ui_->RegisterMessageCallback( |
| 120 "showSyncLoginDialog", | 120 "showSyncLoginDialog", |
| 121 NewCallback(this, &PersonalOptionsHandler::ShowSyncLoginDialog)); | 121 NewCallback(this, &PersonalOptionsHandler::ShowSyncLoginDialog)); |
| 122 dom_ui_->RegisterMessageCallback( | 122 dom_ui_->RegisterMessageCallback( |
| 123 "openPrivacyDashboardTabAndActivate", | |
| 124 NewCallback(this, | |
| 125 &PersonalOptionsHandler::OpenPrivacyDashboardTabAndActivate)); | |
| 126 dom_ui_->RegisterMessageCallback( | |
| 127 "themesReset", | 123 "themesReset", |
| 128 NewCallback(this, &PersonalOptionsHandler::ThemesReset)); | 124 NewCallback(this, &PersonalOptionsHandler::ThemesReset)); |
| 129 dom_ui_->RegisterMessageCallback( | 125 dom_ui_->RegisterMessageCallback( |
| 130 "themesGallery", | 126 "getThemesGalleryURL", |
|
arv (Not doing code reviews)
2010/11/12 01:17:25
Is there a reason why this cannot be included in t
James Hawkins
2010/11/12 21:15:29
I tried using that construct and it didn't work.
James Hawkins
2010/11/12 23:47:20
Done.
| |
| 131 NewCallback(this, &PersonalOptionsHandler::ThemesGallery)); | 127 NewCallback(this, &PersonalOptionsHandler::GetThemesGalleryURL)); |
| 132 #if defined(TOOLKIT_GTK) | 128 #if defined(TOOLKIT_GTK) |
| 133 dom_ui_->RegisterMessageCallback( | 129 dom_ui_->RegisterMessageCallback( |
| 134 "themesSetGTK", | 130 "themesSetGTK", |
| 135 NewCallback(this, &PersonalOptionsHandler::ThemesSetGTK)); | 131 NewCallback(this, &PersonalOptionsHandler::ThemesSetGTK)); |
| 136 #endif | 132 #endif |
| 137 } | 133 } |
| 138 | 134 |
| 139 void PersonalOptionsHandler::Observe(NotificationType type, | 135 void PersonalOptionsHandler::Observe(NotificationType type, |
| 140 const NotificationSource& source, | 136 const NotificationSource& source, |
| 141 const NotificationDetails& details) { | 137 const NotificationDetails& details) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 OnStateChanged(); | 268 OnStateChanged(); |
| 273 } | 269 } |
| 274 } | 270 } |
| 275 | 271 |
| 276 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) { | 272 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) { |
| 277 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); | 273 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); |
| 278 service->ShowLoginDialog(NULL); | 274 service->ShowLoginDialog(NULL); |
| 279 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS); | 275 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS); |
| 280 } | 276 } |
| 281 | 277 |
| 282 void PersonalOptionsHandler::OpenPrivacyDashboardTabAndActivate( | |
| 283 const ListValue* args) { | |
| 284 BrowserList::GetLastActive()->OpenPrivacyDashboardTabAndActivate(); | |
| 285 } | |
| 286 | |
| 287 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { | 278 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { |
| 288 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset")); | 279 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset")); |
| 289 dom_ui_->GetProfile()->ClearTheme(); | 280 dom_ui_->GetProfile()->ClearTheme(); |
| 290 } | 281 } |
| 291 | 282 |
| 292 void PersonalOptionsHandler::ThemesGallery(const ListValue* args) { | 283 void PersonalOptionsHandler::GetThemesGalleryURL(const ListValue* args) { |
| 293 UserMetricsRecordAction(UserMetricsAction("Options_ThemesGallery")); | 284 StringValue url(l10n_util::GetStringUTF16(IDS_THEMES_GALLERY_URL)); |
| 294 BrowserList::GetLastActive()->OpenThemeGalleryTabAndActivate(); | 285 dom_ui_->CallJavascriptFunction( |
| 286 L"options.PersonalOptions.setThemesGalleryURL", url); | |
| 295 } | 287 } |
| 296 | 288 |
| 297 #if defined(TOOLKIT_GTK) | 289 #if defined(TOOLKIT_GTK) |
| 298 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { | 290 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { |
| 299 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet")); | 291 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet")); |
| 300 dom_ui_->GetProfile()->SetNativeTheme(); | 292 dom_ui_->GetProfile()->SetNativeTheme(); |
| 301 } | 293 } |
| 302 #endif | 294 #endif |
| OLD | NEW |