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

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: nit 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 e50590e4ca262775a3b410c6363cb665ce1e3afe..33339988a7b0ddf00ec0a94a8a66d8077645e8ae 100644
--- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
+++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
@@ -28,8 +28,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"
@@ -380,6 +382,48 @@ AutotestPrivateGetVisibleNotificationsFunction::Run() {
return RespondNow(OneArgument(std::move(values)));
}
+ExtensionFunction::ResponseAction
+AutotestPrivateGetPlayStoreStateFunction::Run() {
+ DVLOG(1) << "AutotestPrivateGetPlayStoreStateFunction";
Devlin 2017/04/13 21:49:52 Do you need to keep these logs?
khmel 2017/04/13 23:02:51 Most of the functions here use similar structure:
+ std::unique_ptr<base::DictionaryValue> play_store_state_value =
+ base::MakeUnique<base::DictionaryValue>();
+ play_store_state_value->SetBoolean("allowed", false);
+#if defined(OS_CHROMEOS)
+ Profile* profile = ProfileManager::GetActiveUserProfile();
+ if (arc::IsArcAllowedForProfile(profile)) {
+ play_store_state_value->SetBoolean("allowed", true);
Devlin 2017/04/13 21:49:52 Please use the generated types rather than using a
khmel 2017/04/13 23:02:51 Done.
+ play_store_state_value->SetBoolean(
+ "enabled", arc::IsArcPlayStoreEnabledForProfile(profile));
+ play_store_state_value->SetBoolean(
+ "managed",
+ arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile));
+ }
+#endif
+ return RespondNow(OneArgument(std::move(play_store_state_value)));
+}
+
+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());
+#if defined(OS_CHROMEOS)
+ Profile* profile = ProfileManager::GetActiveUserProfile();
+ if (arc::IsArcAllowedForProfile(profile)) {
+ arc::SetArcPlayStoreEnabledForProfile(profile, params->enabled);
+ if (params->enabled != arc::IsArcPlayStoreEnabledForProfile(profile)) {
Devlin 2017/04/13 21:49:52 This would be cleaner if we just had SetArcPlaySto
khmel 2017/04/13 23:02:51 You mean static boolean SetArcPlayStoreEnabledForP
Devlin 2017/04/13 23:06:00 Ah, sorry, I can see how that would be confusing.
khmel 2017/04/13 23:16:01 Got you :), done.
+ return RespondNow(
+ Error("ARC enabled state cannot be changed for the current user"));
+ }
+ return RespondNow(NoArguments());
+ } else {
+ return RespondNow(Error("ARC is not available for the current user"));
+ }
+#endif
+ return RespondNow(Error("ARC is not available for the current platform"));
+}
+
static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI>>::
DestructorAtExit g_factory = LAZY_INSTANCE_INITIALIZER;

Powered by Google App Engine
This is Rietveld 408576698