| 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/sync/sync_setup_flow.h" | 5 #include "chrome/browser/sync/sync_setup_flow.h" |
| 6 | 6 |
| 7 #include "app/gfx/font_util.h" | 7 #include "app/gfx/font_util.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // So we compensate for this on non-windows platform. | 338 // So we compensate for this on non-windows platform. |
| 339 // | 339 // |
| 340 // TODO(akalin): Remove this hack once we fix the windows font problem (or at | 340 // TODO(akalin): Remove this hack once we fix the windows font problem (or at |
| 341 // least work around it in some other place). | 341 // least work around it in some other place). |
| 342 float scale_hack = 96.f/72.f; | 342 float scale_hack = 96.f/72.f; |
| 343 size->set_width(size->width() * scale_hack); | 343 size->set_width(size->width() * scale_hack); |
| 344 size->set_height(size->height() * scale_hack); | 344 size->set_height(size->height() * scale_hack); |
| 345 #endif | 345 #endif |
| 346 } | 346 } |
| 347 | 347 |
| 348 std::string SyncSetupFlow::GetDialogArgs() const { |
| 349 return dialog_start_args_; |
| 350 } |
| 351 |
| 348 // A callback to notify the delegate that the dialog closed. | 352 // A callback to notify the delegate that the dialog closed. |
| 349 void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { | 353 void SyncSetupFlow::OnDialogClosed(const std::string& json_retval) { |
| 350 DCHECK(json_retval.empty()); | 354 DCHECK(json_retval.empty()); |
| 351 container_->set_flow(NULL); // Sever ties from the wizard. | 355 container_->set_flow(NULL); // Sever ties from the wizard. |
| 352 if (current_state_ == SyncSetupWizard::DONE || | 356 if (current_state_ == SyncSetupWizard::DONE || |
| 353 current_state_ == SyncSetupWizard::DONE_FIRST_TIME) { | 357 current_state_ == SyncSetupWizard::DONE_FIRST_TIME) { |
| 354 service_->SetSyncSetupCompleted(); | 358 service_->SetSyncSetupCompleted(); |
| 355 } | 359 } |
| 356 | 360 |
| 357 // Record the state at which the user cancelled the signon dialog. | 361 // Record the state at which the user cancelled the signon dialog. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 378 base::TimeTicks::Now() - login_start_time_); | 382 base::TimeTicks::Now() - login_start_time_); |
| 379 break; | 383 break; |
| 380 default: | 384 default: |
| 381 break; | 385 break; |
| 382 } | 386 } |
| 383 | 387 |
| 384 service_->OnUserCancelledDialog(); | 388 service_->OnUserCancelledDialog(); |
| 385 delete this; | 389 delete this; |
| 386 } | 390 } |
| 387 | 391 |
| 392 std::wstring SyncSetupFlow::GetDialogTitle() const { |
| 393 return l10n_util::GetString(IDS_SYNC_MY_BOOKMARKS_LABEL); |
| 394 } |
| 395 |
| 396 bool SyncSetupFlow::IsDialogModal() const { |
| 397 return false; |
| 398 } |
| 399 |
| 400 bool SyncSetupFlow::ShouldShowDialogTitle() const { |
| 401 return true; |
| 402 } |
| 403 |
| 388 // static | 404 // static |
| 389 void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service, | 405 void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service, |
| 390 DictionaryValue* args) { | 406 DictionaryValue* args) { |
| 391 args->SetString("iframeToShow", "login"); | 407 args->SetString("iframeToShow", "login"); |
| 392 const GoogleServiceAuthError& error = service->GetAuthError(); | 408 const GoogleServiceAuthError& error = service->GetAuthError(); |
| 393 if (!service->last_attempted_user_email().empty()) { | 409 if (!service->last_attempted_user_email().empty()) { |
| 394 args->SetString("user", service->last_attempted_user_email()); | 410 args->SetString("user", service->last_attempted_user_email()); |
| 395 args->SetInteger("error", error.state()); | 411 args->SetInteger("error", error.state()); |
| 396 args->SetBoolean("editable_user", true); | 412 args->SetBoolean("editable_user", true); |
| 397 } else { | 413 } else { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 platform_util::ActivateWindow(html_dialog_window_); | 605 platform_util::ActivateWindow(html_dialog_window_); |
| 590 } | 606 } |
| 591 #else | 607 #else |
| 592 // TODO(csilv): We don't currently have a way to get the reference to the | 608 // TODO(csilv): We don't currently have a way to get the reference to the |
| 593 // dialog on windows/linux. This can be resolved by a cross platform | 609 // dialog on windows/linux. This can be resolved by a cross platform |
| 594 // implementation of HTML dialogs as described by akalin below. | 610 // implementation of HTML dialogs as described by akalin below. |
| 595 NOTIMPLEMENTED(); | 611 NOTIMPLEMENTED(); |
| 596 #endif // defined(OS_MACOSX) | 612 #endif // defined(OS_MACOSX) |
| 597 } | 613 } |
| 598 | 614 |
| 615 GURL SyncSetupFlow::GetDialogContentURL() const { |
| 616 return GURL("chrome://syncresources/setup"); |
| 617 } |
| 618 |
| 599 // static | 619 // static |
| 600 SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service, | 620 SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service, |
| 601 SyncSetupFlowContainer* container, | 621 SyncSetupFlowContainer* container, |
| 602 SyncSetupWizard::State start, | 622 SyncSetupWizard::State start, |
| 603 SyncSetupWizard::State end, | 623 SyncSetupWizard::State end, |
| 604 gfx::NativeWindow parent_window) { | 624 gfx::NativeWindow parent_window) { |
| 605 DictionaryValue args; | 625 DictionaryValue args; |
| 606 if (start == SyncSetupWizard::GAIA_LOGIN) | 626 if (start == SyncSetupWizard::GAIA_LOGIN) |
| 607 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); | 627 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); |
| 608 else if (start == SyncSetupWizard::CONFIGURE) | 628 else if (start == SyncSetupWizard::CONFIGURE) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 const std::string& mode) { | 709 const std::string& mode) { |
| 690 if (current_state_ == SyncSetupWizard::ENTER_PASSPHRASE) { | 710 if (current_state_ == SyncSetupWizard::ENTER_PASSPHRASE) { |
| 691 service_->SetPassphrase(passphrase, mode == std::string("enter")); | 711 service_->SetPassphrase(passphrase, mode == std::string("enter")); |
| 692 Advance(SyncSetupWizard::SETTING_UP); | 712 Advance(SyncSetupWizard::SETTING_UP); |
| 693 } else if (configuration_pending_) { | 713 } else if (configuration_pending_) { |
| 694 DCHECK_EQ(SyncSetupWizard::CREATE_PASSPHRASE, current_state_); | 714 DCHECK_EQ(SyncSetupWizard::CREATE_PASSPHRASE, current_state_); |
| 695 configuration_.secondary_passphrase = passphrase; | 715 configuration_.secondary_passphrase = passphrase; |
| 696 OnConfigurationComplete(); | 716 OnConfigurationComplete(); |
| 697 } | 717 } |
| 698 } | 718 } |
| OLD | NEW |