| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_session_manager.h" | 5 #include "chrome/browser/chromeos/arc/arc_session_manager.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" |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 sync_preferences::PrefServiceSyncable* pref_service_syncable = | 464 sync_preferences::PrefServiceSyncable* pref_service_syncable = |
| 465 PrefServiceSyncableFromProfile(profile_); | 465 PrefServiceSyncableFromProfile(profile_); |
| 466 pref_service_syncable->RemoveObserver(this); | 466 pref_service_syncable->RemoveObserver(this); |
| 467 } | 467 } |
| 468 pref_change_registrar_.RemoveAll(); | 468 pref_change_registrar_.RemoveAll(); |
| 469 context_.reset(); | 469 context_.reset(); |
| 470 profile_ = nullptr; | 470 profile_ = nullptr; |
| 471 SetState(State::NOT_INITIALIZED); | 471 SetState(State::NOT_INITIALIZED); |
| 472 } | 472 } |
| 473 | 473 |
| 474 void ArcSessionManager::StopArc() { | |
| 475 if (state_ != State::STOPPED) { | |
| 476 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); | |
| 477 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, false); | |
| 478 } | |
| 479 ShutdownSession(); | |
| 480 if (support_host_) | |
| 481 support_host_->Close(); | |
| 482 } | |
| 483 | |
| 484 void ArcSessionManager::StartPreferenceHandler() { | 474 void ArcSessionManager::StartPreferenceHandler() { |
| 485 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 475 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 486 DCHECK(profile_); | 476 DCHECK(profile_); |
| 487 | 477 |
| 488 // Start observing Google Play Store enabled preference. | 478 // Start observing Google Play Store enabled preference. |
| 489 pref_change_registrar_.Init(profile_->GetPrefs()); | 479 pref_change_registrar_.Init(profile_->GetPrefs()); |
| 490 pref_change_registrar_.Add( | 480 pref_change_registrar_.Add( |
| 491 prefs::kArcEnabled, | 481 prefs::kArcEnabled, |
| 492 base::Bind(&ArcSessionManager::OnOptInPreferenceChanged, | 482 base::Bind(&ArcSessionManager::OnOptInPreferenceChanged, |
| 493 weak_ptr_factory_.GetWeakPtr())); | 483 weak_ptr_factory_.GetWeakPtr())); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 | 587 |
| 598 // This is the special method to support enterprise mojo API. | 588 // This is the special method to support enterprise mojo API. |
| 599 // TODO(hidehiko): Remove this. | 589 // TODO(hidehiko): Remove this. |
| 600 void ArcSessionManager::StopAndEnableArc() { | 590 void ArcSessionManager::StopAndEnableArc() { |
| 601 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 591 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 602 DCHECK(!arc_session_runner_->IsStopped()); | 592 DCHECK(!arc_session_runner_->IsStopped()); |
| 603 reenable_arc_ = true; | 593 reenable_arc_ = true; |
| 604 StopArc(); | 594 StopArc(); |
| 605 } | 595 } |
| 606 | 596 |
| 607 void ArcSessionManager::StartArc() { | |
| 608 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 609 | |
| 610 // ARC must be started only if no pending data removal request exists. | |
| 611 DCHECK(!profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); | |
| 612 | |
| 613 arc_start_time_ = base::Time::Now(); | |
| 614 | |
| 615 provisioning_reported_ = false; | |
| 616 | |
| 617 arc_session_runner_->RequestStart(); | |
| 618 SetState(State::ACTIVE); | |
| 619 } | |
| 620 | |
| 621 void ArcSessionManager::OnArcSignInTimeout() { | 597 void ArcSessionManager::OnArcSignInTimeout() { |
| 622 LOG(ERROR) << "Timed out waiting for first sign in."; | 598 LOG(ERROR) << "Timed out waiting for first sign in."; |
| 623 OnProvisioningFinished(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT); | 599 OnProvisioningFinished(ProvisioningResult::OVERALL_SIGN_IN_TIMEOUT); |
| 624 } | 600 } |
| 625 | 601 |
| 626 void ArcSessionManager::CancelAuthCode() { | 602 void ArcSessionManager::CancelAuthCode() { |
| 627 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 603 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 628 | 604 |
| 629 if (state_ == State::NOT_INITIALIZED) { | 605 if (state_ == State::NOT_INITIALIZED) { |
| 630 NOTREACHED(); | 606 NOTREACHED(); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 case policy::AndroidManagementClient::Result::MANAGED: | 874 case policy::AndroidManagementClient::Result::MANAGED: |
| 899 SetArcPlayStoreEnabledForProfile(profile_, false); | 875 SetArcPlayStoreEnabledForProfile(profile_, false); |
| 900 break; | 876 break; |
| 901 case policy::AndroidManagementClient::Result::ERROR: | 877 case policy::AndroidManagementClient::Result::ERROR: |
| 902 // This code should not be reached. For background check, | 878 // This code should not be reached. For background check, |
| 903 // retry_on_error should be set. | 879 // retry_on_error should be set. |
| 904 NOTREACHED(); | 880 NOTREACHED(); |
| 905 } | 881 } |
| 906 } | 882 } |
| 907 | 883 |
| 884 void ArcSessionManager::StartArc() { |
| 885 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 886 |
| 887 // ARC must be started only if no pending data removal request exists. |
| 888 DCHECK(!profile_->GetPrefs()->GetBoolean(prefs::kArcDataRemoveRequested)); |
| 889 |
| 890 arc_start_time_ = base::Time::Now(); |
| 891 |
| 892 provisioning_reported_ = false; |
| 893 |
| 894 arc_session_runner_->RequestStart(); |
| 895 SetState(State::ACTIVE); |
| 896 } |
| 897 |
| 898 void ArcSessionManager::StopArc() { |
| 899 if (state_ != State::STOPPED) { |
| 900 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, false); |
| 901 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, false); |
| 902 } |
| 903 ShutdownSession(); |
| 904 if (support_host_) |
| 905 support_host_->Close(); |
| 906 } |
| 907 |
| 908 void ArcSessionManager::OnWindowClosed() { | 908 void ArcSessionManager::OnWindowClosed() { |
| 909 DCHECK(support_host_); | 909 DCHECK(support_host_); |
| 910 if (terms_of_service_negotiator_) { | 910 if (terms_of_service_negotiator_) { |
| 911 // In this case, ArcTermsOfServiceNegotiator should handle the case. | 911 // In this case, ArcTermsOfServiceNegotiator should handle the case. |
| 912 // Do nothing. | 912 // Do nothing. |
| 913 return; | 913 return; |
| 914 } | 914 } |
| 915 CancelAuthCode(); | 915 CancelAuthCode(); |
| 916 } | 916 } |
| 917 | 917 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 | 993 |
| 994 #undef MAP_STATE | 994 #undef MAP_STATE |
| 995 | 995 |
| 996 // Some compilers report an error even if all values of an enum-class are | 996 // Some compilers report an error even if all values of an enum-class are |
| 997 // covered exhaustively in a switch statement. | 997 // covered exhaustively in a switch statement. |
| 998 NOTREACHED() << "Invalid value " << static_cast<int>(state); | 998 NOTREACHED() << "Invalid value " << static_cast<int>(state); |
| 999 return os; | 999 return os; |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 } // namespace arc | 1002 } // namespace arc |
| OLD | NEW |