Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/browser/dom_ui/options/personal_options_handler.cc

Issue 6344004: DOMUI: Move the meat of SyncOptionsHandler into PersonalOptionsHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 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/dom_ui/options/personal_options_handler.h" 5 #include "chrome/browser/dom_ui/options/personal_options_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/path_service.h" 12 #include "base/path_service.h"
13 #include "base/stl_util-inl.h" 13 #include "base/stl_util-inl.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/browser/browser_list.h" 17 #include "chrome/browser/browser_list.h"
18 #include "chrome/browser/dom_ui/options/dom_options_util.h" 18 #include "chrome/browser/dom_ui/options/dom_options_util.h"
19 #include "chrome/browser/dom_ui/options/options_managed_banner_handler.h" 19 #include "chrome/browser/dom_ui/options/options_managed_banner_handler.h"
20 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "chrome/browser/sync/profile_sync_service.h" 22 #include "chrome/browser/sync/profile_sync_service.h"
23 #include "chrome/browser/sync/sync_setup_flow.h"
23 #include "chrome/browser/sync/sync_ui_util.h" 24 #include "chrome/browser/sync/sync_ui_util.h"
24 #include "chrome/browser/themes/browser_theme_provider.h" 25 #include "chrome/browser/themes/browser_theme_provider.h"
25 #include "chrome/browser/ui/options/options_page_base.h" 26 #include "chrome/browser/ui/options/options_page_base.h"
26 #include "chrome/browser/ui/options/options_window.h" 27 #include "chrome/browser/ui/options/options_window.h"
27 #include "chrome/common/net/gaia/google_service_auth_error.h" 28 #include "chrome/common/net/gaia/google_service_auth_error.h"
28 #include "chrome/common/notification_service.h" 29 #include "chrome/common/notification_service.h"
29 #include "chrome/common/chrome_paths.h" 30 #include "chrome/common/chrome_paths.h"
30 #include "grit/browser_resources.h" 31 #include "grit/browser_resources.h"
31 #include "grit/chromium_strings.h" 32 #include "grit/chromium_strings.h"
32 #include "grit/generated_resources.h" 33 #include "grit/generated_resources.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 Value::CreateStringValue( 118 Value::CreateStringValue(
118 l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_SELECT_DATATYPES))); 119 l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_SELECT_DATATYPES)));
119 sync_select_list->Append(datatypes); 120 sync_select_list->Append(datatypes);
120 ListValue* everything = new ListValue; 121 ListValue* everything = new ListValue;
121 everything->Append(Value::CreateBooleanValue(true)); 122 everything->Append(Value::CreateBooleanValue(true));
122 everything->Append( 123 everything->Append(
123 Value::CreateStringValue( 124 Value::CreateStringValue(
124 l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_SELECT_EVERYTHING))); 125 l10n_util::GetStringUTF8(IDS_SYNC_OPTIONS_SELECT_EVERYTHING)));
125 sync_select_list->Append(everything); 126 sync_select_list->Append(everything);
126 localized_strings->Set("syncSelectList", sync_select_list); 127 localized_strings->Set("syncSelectList", sync_select_list);
128
129 // Sync page.
130 localized_strings->SetString("syncPage",
131 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SYNC_SECTION_TITLE));
132 localized_strings->SetString("sync_title",
133 l10n_util::GetStringUTF16(IDS_CUSTOMIZE_SYNC_DESCRIPTION));
134 localized_strings->SetString("syncsettings",
135 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_PREFERENCES));
136 localized_strings->SetString("syncbookmarks",
137 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_BOOKMARKS));
138 localized_strings->SetString("synctypedurls",
139 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_TYPED_URLS));
140 localized_strings->SetString("syncpasswords",
141 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_PASSWORDS));
142 localized_strings->SetString("syncextensions",
143 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_EXTENSIONS));
144 localized_strings->SetString("syncautofill",
145 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_AUTOFILL));
146 localized_strings->SetString("syncthemes",
147 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_THEMES));
148 localized_strings->SetString("syncapps",
149 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_APPS));
150 localized_strings->SetString("syncsessions",
151 l10n_util::GetStringUTF16(IDS_SYNC_DATATYPE_SESSIONS));
127 } 152 }
128 153
129 void PersonalOptionsHandler::RegisterMessages() { 154 void PersonalOptionsHandler::RegisterMessages() {
130 DCHECK(dom_ui_); 155 DCHECK(dom_ui_);
131 dom_ui_->RegisterMessageCallback( 156 dom_ui_->RegisterMessageCallback(
132 "showSyncLoginDialog", 157 "showSyncLoginDialog",
133 NewCallback(this, &PersonalOptionsHandler::ShowSyncLoginDialog)); 158 NewCallback(this, &PersonalOptionsHandler::ShowSyncLoginDialog));
134 dom_ui_->RegisterMessageCallback( 159 dom_ui_->RegisterMessageCallback(
135 "themesReset", 160 "themesReset",
136 NewCallback(this, &PersonalOptionsHandler::ThemesReset)); 161 NewCallback(this, &PersonalOptionsHandler::ThemesReset));
137 #if defined(TOOLKIT_GTK) 162 #if defined(TOOLKIT_GTK)
138 dom_ui_->RegisterMessageCallback( 163 dom_ui_->RegisterMessageCallback(
139 "themesSetGTK", 164 "themesSetGTK",
140 NewCallback(this, &PersonalOptionsHandler::ThemesSetGTK)); 165 NewCallback(this, &PersonalOptionsHandler::ThemesSetGTK));
141 #endif 166 #endif
167 dom_ui_->RegisterMessageCallback("updatePreferredDataTypes",
168 NewCallback(this, &PersonalOptionsHandler::OnPreferredDataTypesUpdated));
142 } 169 }
143 170
144 void PersonalOptionsHandler::Observe(NotificationType type, 171 void PersonalOptionsHandler::Observe(NotificationType type,
145 const NotificationSource& source, 172 const NotificationSource& source,
146 const NotificationDetails& details) { 173 const NotificationDetails& details) {
147 if (type == NotificationType::BROWSER_THEME_CHANGED) 174 if (type == NotificationType::BROWSER_THEME_CHANGED)
148 ObserveThemeChanged(); 175 ObserveThemeChanged();
149 else 176 else
150 OptionsPageUIHandler::Observe(type, source, details); 177 OptionsPageUIHandler::Observe(type, source, details);
151 } 178 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 245
219 visible.reset(Value::CreateBooleanValue(status_has_error)); 246 visible.reset(Value::CreateBooleanValue(status_has_error));
220 dom_ui_->CallJavascriptFunction( 247 dom_ui_->CallJavascriptFunction(
221 L"PersonalOptions.setSyncStatusErrorVisible", *visible); 248 L"PersonalOptions.setSyncStatusErrorVisible", *visible);
222 #if !defined(OS_CHROMEOS) 249 #if !defined(OS_CHROMEOS)
223 dom_ui_->CallJavascriptFunction( 250 dom_ui_->CallJavascriptFunction(
224 L"PersonalOptions.setSyncActionLinkErrorVisible", *visible); 251 L"PersonalOptions.setSyncActionLinkErrorVisible", *visible);
225 #endif 252 #endif
226 } 253 }
227 254
255 void PersonalOptionsHandler::OnLoginSuccess() {
256 OnStateChanged();
257 }
258
259 void PersonalOptionsHandler::OnLoginFailure(
260 const GoogleServiceAuthError& error) {
261 OnStateChanged();
262 }
263
228 void PersonalOptionsHandler::ObserveThemeChanged() { 264 void PersonalOptionsHandler::ObserveThemeChanged() {
229 Profile* profile = dom_ui_->GetProfile(); 265 Profile* profile = dom_ui_->GetProfile();
230 #if defined(TOOLKIT_GTK) 266 #if defined(TOOLKIT_GTK)
231 GtkThemeProvider* provider = GtkThemeProvider::GetFrom(profile); 267 GtkThemeProvider* provider = GtkThemeProvider::GetFrom(profile);
232 bool is_gtk_theme = provider->UseGtkTheme(); 268 bool is_gtk_theme = provider->UseGtkTheme();
233 FundamentalValue gtk_enabled(!is_gtk_theme); 269 FundamentalValue gtk_enabled(!is_gtk_theme);
234 dom_ui_->CallJavascriptFunction( 270 dom_ui_->CallJavascriptFunction(
235 L"options.PersonalOptions.setGtkThemeButtonEnabled", gtk_enabled); 271 L"options.PersonalOptions.setGtkThemeButtonEnabled", gtk_enabled);
236 #else 272 #else
237 BrowserThemeProvider* provider = 273 BrowserThemeProvider* provider =
(...skipping 16 matching lines...) Expand all
254 // Listen for theme installation. 290 // Listen for theme installation.
255 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, 291 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
256 NotificationService::AllSources()); 292 NotificationService::AllSources());
257 ObserveThemeChanged(); 293 ObserveThemeChanged();
258 294
259 ProfileSyncService* sync_service = 295 ProfileSyncService* sync_service =
260 dom_ui_->GetProfile()->GetProfileSyncService(); 296 dom_ui_->GetProfile()->GetProfileSyncService();
261 if (sync_service) { 297 if (sync_service) {
262 sync_service->AddObserver(this); 298 sync_service->AddObserver(this);
263 OnStateChanged(); 299 OnStateChanged();
300
301 DictionaryValue args;
302 SyncSetupFlow::GetArgsForConfigure(sync_service, &args);
303
304 dom_ui_->CallJavascriptFunction(
305 L"PersonalOptions.setRegisteredDataTypes", args);
264 } else { 306 } else {
265 dom_ui_->CallJavascriptFunction(L"options.PersonalOptions.hideSyncSection"); 307 dom_ui_->CallJavascriptFunction(L"options.PersonalOptions.hideSyncSection");
266 } 308 }
267 } 309 }
268 310
269 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) { 311 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) {
270 #if defined(OS_CHROMEOS) 312 #if defined(OS_CHROMEOS)
271 std::string email = chromeos::UserManager::Get()->logged_in_user().email(); 313 std::string email = chromeos::UserManager::Get()->logged_in_user().email();
272 string16 message = l10n_util::GetStringFUTF16( 314 string16 message = l10n_util::GetStringFUTF16(
273 IDS_SYNC_LOGIN_INTRODUCTION, 315 IDS_SYNC_LOGIN_INTRODUCTION,
(...skipping 13 matching lines...) Expand all
287 dom_ui_->GetProfile()->ClearTheme(); 329 dom_ui_->GetProfile()->ClearTheme();
288 } 330 }
289 331
290 #if defined(TOOLKIT_GTK) 332 #if defined(TOOLKIT_GTK)
291 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { 333 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) {
292 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet")); 334 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet"));
293 dom_ui_->GetProfile()->SetNativeTheme(); 335 dom_ui_->GetProfile()->SetNativeTheme();
294 } 336 }
295 #endif 337 #endif
296 338
297 void PersonalOptionsHandler::OnLoginSuccess() { 339 void PersonalOptionsHandler::OnPreferredDataTypesUpdated(
298 OnStateChanged(); 340 const ListValue* args) {
341 NotificationService::current()->Notify(
342 NotificationType::SYNC_DATA_TYPES_UPDATED,
343 Source<Profile>(dom_ui_->GetProfile()),
344 NotificationService::NoDetails());
299 } 345 }
300
301 void PersonalOptionsHandler::OnLoginFailure(
302 const GoogleServiceAuthError& error) {
303 OnStateChanged();
304 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/options/personal_options_handler.h ('k') | chrome/browser/dom_ui/options/sync_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698