Index: chrome/browser/chromeos/arc/arc_auth_service.cc |
diff --git a/chrome/browser/chromeos/arc/arc_auth_service.cc b/chrome/browser/chromeos/arc/arc_auth_service.cc |
index fcd685244d92f3119a651577f78dc88970dc5ec9..930fdb1e9b674e7f6bf803bc4f9ec20111fac205 100644 |
--- a/chrome/browser/chromeos/arc/arc_auth_service.cc |
+++ b/chrome/browser/chromeos/arc/arc_auth_service.cc |
@@ -15,6 +15,7 @@ |
#include "base/threading/thread_checker.h" |
#include "chrome/browser/chromeos/arc/arc_auth_notification.h" |
#include "chrome/browser/chromeos/arc/arc_optin_uma.h" |
+#include "chrome/browser/chromeos/arc/arc_support_host.h" |
#include "chrome/browser/chromeos/profiles/profile_helper.h" |
#include "chrome/browser/extensions/extension_util.h" |
#include "chrome/browser/policy/profile_policy_connector.h" |
@@ -24,6 +25,7 @@ |
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
#include "chrome/browser/signin/signin_manager_factory.h" |
#include "chrome/browser/ui/app_list/arc/arc_app_launcher.h" |
+#include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
#include "chrome/browser/ui/extensions/app_launch_params.h" |
#include "chrome/browser/ui/extensions/application_launch.h" |
#include "chrome/common/pref_names.h" |
@@ -54,10 +56,6 @@ ArcAuthService* arc_auth_service = nullptr; |
base::LazyInstance<base::ThreadChecker> thread_checker = |
LAZY_INSTANCE_INITIALIZER; |
-const char kPlayStoreAppId[] = "gpkmicpkkebkmabiaedjognfppcchdfa"; |
-const char kArcSupportExtensionId[] = "cnbgggchhmkkdmeppjobngjoejnihlei"; |
-const char kArcSupportStorageId[] = "arc_support"; |
- |
// Skip creating UI in unit tests |
bool disable_ui_for_testing = false; |
@@ -217,6 +215,11 @@ void ArcAuthService::SetState(State state) { |
FOR_EACH_OBSERVER(Observer, observer_list_, OnOptInChanged(state_)); |
} |
+bool ArcAuthService::IsAllowed() const { |
+ DCHECK(thread_checker.Get().CalledOnValidThread()); |
+ return profile_ != nullptr; |
+} |
+ |
void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) { |
DCHECK(profile && profile != profile_); |
DCHECK(thread_checker.Get().CalledOnValidThread()); |
@@ -245,9 +248,9 @@ void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) { |
prefs::kArcEnabled, this); |
// Reuse storage used in ARC OptIn platform app. |
- const std::string site_url = |
- base::StringPrintf("%s://%s/persist?%s", content::kGuestScheme, |
- kArcSupportExtensionId, kArcSupportStorageId); |
+ const std::string site_url = base::StringPrintf( |
+ "%s://%s/persist?%s", content::kGuestScheme, ArcSupportHost::kHostAppId, |
+ ArcSupportHost::kStorageId); |
storage_partition_ = content::BrowserContext::GetStoragePartitionForSite( |
profile_, GURL(site_url)); |
CHECK(storage_partition_); |
@@ -309,14 +312,16 @@ void ArcAuthService::ShowUI(UIPage page, const base::string16& status) { |
const extensions::AppWindowRegistry* const app_window_registry = |
extensions::AppWindowRegistry::Get(profile_); |
DCHECK(app_window_registry); |
- if (app_window_registry->GetCurrentAppWindowForApp(kArcSupportExtensionId)) |
+ if (app_window_registry->GetCurrentAppWindowForApp( |
+ ArcSupportHost::kHostAppId)) { |
return; |
+ } |
const extensions::Extension* extension = |
extensions::ExtensionRegistry::Get(profile_)->GetInstalledExtension( |
- kArcSupportExtensionId); |
- CHECK(extension && |
- extensions::util::IsAppLaunchable(kArcSupportExtensionId, profile_)); |
+ ArcSupportHost::kHostAppId); |
+ CHECK(extension && extensions::util::IsAppLaunchable( |
+ ArcSupportHost::kHostAppId, profile_)); |
OpenApplication(CreateAppLaunchParamsUserContainer( |
profile_, extension, NEW_WINDOW, extensions::SOURCE_CHROME_INTERNAL)); |
@@ -489,13 +494,21 @@ void ArcAuthService::CancelAuthCode() { |
DisableArc(); |
} |
+bool ArcAuthService::IsArcEnabled() { |
+ DCHECK(thread_checker.Get().CalledOnValidThread()); |
+ DCHECK(profile_); |
+ return profile_->GetPrefs()->GetBoolean(prefs::kArcEnabled); |
+} |
+ |
void ArcAuthService::EnableArc() { |
DCHECK(thread_checker.Get().CalledOnValidThread()); |
+ DCHECK(profile_); |
profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, true); |
} |
void ArcAuthService::DisableArc() { |
DCHECK(thread_checker.Get().CalledOnValidThread()); |
+ DCHECK(profile_); |
profile_->GetPrefs()->SetBoolean(prefs::kArcEnabled, false); |
} |