Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4543)

Unified Diff: chrome/browser/chromeos/arc/arc_auth_service.cc

Issue 1973603002: arc: Make Play Store item persistance in shelf. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase + policy_browsertest.cc Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 470e17e1c9bc5875872a59b86762ae03523a31c9..bfea838c3e9af0b06fcfda6c47d7f12efca42c8f 100644
--- a/chrome/browser/chromeos/arc/arc_auth_service.cc
+++ b/chrome/browser/chromeos/arc/arc_auth_service.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/browser_process_platform_part.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/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/extensions/extension_util.h"
@@ -28,6 +29,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"
@@ -60,10 +62,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;
@@ -128,6 +126,33 @@ void ArcAuthService::EnableCheckAndroidManagementForTesting() {
enable_check_android_management_for_testing = true;
}
+bool ArcAuthService::IsAllowedForProfile(const Profile* profile) {
+ if (!arc::ArcBridgeService::GetEnabled(
+ base::CommandLine::ForCurrentProcess())) {
+ VLOG(1) << "Arc is not enabled.";
+ return false;
+ }
+
+ user_manager::User const* const user =
+ chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
+ if (profile->IsLegacySupervised()) {
+ VLOG(1) << "Supervised users are not supported in ARC.";
+ return false;
+ }
+ if (!user->HasGaiaAccount()) {
+ VLOG(1) << "Users without GAIA accounts are not supported in ARC.";
+ return false;
+ }
+
+ if (user_manager::UserManager::Get()
+ ->IsCurrentUserCryptohomeDataEphemeral()) {
+ VLOG(2) << "Users with ephemeral data are not supported in Arc.";
+ return false;
+ }
+
+ return true;
+}
+
void ArcAuthService::OnAuthInstanceReady() {
arc_bridge_service()->auth_instance()->Init(
binding_.CreateInterfacePtrAndBind());
@@ -234,37 +259,28 @@ 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());
Shutdown();
- user_manager::User const* const user =
- chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
- if (profile->IsLegacySupervised()) {
- VLOG(1) << "Supervised users are not supported in ARC.";
- return;
- }
- if (!user->HasGaiaAccount()) {
- VLOG(1) << "Users without GAIA accounts are not supported in ARC.";
- return;
- }
-
- if (user_manager::UserManager::Get()
- ->IsCurrentUserCryptohomeDataEphemeral()) {
- VLOG(2) << "Users with ephemeral data are not supported in Arc.";
+ if (!IsAllowedForProfile(profile))
return;
- }
profile_ = profile;
PrefServiceSyncableFromProfile(profile_)->AddSyncedPrefObserver(
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_);
@@ -335,14 +351,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));
@@ -523,13 +541,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);
}
« no previous file with comments | « chrome/browser/chromeos/arc/arc_auth_service.h ('k') | chrome/browser/chromeos/arc/arc_auth_service_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698