| Index: chrome/browser/chromeos/arc/arc_support_host.cc
|
| diff --git a/chrome/browser/chromeos/arc/arc_support_host.cc b/chrome/browser/chromeos/arc/arc_support_host.cc
|
| index f34771731e0e443b62edd325f2df5f5c621cdc3d..f49c7cf75124f96268c130b8c523c6bd4120a878 100644
|
| --- a/chrome/browser/chromeos/arc/arc_support_host.cc
|
| +++ b/chrome/browser/chromeos/arc/arc_support_host.cc
|
| @@ -74,6 +74,10 @@ std::unique_ptr<extensions::NativeMessageHost> ArcSupportHost::Create() {
|
| ArcSupportHost::ArcSupportHost() {
|
| arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
|
| DCHECK(arc_auth_service);
|
| +
|
| + if (!arc_auth_service->IsAllowed())
|
| + return;
|
| +
|
| arc_auth_service->AddObserver(this);
|
| display::Screen::GetScreen()->AddObserver(this);
|
|
|
| @@ -95,7 +99,11 @@ void ArcSupportHost::Start(Client* client) {
|
| DCHECK(!client_);
|
| client_ = client;
|
|
|
| - Initialize();
|
| + if (!Initialize()) {
|
| + OnOptInUIClose();
|
| + return;
|
| + }
|
| +
|
| SendMetricsMode();
|
|
|
| arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
|
| @@ -104,8 +112,12 @@ void ArcSupportHost::Start(Client* client) {
|
| arc_auth_service->ui_page_status());
|
| }
|
|
|
| -void ArcSupportHost::Initialize() {
|
| +bool ArcSupportHost::Initialize() {
|
| DCHECK(client_);
|
| + arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
|
| + if (!arc_auth_service->IsAllowed())
|
| + return false;
|
| +
|
| std::unique_ptr<base::DictionaryValue> loadtime_data(
|
| new base::DictionaryValue());
|
| base::string16 device_name = ash::GetChromeOSDeviceName();
|
| @@ -150,8 +162,6 @@ void ArcSupportHost::Initialize() {
|
| const std::string& country_code = base::CountryCodeForCurrentTimezone();
|
| loadtime_data->SetString("countryCode", country_code);
|
|
|
| - arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
|
| -
|
| loadtime_data->SetBoolean(kBackupRestoreEnabled,
|
| arc_auth_service->profile()->GetPrefs()->GetBoolean(
|
| prefs::kArcBackupRestoreEnabled));
|
| @@ -169,6 +179,8 @@ void ArcSupportHost::Initialize() {
|
| request.SetString(kDeviceId, device_id);
|
| base::JSONWriter::Write(request, &request_string);
|
| client_->PostMessageFromNativeHost(request_string);
|
| +
|
| + return true;
|
| }
|
|
|
| void ArcSupportHost::OnDisplayAdded(const display::Display& new_display) {}
|
| @@ -190,7 +202,7 @@ void ArcSupportHost::OnMetricsPreferenceChanged() {
|
|
|
| void ArcSupportHost::SendMetricsMode() {
|
| arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
|
| - DCHECK(arc_auth_service);
|
| + DCHECK(arc_auth_service && arc_auth_service->IsAllowed());
|
| const Profile* profile = arc_auth_service->profile();
|
|
|
| const bool metrics_managed = IsMetricsReportingPolicyManaged();
|
| @@ -249,7 +261,9 @@ void ArcSupportHost::EnableMetrics(bool is_enabled) {
|
| }
|
|
|
| void ArcSupportHost::EnableBackupRestore(bool is_enabled) {
|
| - PrefService* pref_service = arc::ArcAuthService::Get()->profile()->GetPrefs();
|
| + arc::ArcAuthService* arc_auth_service = arc::ArcAuthService::Get();
|
| + DCHECK(arc_auth_service && arc_auth_service->IsAllowed());
|
| + PrefService* pref_service = arc_auth_service->profile()->GetPrefs();
|
| pref_service->SetBoolean(prefs::kArcBackupRestoreEnabled, is_enabled);
|
| }
|
|
|
|
|