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

Unified Diff: chrome/browser/extensions/api/autotest_private/autotest_private_api.cc

Issue 2801173002: arc: Provide API to control Play Store state from autotests (Closed)
Patch Set: handle attempt to enabled policy disabled ARC, nits Created 3 years, 8 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/extensions/api/autotest_private/autotest_private_api.cc
diff --git a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
index c11364a72883c62385869d3117dca10f06623232..11da87a1148e133986125eb756bafee20e4fb194 100644
--- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
+++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
@@ -27,8 +27,10 @@
#include "extensions/common/permissions/permissions_data.h"
#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/login/lock/screen_locker.h"
#include "chrome/browser/chromeos/system/input_device_settings.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/session_manager_client.h"
#include "components/user_manager/user.h"
@@ -378,6 +380,46 @@ AutotestPrivateGetVisibleNotificationsFunction::Run() {
return RespondNow(OneArgument(std::move(values)));
}
+ExtensionFunction::ResponseAction
+AutotestPrivateIsPlayStoreEnabledFunction::Run() {
+ DVLOG(1) << "AutotestPrivateIsPlayStoreEnabledFunction";
+ bool enabled = false;
+#if defined(OS_CHROMEOS)
+ Profile* profile = ProfileManager::GetActiveUserProfile();
+ enabled = arc::IsArcPlayStoreEnabledForProfile(profile);
+#endif
+ return RespondNow(OneArgument(base::MakeUnique<base::Value>(enabled)));
+}
+
+ExtensionFunction::ResponseAction
+AutotestPrivateIsPlayStoreManagedFunction::Run() {
+ DVLOG(1) << "AutotestPrivateIsPlayStoreManagedFunction";
+ bool managed = false;
+#if defined(OS_CHROMEOS)
+ Profile* profile = ProfileManager::GetActiveUserProfile();
+ managed = arc::IsArcAllowedForProfile(profile) &&
+ arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile);
+#endif
+ return RespondNow(OneArgument(base::MakeUnique<base::Value>(managed)));
+}
+
+ExtensionFunction::ResponseAction
+AutotestPrivateSetPlayStoreEnabledFunction::Run() {
+ DVLOG(1) << "AutotestPrivateSetPlayStoreEnabledFunction";
+ std::unique_ptr<api::autotest_private::SetPlayStoreEnabled::Params> params(
+ api::autotest_private::SetPlayStoreEnabled::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
+ bool was_enabled = false;
+#if defined(OS_CHROMEOS)
+ Profile* profile = ProfileManager::GetActiveUserProfile();
+ if (arc::IsArcAllowedForProfile(profile)) {
+ arc::SetArcPlayStoreEnabledForProfile(profile, params->enabled);
+ was_enabled = arc::IsArcPlayStoreEnabledForProfile(profile);
+ }
+#endif
+ return RespondNow(OneArgument(base::MakeUnique<base::Value>(was_enabled)));
+}
+
static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>::
DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER;

Powered by Google App Engine
This is Rietveld 408576698