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

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

Issue 4980005: Allow sync with 2-factor StrongAuth accounts in ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Refactored 2-factor error passing Created 10 years, 1 month 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) 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"
11 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "build/build_config.h" 14 #include "build/build_config.h"
15 #include "chrome/browser/browser_list.h" 15 #include "chrome/browser/browser_list.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #if defined(OS_CHROMEOS)
18 #include "chrome/browser/chromeos/login/user_manager.h"
19 #endif
17 #include "chrome/browser/dom_ui/options/options_managed_banner_handler.h" 20 #include "chrome/browser/dom_ui/options/options_managed_banner_handler.h"
18 #if defined(TOOLKIT_GTK) 21 #if defined(TOOLKIT_GTK)
19 #include "chrome/browser/gtk/gtk_theme_provider.h" 22 #include "chrome/browser/gtk/gtk_theme_provider.h"
20 #endif // defined(TOOLKIT_GTK) 23 #endif // defined(TOOLKIT_GTK)
21 #include "chrome/browser/options_page_base.h" 24 #include "chrome/browser/options_page_base.h"
22 #include "chrome/browser/options_window.h" 25 #include "chrome/browser/options_window.h"
23 #include "chrome/browser/profile.h" 26 #include "chrome/browser/profile.h"
24 #include "chrome/browser/profile_manager.h" 27 #include "chrome/browser/profile_manager.h"
25 #include "chrome/browser/sync/profile_sync_service.h" 28 #include "chrome/browser/sync/profile_sync_service.h"
26 #include "chrome/browser/sync/sync_ui_util.h" 29 #include "chrome/browser/sync/sync_ui_util.h"
27 #include "chrome/browser/themes/browser_theme_provider.h" 30 #include "chrome/browser/themes/browser_theme_provider.h"
31 #include "chrome/common/net/gaia/google_service_auth_error.h"
28 #include "chrome/common/notification_service.h" 32 #include "chrome/common/notification_service.h"
29 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
30 #include "grit/browser_resources.h" 34 #include "grit/browser_resources.h"
31 #include "grit/chromium_strings.h" 35 #include "grit/chromium_strings.h"
32 #include "grit/generated_resources.h" 36 #include "grit/generated_resources.h"
33 #include "grit/locale_settings.h" 37 #include "grit/locale_settings.h"
34 #include "grit/theme_resources.h" 38 #include "grit/theme_resources.h"
35 39
36 PersonalOptionsHandler::PersonalOptionsHandler() { 40 PersonalOptionsHandler::PersonalOptionsHandler() {
37 } 41 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 265
262 ProfileSyncService* sync_service = 266 ProfileSyncService* sync_service =
263 dom_ui_->GetProfile()->GetProfileSyncService(); 267 dom_ui_->GetProfile()->GetProfileSyncService();
264 if (sync_service) { 268 if (sync_service) {
265 sync_service->AddObserver(this); 269 sync_service->AddObserver(this);
266 OnStateChanged(); 270 OnStateChanged();
267 } 271 }
268 } 272 }
269 273
270 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) { 274 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) {
275 #if defined(OS_CHROMEOS)
276 std::string email = chromeos::UserManager::Get()->logged_in_user().email();
277 string16 message = l10n_util::GetStringFUTF16(
278 IDS_SYNC_LOGIN_INTRODUCTION,
279 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
280 dom_ui_->GetProfile()->GetBrowserSignin()->RequestSignin(
281 dom_ui_->tab_contents(), UTF8ToUTF16(email), message, this);
282 #else
271 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); 283 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService();
272 service->ShowLoginDialog(NULL); 284 service->ShowLoginDialog(NULL);
273 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS); 285 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS);
286 #endif
274 } 287 }
275 288
276 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { 289 void PersonalOptionsHandler::ThemesReset(const ListValue* args) {
277 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset")); 290 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset"));
278 dom_ui_->GetProfile()->ClearTheme(); 291 dom_ui_->GetProfile()->ClearTheme();
279 } 292 }
280 293
281 #if defined(TOOLKIT_GTK) 294 #if defined(TOOLKIT_GTK)
282 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) { 295 void PersonalOptionsHandler::ThemesSetGTK(const ListValue* args) {
283 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet")); 296 UserMetricsRecordAction(UserMetricsAction("Options_GtkThemeSet"));
284 dom_ui_->GetProfile()->SetNativeTheme(); 297 dom_ui_->GetProfile()->SetNativeTheme();
285 } 298 }
286 #endif 299 #endif
300
301 void PersonalOptionsHandler::OnLoginSuccess() {
302 OnStateChanged();
303 }
304
305 void PersonalOptionsHandler::OnLoginFailure(
306 const GoogleServiceAuthError& error) {
307 OnStateChanged();
308 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698