| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/arc/arc_auth_service.h" | 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/common/shelf/shelf_delegate.h" | 9 #include "ash/common/shelf/shelf_delegate.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher.h" | 17 #include "chrome/browser/chromeos/arc/arc_auth_code_fetcher.h" |
| 18 #include "chrome/browser/chromeos/arc/arc_auth_context.h" | 18 #include "chrome/browser/chromeos/arc/arc_auth_context.h" |
| 19 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" | 19 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" |
| 20 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 20 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 21 #include "chrome/browser/chromeos/arc/auth/arc_robot_auth.h" | 21 #include "chrome/browser/chromeos/arc/auth/arc_robot_auth.h" |
| 22 #include "chrome/browser/chromeos/arc/optin/arc_optin_preference_handler.h" | 22 #include "chrome/browser/chromeos/arc/optin/arc_optin_preference_handler.h" |
| 23 #include "chrome/browser/chromeos/arc/policy/arc_android_management_checker.h" | 23 #include "chrome/browser/chromeos/arc/policy/arc_android_management_checker.h" |
| 24 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h" | 24 #include "chrome/browser/chromeos/arc/policy/arc_policy_util.h" |
| 25 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 25 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 26 #include "chrome/browser/extensions/extension_util.h" | |
| 27 #include "chrome/browser/lifetime/application_lifetime.h" | 26 #include "chrome/browser/lifetime/application_lifetime.h" |
| 28 #include "chrome/browser/policy/profile_policy_connector.h" | 27 #include "chrome/browser/policy/profile_policy_connector.h" |
| 29 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 28 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 30 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 29 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 31 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 32 #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" | 31 #include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" |
| 33 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 32 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 34 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 33 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 35 #include "chrome/browser/ui/browser_commands.h" | 34 #include "chrome/browser/ui/browser_commands.h" |
| 36 #include "chrome/browser/ui/extensions/app_launch_params.h" | |
| 37 #include "chrome/browser/ui/extensions/application_launch.h" | |
| 38 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 39 #include "chrome/grit/generated_resources.h" | 36 #include "chrome/grit/generated_resources.h" |
| 40 #include "chromeos/chromeos_switches.h" | 37 #include "chromeos/chromeos_switches.h" |
| 41 #include "chromeos/cryptohome/cryptohome_parameters.h" | 38 #include "chromeos/cryptohome/cryptohome_parameters.h" |
| 42 #include "chromeos/dbus/dbus_thread_manager.h" | 39 #include "chromeos/dbus/dbus_thread_manager.h" |
| 43 #include "chromeos/dbus/session_manager_client.h" | 40 #include "chromeos/dbus/session_manager_client.h" |
| 44 #include "components/arc/arc_bridge_service.h" | 41 #include "components/arc/arc_bridge_service.h" |
| 45 #include "components/pref_registry/pref_registry_syncable.h" | 42 #include "components/pref_registry/pref_registry_syncable.h" |
| 46 #include "components/prefs/pref_service.h" | 43 #include "components/prefs/pref_service.h" |
| 47 #include "components/sync_preferences/pref_service_syncable.h" | 44 #include "components/sync_preferences/pref_service_syncable.h" |
| 48 #include "components/user_manager/user.h" | 45 #include "components/user_manager/user.h" |
| 49 #include "content/public/browser/browser_thread.h" | 46 #include "content/public/browser/browser_thread.h" |
| 50 #include "extensions/browser/app_window/app_window_registry.h" | |
| 51 #include "extensions/browser/extension_prefs.h" | 47 #include "extensions/browser/extension_prefs.h" |
| 52 #include "extensions/browser/extension_registry.h" | |
| 53 #include "ui/base/l10n/l10n_util.h" | |
| 54 | 48 |
| 55 namespace arc { | 49 namespace arc { |
| 56 | 50 |
| 57 namespace { | 51 namespace { |
| 58 | 52 |
| 59 constexpr size_t kMinVersionForOnAccountInfoReady = 5; | 53 constexpr size_t kMinVersionForOnAccountInfoReady = 5; |
| 60 | 54 |
| 61 // Weak pointer. This class is owned by ArcServiceManager. | 55 // Weak pointer. This class is owned by ArcServiceManager. |
| 62 ArcAuthService* g_arc_auth_service = nullptr; | 56 ArcAuthService* g_arc_auth_service = nullptr; |
| 63 | 57 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 DCHECK_EQ(state_, State::ACTIVE); | 445 DCHECK_EQ(state_, State::ACTIVE); |
| 452 | 446 |
| 453 if (!sign_in_time_.is_null()) { | 447 if (!sign_in_time_.is_null()) { |
| 454 arc_sign_in_timer_.Stop(); | 448 arc_sign_in_timer_.Stop(); |
| 455 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, | 449 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, |
| 456 policy_util::IsAccountManaged(profile_)); | 450 policy_util::IsAccountManaged(profile_)); |
| 457 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS, | 451 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS, |
| 458 policy_util::IsAccountManaged(profile_)); | 452 policy_util::IsAccountManaged(profile_)); |
| 459 } | 453 } |
| 460 | 454 |
| 461 CloseUI(); | 455 if (support_host_) |
| 456 support_host_->Close(); |
| 462 | 457 |
| 463 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) | 458 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn)) |
| 464 return; | 459 return; |
| 465 | 460 |
| 466 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); | 461 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); |
| 467 if (!IsOptInVerificationDisabled()) { | 462 if (!IsOptInVerificationDisabled()) { |
| 468 playstore_launcher_.reset( | 463 playstore_launcher_.reset( |
| 469 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); | 464 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); |
| 470 } | 465 } |
| 471 | 466 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 485 if (!sign_in_time_.is_null()) { | 480 if (!sign_in_time_.is_null()) { |
| 486 arc_sign_in_timer_.Stop(); | 481 arc_sign_in_timer_.Stop(); |
| 487 | 482 |
| 488 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false, | 483 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, false, |
| 489 policy_util::IsAccountManaged(profile_)); | 484 policy_util::IsAccountManaged(profile_)); |
| 490 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); | 485 UpdateOptInCancelUMA(OptInCancelReason::CLOUD_PROVISION_FLOW_FAIL); |
| 491 UpdateProvisioningResultUMA(result, | 486 UpdateProvisioningResultUMA(result, |
| 492 policy_util::IsAccountManaged(profile_)); | 487 policy_util::IsAccountManaged(profile_)); |
| 493 } | 488 } |
| 494 | 489 |
| 495 int error_message_id; | 490 ArcSupportHost::Error error; |
| 496 switch (result) { | 491 switch (result) { |
| 497 case ProvisioningResult::GMS_NETWORK_ERROR: | 492 case ProvisioningResult::GMS_NETWORK_ERROR: |
| 498 error_message_id = IDS_ARC_SIGN_IN_NETWORK_ERROR; | 493 error = ArcSupportHost::Error::SIGN_IN_NETWORK_ERROR; |
| 499 break; | 494 break; |
| 500 case ProvisioningResult::GMS_SERVICE_UNAVAILABLE: | 495 case ProvisioningResult::GMS_SERVICE_UNAVAILABLE: |
| 501 case ProvisioningResult::GMS_SIGN_IN_FAILED: | 496 case ProvisioningResult::GMS_SIGN_IN_FAILED: |
| 502 case ProvisioningResult::GMS_SIGN_IN_TIMEOUT: | 497 case ProvisioningResult::GMS_SIGN_IN_TIMEOUT: |
| 503 case ProvisioningResult::GMS_SIGN_IN_INTERNAL_ERROR: | 498 case ProvisioningResult::GMS_SIGN_IN_INTERNAL_ERROR: |
| 504 error_message_id = IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR; | 499 error = ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR; |
| 505 break; | 500 break; |
| 506 case ProvisioningResult::GMS_BAD_AUTHENTICATION: | 501 case ProvisioningResult::GMS_BAD_AUTHENTICATION: |
| 507 error_message_id = IDS_ARC_SIGN_IN_BAD_AUTHENTICATION_ERROR; | 502 error = ArcSupportHost::Error::SIGN_IN_BAD_AUTHENTICATION_ERROR; |
| 508 break; | 503 break; |
| 509 case ProvisioningResult::DEVICE_CHECK_IN_FAILED: | 504 case ProvisioningResult::DEVICE_CHECK_IN_FAILED: |
| 510 case ProvisioningResult::DEVICE_CHECK_IN_TIMEOUT: | 505 case ProvisioningResult::DEVICE_CHECK_IN_TIMEOUT: |
| 511 case ProvisioningResult::DEVICE_CHECK_IN_INTERNAL_ERROR: | 506 case ProvisioningResult::DEVICE_CHECK_IN_INTERNAL_ERROR: |
| 512 error_message_id = IDS_ARC_SIGN_IN_GMS_NOT_AVAILABLE_ERROR; | 507 error = ArcSupportHost::Error::SIGN_IN_GMS_NOT_AVAILABLE_ERROR; |
| 513 break; | 508 break; |
| 514 case ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED: | 509 case ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED: |
| 515 case ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT: | 510 case ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT: |
| 516 case ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR: | 511 case ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR: |
| 517 error_message_id = IDS_ARC_SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR; | 512 error = ArcSupportHost::Error::SIGN_IN_CLOUD_PROVISION_FLOW_FAIL_ERROR; |
| 518 break; | 513 break; |
| 519 default: | 514 default: |
| 520 error_message_id = IDS_ARC_SIGN_IN_UNKNOWN_ERROR; | 515 error = ArcSupportHost::Error::SIGN_IN_UNKNOWN_ERROR; |
| 521 break; | 516 break; |
| 522 } | 517 } |
| 523 | 518 |
| 524 if (result == ProvisioningResult::ARC_STOPPED) { | 519 if (result == ProvisioningResult::ARC_STOPPED) { |
| 525 if (profile_->GetPrefs()->HasPrefPath(prefs::kArcSignedIn)) | 520 if (profile_->GetPrefs()->HasPrefPath(prefs::kArcSignedIn)) |
| 526 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); | 521 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); |
| 527 ShutdownBridgeAndShowUI(ArcSupportHost::UIPage::ERROR, | 522 ShutdownBridge(); |
| 528 l10n_util::GetStringUTF16(error_message_id)); | 523 if (support_host_) |
| 524 support_host_->ShowError(error, false); |
| 529 return; | 525 return; |
| 530 } | 526 } |
| 531 | 527 |
| 532 if (result == ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED || | 528 if (result == ProvisioningResult::CLOUD_PROVISION_FLOW_FAILED || |
| 533 result == ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT || | 529 result == ProvisioningResult::CLOUD_PROVISION_FLOW_TIMEOUT || |
| 534 result == ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR || | 530 result == ProvisioningResult::CLOUD_PROVISION_FLOW_INTERNAL_ERROR || |
| 535 // OVERALL_SIGN_IN_TIMEOUT might be an indication that ARC believes it is | 531 // OVERALL_SIGN_IN_TIMEOUT might be an indication that ARC believes it is |
| 536 // fully setup, but Chrome does not. | 532 // fully setup, but Chrome does not. |
| 537 result == ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT || | 533 result == ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT || |
| 538 // Just to be safe, remove data if we don't know the cause. | 534 // Just to be safe, remove data if we don't know the cause. |
| 539 result == ProvisioningResult::UNKNOWN_ERROR) { | 535 result == ProvisioningResult::UNKNOWN_ERROR) { |
| 540 RemoveArcData(); | 536 RemoveArcData(); |
| 541 } | 537 } |
| 542 | 538 |
| 543 // We'll delay shutting down the bridge in this case to allow people to send | 539 // We'll delay shutting down the bridge in this case to allow people to send |
| 544 // feedback. | 540 // feedback. |
| 545 ShowUI(ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK, | 541 if (support_host_) |
| 546 l10n_util::GetStringUTF16(error_message_id)); | 542 support_host_->ShowError(error, true /* = show send feedback button */); |
| 547 } | 543 } |
| 548 | 544 |
| 549 void ArcAuthService::GetIsAccountManagedDeprecated( | 545 void ArcAuthService::GetIsAccountManagedDeprecated( |
| 550 const GetIsAccountManagedDeprecatedCallback& callback) { | 546 const GetIsAccountManagedDeprecatedCallback& callback) { |
| 551 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 547 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 552 | 548 |
| 553 callback.Run(policy_util::IsAccountManaged(profile_)); | 549 callback.Run(policy_util::IsAccountManaged(profile_)); |
| 554 } | 550 } |
| 555 | 551 |
| 556 void ArcAuthService::SetState(State state) { | 552 void ArcAuthService::SetState(State state) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 572 return; | 568 return; |
| 573 | 569 |
| 574 // TODO(khmel): Move this to IsAllowedForProfile. | 570 // TODO(khmel): Move this to IsAllowedForProfile. |
| 575 if (policy_util::IsArcDisabledForEnterprise() && | 571 if (policy_util::IsArcDisabledForEnterprise() && |
| 576 policy_util::IsAccountManaged(profile)) { | 572 policy_util::IsAccountManaged(profile)) { |
| 577 VLOG(2) << "Enterprise users are not supported in ARC."; | 573 VLOG(2) << "Enterprise users are not supported in ARC."; |
| 578 return; | 574 return; |
| 579 } | 575 } |
| 580 | 576 |
| 581 profile_ = profile; | 577 profile_ = profile; |
| 578 |
| 582 // Create the support host at initialization. Note that, practically, | 579 // Create the support host at initialization. Note that, practically, |
| 583 // ARC support Chrome app is rarely used (only opt-in and re-auth flow). | 580 // ARC support Chrome app is rarely used (only opt-in and re-auth flow). |
| 584 // So, it may be better to initialize it lazily. | 581 // So, it may be better to initialize it lazily. |
| 585 // TODO(hidehiko): Revisit to think about lazy initialization. | 582 // TODO(hidehiko): Revisit to think about lazy initialization. |
| 586 support_host_.reset(new ArcSupportHost()); | 583 // |
| 587 support_host_->AddObserver(this); | 584 // Don't show UI for ARC Kiosk because the only one UI in kiosk mode must |
| 588 if (!g_disable_ui_for_testing && !IsOptInVerificationDisabled()) { | 585 // be the kiosk app. In case of error the UI will be useless as well, because |
| 586 // in typical use case there will be no one nearby the kiosk device, who can |
| 587 // do some action to solve the problem be means of UI. |
| 588 if (!g_disable_ui_for_testing && !IsOptInVerificationDisabled() && |
| 589 !IsArcKioskMode()) { |
| 590 support_host_ = base::MakeUnique<ArcSupportHost>(profile_); |
| 591 support_host_->AddObserver(this); |
| 592 |
| 589 preference_handler_ = base::MakeUnique<arc::ArcOptInPreferenceHandler>( | 593 preference_handler_ = base::MakeUnique<arc::ArcOptInPreferenceHandler>( |
| 590 this, profile_->GetPrefs()); | 594 this, profile_->GetPrefs()); |
| 591 // This automatically updates all preferences. | 595 // This automatically updates all preferences. |
| 592 preference_handler_->Start(); | 596 preference_handler_->Start(); |
| 593 } | 597 } |
| 594 | 598 |
| 595 DCHECK_EQ(State::NOT_INITIALIZED, state_); | 599 DCHECK_EQ(State::NOT_INITIALIZED, state_); |
| 596 SetState(State::STOPPED); | 600 SetState(State::STOPPED); |
| 597 | 601 |
| 598 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( | 602 PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 623 if (!pref_service_syncable->IsSyncing()) | 627 if (!pref_service_syncable->IsSyncing()) |
| 624 return; | 628 return; |
| 625 | 629 |
| 626 pref_service_syncable->RemoveObserver(this); | 630 pref_service_syncable->RemoveObserver(this); |
| 627 | 631 |
| 628 if (IsArcEnabled()) | 632 if (IsArcEnabled()) |
| 629 OnOptInPreferenceChanged(); | 633 OnOptInPreferenceChanged(); |
| 630 } | 634 } |
| 631 | 635 |
| 632 void ArcAuthService::Shutdown() { | 636 void ArcAuthService::Shutdown() { |
| 633 ShutdownBridgeAndCloseUI(); | 637 ShutdownBridge(); |
| 638 if (support_host_) |
| 639 support_host_->Close(); |
| 634 if (profile_) { | 640 if (profile_) { |
| 635 sync_preferences::PrefServiceSyncable* pref_service_syncable = | 641 sync_preferences::PrefServiceSyncable* pref_service_syncable = |
| 636 PrefServiceSyncableFromProfile(profile_); | 642 PrefServiceSyncableFromProfile(profile_); |
| 637 pref_service_syncable->RemoveObserver(this); | 643 pref_service_syncable->RemoveObserver(this); |
| 638 pref_service_syncable->RemoveSyncedPrefObserver(prefs::kArcEnabled, this); | 644 pref_service_syncable->RemoveSyncedPrefObserver(prefs::kArcEnabled, this); |
| 639 } | 645 } |
| 640 pref_change_registrar_.RemoveAll(); | 646 pref_change_registrar_.RemoveAll(); |
| 641 context_.reset(); | 647 context_.reset(); |
| 642 profile_ = nullptr; | 648 profile_ = nullptr; |
| 643 arc_robot_auth_.reset(); | 649 arc_robot_auth_.reset(); |
| 644 SetState(State::NOT_INITIALIZED); | 650 SetState(State::NOT_INITIALIZED); |
| 645 } | 651 } |
| 646 | 652 |
| 647 void ArcAuthService::ShowUI(ArcSupportHost::UIPage page, | |
| 648 const base::string16& status) { | |
| 649 if (g_disable_ui_for_testing || IsOptInVerificationDisabled()) | |
| 650 return; | |
| 651 | |
| 652 // Don't show UI for ARC Kiosk because the only one UI in kiosk mode must | |
| 653 // be the kiosk app. In case of error the UI will be useless as well, because | |
| 654 // in typical use case there will be no one nearby the kiosk device, who can | |
| 655 // do some action to solve the problem be means of UI. | |
| 656 if (IsArcKioskMode()) | |
| 657 return; | |
| 658 | |
| 659 SetUIPage(page, status); | |
| 660 const extensions::AppWindowRegistry* const app_window_registry = | |
| 661 extensions::AppWindowRegistry::Get(profile_); | |
| 662 DCHECK(app_window_registry); | |
| 663 if (app_window_registry->GetCurrentAppWindowForApp( | |
| 664 ArcSupportHost::kHostAppId)) { | |
| 665 return; | |
| 666 } | |
| 667 | |
| 668 const extensions::Extension* extension = | |
| 669 extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension( | |
| 670 ArcSupportHost::kHostAppId); | |
| 671 CHECK(extension && extensions::util::IsAppLaunchable( | |
| 672 ArcSupportHost::kHostAppId, profile_)); | |
| 673 OpenApplication(CreateAppLaunchParamsUserContainer( | |
| 674 profile_, extension, WindowOpenDisposition::NEW_WINDOW, | |
| 675 extensions::SOURCE_CHROME_INTERNAL)); | |
| 676 } | |
| 677 | |
| 678 void ArcAuthService::OnContextReady() { | 653 void ArcAuthService::OnContextReady() { |
| 679 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 654 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 680 FetchAuthCode(); | 655 FetchAuthCode(); |
| 681 } | 656 } |
| 682 | 657 |
| 683 void ArcAuthService::OnSyncedPrefChanged(const std::string& path, | 658 void ArcAuthService::OnSyncedPrefChanged(const std::string& path, |
| 684 bool from_sync) { | 659 bool from_sync) { |
| 685 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 660 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 686 | 661 |
| 687 // Update UMA only for local changes | 662 // Update UMA only for local changes |
| 688 if (!from_sync) { | 663 if (!from_sync) { |
| 689 const bool arc_enabled = | 664 const bool arc_enabled = |
| 690 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); | 665 profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); |
| 691 UpdateOptInActionUMA(arc_enabled ? OptInActionType::OPTED_IN | 666 UpdateOptInActionUMA(arc_enabled ? OptInActionType::OPTED_IN |
| 692 : OptInActionType::OPTED_OUT); | 667 : OptInActionType::OPTED_OUT); |
| 693 | 668 |
| 694 if (!arc_enabled && !IsArcManaged()) { | 669 if (!arc_enabled && !IsArcManaged()) { |
| 695 ash::ShelfDelegate* shelf_delegate = GetShelfDelegate(); | 670 ash::ShelfDelegate* shelf_delegate = GetShelfDelegate(); |
| 696 if (shelf_delegate) | 671 if (shelf_delegate) |
| 697 shelf_delegate->UnpinAppWithID(ArcSupportHost::kHostAppId); | 672 shelf_delegate->UnpinAppWithID(ArcSupportHost::kHostAppId); |
| 698 } | 673 } |
| 699 } | 674 } |
| 700 } | 675 } |
| 701 | 676 |
| 702 void ArcAuthService::StopArc() { | 677 void ArcAuthService::StopArc() { |
| 703 if (state_ != State::STOPPED) { | 678 if (state_ != State::STOPPED) { |
| 704 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); | 679 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); |
| 705 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, false); | 680 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, false); |
| 706 } | 681 } |
| 707 ShutdownBridgeAndCloseUI(); | 682 ShutdownBridge(); |
| 683 if (support_host_) |
| 684 support_host_->Close(); |
| 708 } | 685 } |
| 709 | 686 |
| 710 void ArcAuthService::OnOptInPreferenceChanged() { | 687 void ArcAuthService::OnOptInPreferenceChanged() { |
| 711 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 688 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 712 DCHECK(profile_); | 689 DCHECK(profile_); |
| 713 | 690 |
| 714 // TODO(dspaid): Move code from OnSyncedPrefChanged into this method. | 691 // TODO(dspaid): Move code from OnSyncedPrefChanged into this method. |
| 715 OnSyncedPrefChanged(prefs::kArcEnabled, IsArcManaged()); | 692 OnSyncedPrefChanged(prefs::kArcEnabled, IsArcManaged()); |
| 716 | 693 |
| 717 const bool arc_enabled = IsArcEnabled(); | 694 const bool arc_enabled = IsArcEnabled(); |
| 718 for (auto& observer : observer_list_) | 695 for (auto& observer : observer_list_) |
| 719 observer.OnOptInEnabled(arc_enabled); | 696 observer.OnOptInEnabled(arc_enabled); |
| 720 | 697 |
| 721 if (!arc_enabled) { | 698 if (!arc_enabled) { |
| 722 StopArc(); | 699 StopArc(); |
| 723 RemoveArcData(); | 700 RemoveArcData(); |
| 724 return; | 701 return; |
| 725 } | 702 } |
| 726 | 703 |
| 727 if (state_ == State::ACTIVE) | 704 if (state_ == State::ACTIVE) |
| 728 return; | 705 return; |
| 729 | 706 |
| 707 if (support_host_) |
| 708 support_host_->SetArcManaged(IsArcManaged()); |
| 709 |
| 730 // In case UI is disabled we assume that ARC is opted-in. For ARC Kiosk we | 710 // In case UI is disabled we assume that ARC is opted-in. For ARC Kiosk we |
| 731 // skip ToS because it is very likely that near the device there will be | 711 // skip ToS because it is very likely that near the device there will be |
| 732 // no one who is eligible to accept them. We skip if Android management check | 712 // no one who is eligible to accept them. We skip if Android management check |
| 733 // because there are no managed human users for Kiosk exist. | 713 // because there are no managed human users for Kiosk exist. |
| 734 if (IsOptInVerificationDisabled() || IsArcKioskMode()) { | 714 if (IsOptInVerificationDisabled() || IsArcKioskMode()) { |
| 735 // Automatically accept terms in kiosk mode. This is not required for | 715 // Automatically accept terms in kiosk mode. This is not required for |
| 736 // IsOptInVerificationDisabled mode because in last case it may cause | 716 // IsOptInVerificationDisabled mode because in last case it may cause |
| 737 // a privacy issue on next run without this flag set. | 717 // a privacy issue on next run without this flag set. |
| 738 if (IsArcKioskMode()) | 718 if (IsArcKioskMode()) |
| 739 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); | 719 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 account_info_notifier_.reset(); | 753 account_info_notifier_.reset(); |
| 774 android_management_checker_.reset(); | 754 android_management_checker_.reset(); |
| 775 auth_code_fetcher_.reset(); | 755 auth_code_fetcher_.reset(); |
| 776 arc_bridge_service()->RequestStop(); | 756 arc_bridge_service()->RequestStop(); |
| 777 if (state_ != State::NOT_INITIALIZED) | 757 if (state_ != State::NOT_INITIALIZED) |
| 778 SetState(State::STOPPED); | 758 SetState(State::STOPPED); |
| 779 for (auto& observer : observer_list_) | 759 for (auto& observer : observer_list_) |
| 780 observer.OnShutdownBridge(); | 760 observer.OnShutdownBridge(); |
| 781 } | 761 } |
| 782 | 762 |
| 783 void ArcAuthService::ShutdownBridgeAndCloseUI() { | |
| 784 ShutdownBridge(); | |
| 785 CloseUI(); | |
| 786 } | |
| 787 | |
| 788 void ArcAuthService::ShutdownBridgeAndShowUI(ArcSupportHost::UIPage page, | |
| 789 const base::string16& status) { | |
| 790 ShutdownBridge(); | |
| 791 ShowUI(page, status); | |
| 792 } | |
| 793 | |
| 794 void ArcAuthService::AddObserver(Observer* observer) { | 763 void ArcAuthService::AddObserver(Observer* observer) { |
| 795 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 764 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 796 observer_list_.AddObserver(observer); | 765 observer_list_.AddObserver(observer); |
| 797 } | 766 } |
| 798 | 767 |
| 799 void ArcAuthService::RemoveObserver(Observer* observer) { | 768 void ArcAuthService::RemoveObserver(Observer* observer) { |
| 800 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 769 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 801 observer_list_.RemoveObserver(observer); | 770 observer_list_.RemoveObserver(observer); |
| 802 } | 771 } |
| 803 | 772 |
| 804 void ArcAuthService::CloseUI() { | |
| 805 ui_page_ = ArcSupportHost::UIPage::NO_PAGE; | |
| 806 ui_page_status_.clear(); | |
| 807 | |
| 808 if (support_host_) | |
| 809 support_host_->Close(); | |
| 810 } | |
| 811 | |
| 812 void ArcAuthService::SetUIPage(ArcSupportHost::UIPage page, | |
| 813 const base::string16& status) { | |
| 814 ui_page_ = page; | |
| 815 ui_page_status_ = status; | |
| 816 if (support_host_) | |
| 817 support_host_->ShowPage(ui_page_, ui_page_status_); | |
| 818 } | |
| 819 | |
| 820 // This is the special method to support enterprise mojo API. | 773 // This is the special method to support enterprise mojo API. |
| 821 // TODO(hidehiko): Remove this. | 774 // TODO(hidehiko): Remove this. |
| 822 void ArcAuthService::StopAndEnableArc() { | 775 void ArcAuthService::StopAndEnableArc() { |
| 823 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 776 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 824 DCHECK(!arc_bridge_service()->stopped()); | 777 DCHECK(!arc_bridge_service()->stopped()); |
| 825 reenable_arc_ = true; | 778 reenable_arc_ = true; |
| 826 StopArc(); | 779 StopArc(); |
| 827 } | 780 } |
| 828 | 781 |
| 829 void ArcAuthService::StartArc() { | 782 void ArcAuthService::StartArc() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 848 } | 801 } |
| 849 | 802 |
| 850 void ArcAuthService::CancelAuthCode() { | 803 void ArcAuthService::CancelAuthCode() { |
| 851 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 804 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 852 | 805 |
| 853 if (state_ == State::NOT_INITIALIZED) { | 806 if (state_ == State::NOT_INITIALIZED) { |
| 854 NOTREACHED(); | 807 NOTREACHED(); |
| 855 return; | 808 return; |
| 856 } | 809 } |
| 857 | 810 |
| 858 // In case |state_| is ACTIVE, |ui_page_| can be START_PROGRESS (which means | 811 // In case |state_| is ACTIVE, UI page can be ARC_LOADING (which means normal |
| 859 // normal Arc booting) or ERROR or ERROR_WITH_FEEDBACK (in case Arc can not | 812 // ARC booting) or ERROR (in case ARC can not be started). If ARC is booting |
| 860 // be started). If Arc is booting normally dont't stop it on progress close. | 813 // normally don't stop it on progress close. |
| 861 if ((state_ != State::SHOWING_TERMS_OF_SERVICE && | 814 if ((state_ != State::SHOWING_TERMS_OF_SERVICE && |
| 862 state_ != State::CHECKING_ANDROID_MANAGEMENT) && | 815 state_ != State::CHECKING_ANDROID_MANAGEMENT) && |
| 863 ui_page_ != ArcSupportHost::UIPage::ERROR && | 816 (!support_host_ || |
| 864 ui_page_ != ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) { | 817 support_host_->ui_page() != ArcSupportHost::UIPage::ERROR)) { |
| 865 return; | 818 return; |
| 866 } | 819 } |
| 867 | 820 |
| 868 // Update UMA with user cancel only if error is not currently shown. | 821 // Update UMA with user cancel only if error is not currently shown. |
| 869 if (ui_page_ != ArcSupportHost::UIPage::NO_PAGE && | 822 if (support_host_ && |
| 870 ui_page_ != ArcSupportHost::UIPage::ERROR && | 823 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE && |
| 871 ui_page_ != ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) { | 824 support_host_->ui_page() != ArcSupportHost::UIPage::ERROR) { |
| 872 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); | 825 UpdateOptInCancelUMA(OptInCancelReason::USER_CANCEL); |
| 873 } | 826 } |
| 874 | 827 |
| 875 StopArc(); | 828 StopArc(); |
| 876 | 829 |
| 877 if (IsArcManaged()) | 830 if (IsArcManaged()) |
| 878 return; | 831 return; |
| 879 | 832 |
| 880 DisableArc(); | 833 DisableArc(); |
| 881 } | 834 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 if (IsAllowed()) | 873 if (IsAllowed()) |
| 921 UpdateEnabledStateUMA(IsArcEnabled()); | 874 UpdateEnabledStateUMA(IsArcEnabled()); |
| 922 } | 875 } |
| 923 | 876 |
| 924 void ArcAuthService::StartUI() { | 877 void ArcAuthService::StartUI() { |
| 925 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 878 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 926 | 879 |
| 927 if (!arc_bridge_service()->stopped()) { | 880 if (!arc_bridge_service()->stopped()) { |
| 928 // If the user attempts to re-enable ARC while the bridge is still running | 881 // If the user attempts to re-enable ARC while the bridge is still running |
| 929 // the user should not be able to continue until the bridge has stopped. | 882 // the user should not be able to continue until the bridge has stopped. |
| 930 ShowUI( | 883 if (support_host_) { |
| 931 ArcSupportHost::UIPage::ERROR, | 884 support_host_->ShowError( |
| 932 l10n_util::GetStringUTF16(IDS_ARC_SIGN_IN_SERVICE_UNAVAILABLE_ERROR)); | 885 ArcSupportHost::Error::SIGN_IN_SERVICE_UNAVAILABLE_ERROR, false); |
| 886 } |
| 933 return; | 887 return; |
| 934 } | 888 } |
| 935 | 889 |
| 936 SetState(State::SHOWING_TERMS_OF_SERVICE); | 890 SetState(State::SHOWING_TERMS_OF_SERVICE); |
| 937 ShowUI(ArcSupportHost::UIPage::TERMS, base::string16()); | 891 if (support_host_) |
| 892 support_host_->ShowTermsOfService(); |
| 938 } | 893 } |
| 939 | 894 |
| 940 void ArcAuthService::OnPrepareContextFailed() { | 895 void ArcAuthService::OnPrepareContextFailed() { |
| 941 ShutdownBridgeAndShowUI( | 896 ShutdownBridge(); |
| 942 ArcSupportHost::UIPage::ERROR, | 897 if (support_host_) { |
| 943 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); | 898 support_host_->ShowError(ArcSupportHost::Error::SERVER_COMMUNICATION_ERROR, |
| 899 false); |
| 900 } |
| 944 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 901 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
| 945 } | 902 } |
| 946 | 903 |
| 947 void ArcAuthService::OnAuthCodeSuccess(const std::string& auth_code) { | 904 void ArcAuthService::OnAuthCodeSuccess(const std::string& auth_code) { |
| 948 OnAuthCodeObtained(auth_code); | 905 OnAuthCodeObtained(auth_code); |
| 949 } | 906 } |
| 950 | 907 |
| 951 void ArcAuthService::OnAuthCodeFailed() { | 908 void ArcAuthService::OnAuthCodeFailed() { |
| 952 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 909 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 953 ShutdownBridgeAndShowUI( | 910 ShutdownBridge(); |
| 954 ArcSupportHost::UIPage::ERROR, | 911 if (support_host_) { |
| 955 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); | 912 support_host_->ShowError(ArcSupportHost::Error::SERVER_COMMUNICATION_ERROR, |
| 913 false); |
| 914 } |
| 956 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 915 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
| 957 } | 916 } |
| 958 | 917 |
| 959 void ArcAuthService::StartArcAndroidManagementCheck() { | 918 void ArcAuthService::StartArcAndroidManagementCheck() { |
| 960 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 919 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 961 DCHECK(arc_bridge_service()->stopped()); | 920 DCHECK(arc_bridge_service()->stopped()); |
| 962 DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE || | 921 DCHECK(state_ == State::SHOWING_TERMS_OF_SERVICE || |
| 963 state_ == State::CHECKING_ANDROID_MANAGEMENT); | 922 state_ == State::CHECKING_ANDROID_MANAGEMENT); |
| 964 SetState(State::CHECKING_ANDROID_MANAGEMENT); | 923 SetState(State::CHECKING_ANDROID_MANAGEMENT); |
| 965 | 924 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 979 switch (result) { | 938 switch (result) { |
| 980 case policy::AndroidManagementClient::Result::UNMANAGED: | 939 case policy::AndroidManagementClient::Result::UNMANAGED: |
| 981 VLOG(1) << "Starting ARC for first sign in."; | 940 VLOG(1) << "Starting ARC for first sign in."; |
| 982 sign_in_time_ = base::Time::Now(); | 941 sign_in_time_ = base::Time::Now(); |
| 983 arc_sign_in_timer_.Start(FROM_HERE, kArcSignInTimeout, | 942 arc_sign_in_timer_.Start(FROM_HERE, kArcSignInTimeout, |
| 984 base::Bind(&ArcAuthService::OnArcSignInTimeout, | 943 base::Bind(&ArcAuthService::OnArcSignInTimeout, |
| 985 weak_ptr_factory_.GetWeakPtr())); | 944 weak_ptr_factory_.GetWeakPtr())); |
| 986 StartArc(); | 945 StartArc(); |
| 987 break; | 946 break; |
| 988 case policy::AndroidManagementClient::Result::MANAGED: | 947 case policy::AndroidManagementClient::Result::MANAGED: |
| 989 ShutdownBridgeAndShowUI( | 948 ShutdownBridge(); |
| 990 ArcSupportHost::UIPage::ERROR, | 949 if (support_host_) { |
| 991 l10n_util::GetStringUTF16(IDS_ARC_ANDROID_MANAGEMENT_REQUIRED_ERROR)); | 950 support_host_->ShowError( |
| 951 ArcSupportHost::Error::ANDROID_MANAGEMENT_REQUIRED_ERROR, false); |
| 952 } |
| 992 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED); | 953 UpdateOptInCancelUMA(OptInCancelReason::ANDROID_MANAGEMENT_REQUIRED); |
| 993 break; | 954 break; |
| 994 case policy::AndroidManagementClient::Result::ERROR: | 955 case policy::AndroidManagementClient::Result::ERROR: |
| 995 ShutdownBridgeAndShowUI( | 956 ShutdownBridge(); |
| 996 ArcSupportHost::UIPage::ERROR, | 957 if (support_host_) { |
| 997 l10n_util::GetStringUTF16(IDS_ARC_SERVER_COMMUNICATION_ERROR)); | 958 support_host_->ShowError( |
| 959 ArcSupportHost::Error::SERVER_COMMUNICATION_ERROR, false); |
| 960 } |
| 998 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); | 961 UpdateOptInCancelUMA(OptInCancelReason::NETWORK_ERROR); |
| 999 break; | 962 break; |
| 1000 } | 963 } |
| 1001 } | 964 } |
| 1002 | 965 |
| 1003 void ArcAuthService::OnBackgroundAndroidManagementChecked( | 966 void ArcAuthService::OnBackgroundAndroidManagementChecked( |
| 1004 policy::AndroidManagementClient::Result result) { | 967 policy::AndroidManagementClient::Result result) { |
| 1005 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 968 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 1006 switch (result) { | 969 switch (result) { |
| 1007 case policy::AndroidManagementClient::Result::UNMANAGED: | 970 case policy::AndroidManagementClient::Result::UNMANAGED: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1025 std::string auth_endpoint; | 988 std::string auth_endpoint; |
| 1026 if (command_line->HasSwitch(chromeos::switches::kArcUseAuthEndpoint)) { | 989 if (command_line->HasSwitch(chromeos::switches::kArcUseAuthEndpoint)) { |
| 1027 auth_endpoint = command_line->GetSwitchValueASCII( | 990 auth_endpoint = command_line->GetSwitchValueASCII( |
| 1028 chromeos::switches::kArcUseAuthEndpoint); | 991 chromeos::switches::kArcUseAuthEndpoint); |
| 1029 } | 992 } |
| 1030 | 993 |
| 1031 if (!auth_endpoint.empty()) { | 994 if (!auth_endpoint.empty()) { |
| 1032 auth_code_fetcher_.reset(new ArcAuthCodeFetcher( | 995 auth_code_fetcher_.reset(new ArcAuthCodeFetcher( |
| 1033 this, context_->GetURLRequestContext(), profile_, auth_endpoint)); | 996 this, context_->GetURLRequestContext(), profile_, auth_endpoint)); |
| 1034 } else { | 997 } else { |
| 1035 ShowUI(ArcSupportHost::UIPage::LSO_PROGRESS, base::string16()); | 998 if (support_host_) |
| 999 support_host_->ShowLso(); |
| 1036 } | 1000 } |
| 1037 } | 1001 } |
| 1038 | 1002 |
| 1039 void ArcAuthService::OnWindowClosed() { | 1003 void ArcAuthService::OnWindowClosed() { |
| 1004 DCHECK(support_host_); |
| 1040 CancelAuthCode(); | 1005 CancelAuthCode(); |
| 1041 } | 1006 } |
| 1042 | 1007 |
| 1043 void ArcAuthService::OnTermsAgreed(bool is_metrics_enabled, | 1008 void ArcAuthService::OnTermsAgreed(bool is_metrics_enabled, |
| 1044 bool is_backup_and_restore_enabled, | 1009 bool is_backup_and_restore_enabled, |
| 1045 bool is_location_service_enabled) { | 1010 bool is_location_service_enabled) { |
| 1011 DCHECK(support_host_); |
| 1012 |
| 1046 // Terms were accepted | 1013 // Terms were accepted |
| 1047 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); | 1014 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); |
| 1048 | 1015 |
| 1049 // This is ARC support's UI event callback, so this is called only when | 1016 // Since this is ARC support's UI event callback, preference_handler_ |
| 1050 // the UI is visible. The condition to open the UI is | 1017 // should be always created (see OnPrimaryUserProfilePrepared()). |
| 1051 // !g_disable_ui_for_testing && !IsOptInVerificationDisabled() (see ShowUI()) | |
| 1052 // and in the case, preference_handler_ should be always created (see | |
| 1053 // OnPrimaryUserProfilePrepared()), | |
| 1054 // TODO(hidehiko): Simplify the logic with the code restructuring. | 1018 // TODO(hidehiko): Simplify the logic with the code restructuring. |
| 1055 DCHECK(preference_handler_); | 1019 DCHECK(preference_handler_); |
| 1056 preference_handler_->EnableMetrics(is_metrics_enabled); | 1020 preference_handler_->EnableMetrics(is_metrics_enabled); |
| 1057 preference_handler_->EnableBackupRestore(is_backup_and_restore_enabled); | 1021 preference_handler_->EnableBackupRestore(is_backup_and_restore_enabled); |
| 1058 preference_handler_->EnableLocationService(is_location_service_enabled); | 1022 preference_handler_->EnableLocationService(is_location_service_enabled); |
| 1059 SetUIPage(ArcSupportHost::UIPage::START_PROGRESS, base::string16()); | 1023 support_host_->ShowArcLoading(); |
| 1060 StartArcAndroidManagementCheck(); | 1024 StartArcAndroidManagementCheck(); |
| 1061 } | 1025 } |
| 1062 | 1026 |
| 1063 void ArcAuthService::OnAuthSucceeded(const std::string& auth_code) { | 1027 void ArcAuthService::OnAuthSucceeded(const std::string& auth_code) { |
| 1028 DCHECK(support_host_); |
| 1064 OnAuthCodeObtained(auth_code); | 1029 OnAuthCodeObtained(auth_code); |
| 1065 } | 1030 } |
| 1066 | 1031 |
| 1067 void ArcAuthService::OnRetryClicked() { | 1032 void ArcAuthService::OnRetryClicked() { |
| 1033 DCHECK(support_host_); |
| 1034 |
| 1068 UpdateOptInActionUMA(OptInActionType::RETRY); | 1035 UpdateOptInActionUMA(OptInActionType::RETRY); |
| 1069 | 1036 |
| 1070 // TODO(hidehiko): Simplify the retry logic. | 1037 // TODO(hidehiko): Simplify the retry logic. |
| 1071 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { | 1038 if (!profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { |
| 1072 // If the user has not yet agreed on Terms of Service, then show it. | 1039 // If the user has not yet agreed on Terms of Service, then show it. |
| 1073 ShowUI(ArcSupportHost::UIPage::TERMS, base::string16()); | 1040 support_host_->ShowTermsOfService(); |
| 1074 } else if (ui_page_ == ArcSupportHost::UIPage::ERROR_WITH_FEEDBACK) { | 1041 } else if (support_host_->ui_page() == ArcSupportHost::UIPage::ERROR && |
| 1042 !arc_bridge_service()->stopped()) { |
| 1075 // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping | 1043 // ERROR_WITH_FEEDBACK is set in OnSignInFailed(). In the case, stopping |
| 1076 // ARC was postponed to contain its internal state into the report. | 1044 // ARC was postponed to contain its internal state into the report. |
| 1077 // Here, on retry, stop it, then restart. | 1045 // Here, on retry, stop it, then restart. |
| 1078 DCHECK_EQ(State::ACTIVE, state_); | 1046 DCHECK_EQ(State::ACTIVE, state_); |
| 1079 SetUIPage(ArcSupportHost::UIPage::START_PROGRESS, base::string16()); | 1047 support_host_->ShowArcLoading(); |
| 1080 ShutdownBridge(); | 1048 ShutdownBridge(); |
| 1081 reenable_arc_ = true; | 1049 reenable_arc_ = true; |
| 1082 } else if (state_ == State::ACTIVE) { | 1050 } else if (state_ == State::ACTIVE) { |
| 1083 // This happens when ARC support Chrome app reports an error on "Sign in" | 1051 // This happens when ARC support Chrome app reports an error on "Sign in" |
| 1084 // page. | 1052 // page. |
| 1085 // TODO(hidehiko): Currently, due to the existing code structure, we need | 1053 // TODO(hidehiko): Currently, due to the existing code structure, we need |
| 1086 // to call PrepareContextForAuthCodeRequest() always. However, to fetch | 1054 // to call PrepareContextForAuthCodeRequest() always. However, to fetch |
| 1087 // an authtoken via LSO page, it is not necessary to call PrepareContext(). | 1055 // an authtoken via LSO page, it is not necessary to call PrepareContext(). |
| 1088 // Instead, it is possible to show LSO page, immediately. | 1056 // Instead, it is possible to show LSO page, immediately. |
| 1089 SetUIPage(ArcSupportHost::UIPage::START_PROGRESS, base::string16()); | 1057 support_host_->ShowArcLoading(); |
| 1090 PrepareContextForAuthCodeRequest(); | 1058 PrepareContextForAuthCodeRequest(); |
| 1091 } else { | 1059 } else { |
| 1092 // Otherwise, we restart ARC. Note: this is the first boot case. | 1060 // Otherwise, we restart ARC. Note: this is the first boot case. |
| 1093 // For second or later boot, either ERROR_WITH_FEEDBACK case or ACTIVE | 1061 // For second or later boot, either ERROR_WITH_FEEDBACK case or ACTIVE |
| 1094 // case must hit. | 1062 // case must hit. |
| 1095 SetUIPage(ArcSupportHost::UIPage::START_PROGRESS, base::string16()); | 1063 support_host_->ShowArcLoading(); |
| 1096 StartArcAndroidManagementCheck(); | 1064 StartArcAndroidManagementCheck(); |
| 1097 } | 1065 } |
| 1098 } | 1066 } |
| 1099 | 1067 |
| 1100 void ArcAuthService::OnSendFeedbackClicked() { | 1068 void ArcAuthService::OnSendFeedbackClicked() { |
| 1069 DCHECK(support_host_); |
| 1101 chrome::OpenFeedbackDialog(nullptr); | 1070 chrome::OpenFeedbackDialog(nullptr); |
| 1102 } | 1071 } |
| 1103 | 1072 |
| 1104 void ArcAuthService::OnMetricsModeChanged(bool enabled, bool managed) { | 1073 void ArcAuthService::OnMetricsModeChanged(bool enabled, bool managed) { |
| 1105 if (!support_host_) | 1074 if (!support_host_) |
| 1106 return; | 1075 return; |
| 1107 support_host_->SetMetricsPreferenceCheckbox(enabled, managed); | 1076 support_host_->SetMetricsPreferenceCheckbox(enabled, managed); |
| 1108 } | 1077 } |
| 1109 | 1078 |
| 1110 void ArcAuthService::OnBackupAndRestoreModeChanged(bool enabled, bool managed) { | 1079 void ArcAuthService::OnBackupAndRestoreModeChanged(bool enabled, bool managed) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1133 return os << "ACTIVE"; | 1102 return os << "ACTIVE"; |
| 1134 } | 1103 } |
| 1135 | 1104 |
| 1136 // Some compiler reports an error even if all values of an enum-class are | 1105 // Some compiler reports an error even if all values of an enum-class are |
| 1137 // covered indivisually in a switch statement. | 1106 // covered indivisually in a switch statement. |
| 1138 NOTREACHED(); | 1107 NOTREACHED(); |
| 1139 return os; | 1108 return os; |
| 1140 } | 1109 } |
| 1141 | 1110 |
| 1142 } // namespace arc | 1111 } // namespace arc |
| OLD | NEW |