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/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 "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 SyncSetupFlow::GetArgsForConfigure(sync_service, &args); | 315 SyncSetupFlow::GetArgsForConfigure(sync_service, &args); |
316 | 316 |
317 dom_ui_->CallJavascriptFunction( | 317 dom_ui_->CallJavascriptFunction( |
318 L"PersonalOptions.setRegisteredDataTypes", args); | 318 L"PersonalOptions.setRegisteredDataTypes", args); |
319 } else { | 319 } else { |
320 dom_ui_->CallJavascriptFunction(L"options.PersonalOptions.hideSyncSection"); | 320 dom_ui_->CallJavascriptFunction(L"options.PersonalOptions.hideSyncSection"); |
321 } | 321 } |
322 } | 322 } |
323 | 323 |
324 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) { | 324 void PersonalOptionsHandler::ShowSyncLoginDialog(const ListValue* args) { |
325 #if defined(OS_CHROMEOS) | |
326 std::string email = chromeos::UserManager::Get()->logged_in_user().email(); | |
327 string16 message = l10n_util::GetStringFUTF16( | |
328 IDS_SYNC_LOGIN_INTRODUCTION, | |
329 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | |
330 dom_ui_->GetProfile()->GetBrowserSignin()->RequestSignin( | |
331 dom_ui_->tab_contents(), UTF8ToUTF16(email), message, this); | |
332 #else | |
333 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); | 325 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); |
334 DCHECK(service); | 326 DCHECK(service); |
335 service->ShowLoginDialog(NULL); | 327 if (service->HasSyncSetupCompleted()) { |
336 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS); | 328 service->ShowErrorUI(NULL); |
| 329 } else { |
| 330 #if defined(OS_CHROMEOS) |
| 331 std::string email = chromeos::UserManager::Get()->logged_in_user().email(); |
| 332 string16 message = l10n_util::GetStringFUTF16( |
| 333 IDS_SYNC_LOGIN_INTRODUCTION, |
| 334 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 335 dom_ui_->GetProfile()->GetBrowserSignin()->RequestSignin( |
| 336 dom_ui_->tab_contents(), UTF8ToUTF16(email), message, this); |
| 337 #else |
| 338 service->ShowLoginDialog(NULL); |
| 339 ProfileSyncService::SyncEvent(ProfileSyncService::START_FROM_OPTIONS); |
337 #endif | 340 #endif |
| 341 } |
338 } | 342 } |
339 | 343 |
340 void PersonalOptionsHandler::ShowCustomizeSyncDialog(const ListValue* args) { | 344 void PersonalOptionsHandler::ShowCustomizeSyncDialog(const ListValue* args) { |
341 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); | 345 ProfileSyncService* service = dom_ui_->GetProfile()->GetProfileSyncService(); |
342 DCHECK(service); | 346 DCHECK(service); |
343 service->ShowConfigure(NULL); | 347 service->ShowConfigure(NULL); |
344 } | 348 } |
345 | 349 |
346 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { | 350 void PersonalOptionsHandler::ThemesReset(const ListValue* args) { |
347 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset")); | 351 UserMetricsRecordAction(UserMetricsAction("Options_ThemesReset")); |
(...skipping 20 matching lines...) Expand all Loading... |
368 const SkBitmap& account_picture = | 372 const SkBitmap& account_picture = |
369 chromeos::UserManager::Get()->logged_in_user().image(); | 373 chromeos::UserManager::Get()->logged_in_user().image(); |
370 | 374 |
371 if (!account_picture.isNull()) { | 375 if (!account_picture.isNull()) { |
372 StringValue data_url(web_ui_util::GetImageDataUrl(account_picture)); | 376 StringValue data_url(web_ui_util::GetImageDataUrl(account_picture)); |
373 dom_ui_->CallJavascriptFunction(L"PersonalOptions.setAccountPicture", | 377 dom_ui_->CallJavascriptFunction(L"PersonalOptions.setAccountPicture", |
374 data_url); | 378 data_url); |
375 } | 379 } |
376 } | 380 } |
377 #endif | 381 #endif |
OLD | NEW |