Chromium Code Reviews| 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..f0874c648649356c79d5102d1d457a0b72e9b102 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,50 @@ AutotestPrivateGetVisibleNotificationsFunction::Run() { |
| return RespondNow(OneArgument(std::move(values))); |
| } |
| +ExtensionFunction::ResponseAction |
| +AutotestPrivateGetPlayStoreStateFunction::Run() { |
| + DVLOG(1) << "AutotestPrivateGetPlayStoreStateFunction"; |
| + std::unique_ptr<base::DictionaryValue> play_store_state_value( |
| + new base::DictionaryValue); |
| + play_store_state_value->SetBoolean("enabled", false); |
| + play_store_state_value->SetBoolean("managed", false); |
| + play_store_state_value->SetBoolean("allowed", false); |
|
stevenjb
2017/04/13 00:23:47
nit: Maybe just set "allowed" to false? The other
khmel
2017/04/13 01:14:21
Makes sense
|
| +#if defined(OS_CHROMEOS) |
| + Profile* profile = ProfileManager::GetActiveUserProfile(); |
| + if (arc::IsArcAllowedForProfile(profile)) { |
| + play_store_state_value->SetBoolean( |
| + "enabled", arc::IsArcPlayStoreEnabledForProfile(profile)); |
| + play_store_state_value->SetBoolean( |
| + "managed", |
| + arc::IsArcPlayStoreEnabledPreferenceManagedForProfile(profile)); |
| + play_store_state_value->SetBoolean("allowed", true); |
| + } |
| +#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)) { |
| + 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; |