| 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 e5a85eb14cfc99f2cbc1f50eeb0a10e58b6ca0f8..27e1777497183e29a26f9a43a31fc367169001da 100644
|
| --- a/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
|
| +++ b/chrome/browser/extensions/api/autotest_private/autotest_private_api.cc
|
| @@ -66,39 +66,39 @@ base::ListValue* GetAPIPermissions(const Extension* ext) {
|
| return permissions;
|
| }
|
|
|
| -bool IsTestMode(Profile* profile) {
|
| - return AutotestPrivateAPI::GetFactoryInstance()->Get(profile)->test_mode();
|
| +bool IsTestMode(content::BrowserContext* context) {
|
| + return AutotestPrivateAPI::GetFactoryInstance()->Get(context)->test_mode();
|
| }
|
|
|
| } // namespace
|
|
|
| -bool AutotestPrivateLogoutFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction AutotestPrivateLogoutFunction::Run() {
|
| DVLOG(1) << "AutotestPrivateLogoutFunction";
|
| - if (!IsTestMode(GetProfile()))
|
| + if (!IsTestMode(browser_context()))
|
| chrome::AttemptUserExit();
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateRestartFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction AutotestPrivateRestartFunction::Run() {
|
| DVLOG(1) << "AutotestPrivateRestartFunction";
|
| - if (!IsTestMode(GetProfile()))
|
| + if (!IsTestMode(browser_context()))
|
| chrome::AttemptRestart();
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateShutdownFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction AutotestPrivateShutdownFunction::Run() {
|
| std::unique_ptr<api::autotest_private::Shutdown::Params> params(
|
| api::autotest_private::Shutdown::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
|
|
| DVLOG(1) << "AutotestPrivateShutdownFunction " << params->force;
|
|
|
| - if (!IsTestMode(GetProfile()))
|
| + if (!IsTestMode(browser_context()))
|
| chrome::AttemptExit();
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateLoginStatusFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction AutotestPrivateLoginStatusFunction::Run() {
|
| DVLOG(1) << "AutotestPrivateLoginStatusFunction";
|
|
|
| std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
|
| @@ -141,29 +141,29 @@ bool AutotestPrivateLoginStatusFunction::RunSync() {
|
| }
|
| #endif
|
|
|
| - SetResult(std::move(result));
|
| - return true;
|
| + return RespondNow(OneArgument(std::move(result)));
|
| }
|
|
|
| -bool AutotestPrivateLockScreenFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction AutotestPrivateLockScreenFunction::Run() {
|
| DVLOG(1) << "AutotestPrivateLockScreenFunction";
|
| #if defined(OS_CHROMEOS)
|
| chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
|
| RequestLockScreen();
|
| #endif
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateGetExtensionsInfoFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction
|
| +AutotestPrivateGetExtensionsInfoFunction::Run() {
|
| DVLOG(1) << "AutotestPrivateGetExtensionsInfoFunction";
|
|
|
| ExtensionService* service =
|
| - ExtensionSystem::Get(GetProfile())->extension_service();
|
| - ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile());
|
| + ExtensionSystem::Get(browser_context())->extension_service();
|
| + ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context());
|
| const ExtensionSet& extensions = registry->enabled_extensions();
|
| const ExtensionSet& disabled_extensions = registry->disabled_extensions();
|
| ExtensionActionManager* extension_action_manager =
|
| - ExtensionActionManager::Get(GetProfile());
|
| + ExtensionActionManager::Get(browser_context());
|
|
|
| base::ListValue* extensions_values = new base::ListValue;
|
| ExtensionList all;
|
| @@ -200,8 +200,8 @@ bool AutotestPrivateGetExtensionsInfoFunction::RunSync() {
|
| location == Manifest::INTERNAL ||
|
| Manifest::IsUnpackedLocation(location));
|
| extension_value->SetBoolean("isEnabled", service->IsExtensionEnabled(id));
|
| - extension_value->SetBoolean("allowedInIncognito",
|
| - util::IsIncognitoEnabled(id, GetProfile()));
|
| + extension_value->SetBoolean(
|
| + "allowedInIncognito", util::IsIncognitoEnabled(id, browser_context()));
|
| extension_value->SetBoolean(
|
| "hasPageAction",
|
| extension_action_manager->GetPageAction(*extension) != NULL);
|
| @@ -212,17 +212,17 @@ bool AutotestPrivateGetExtensionsInfoFunction::RunSync() {
|
| std::unique_ptr<base::DictionaryValue> return_value(
|
| new base::DictionaryValue);
|
| return_value->Set("extensions", extensions_values);
|
| - SetResult(std::move(return_value));
|
| - return true;
|
| + return RespondNow(OneArgument(std::move(return_value)));
|
| }
|
|
|
| static int AccessArray(const volatile int arr[], const volatile int *index) {
|
| return arr[*index];
|
| }
|
|
|
| -bool AutotestPrivateSimulateAsanMemoryBugFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction
|
| +AutotestPrivateSimulateAsanMemoryBugFunction::Run() {
|
| DVLOG(1) << "AutotestPrivateSimulateAsanMemoryBugFunction";
|
| - if (!IsTestMode(GetProfile())) {
|
| + if (!IsTestMode(browser_context())) {
|
| // This array is volatile not to let compiler optimize us out.
|
| volatile int testarray[3] = {0, 0, 0};
|
|
|
| @@ -230,10 +230,11 @@ bool AutotestPrivateSimulateAsanMemoryBugFunction::RunSync() {
|
| volatile int index = 5;
|
| AccessArray(testarray, &index);
|
| }
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateSetTouchpadSensitivityFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction
|
| +AutotestPrivateSetTouchpadSensitivityFunction::Run() {
|
| std::unique_ptr<api::autotest_private::SetTouchpadSensitivity::Params> params(
|
| api::autotest_private::SetTouchpadSensitivity::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| @@ -244,10 +245,10 @@ bool AutotestPrivateSetTouchpadSensitivityFunction::RunSync() {
|
| chromeos::system::InputDeviceSettings::Get()->SetTouchpadSensitivity(
|
| params->value);
|
| #endif
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateSetTapToClickFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction AutotestPrivateSetTapToClickFunction::Run() {
|
| std::unique_ptr<api::autotest_private::SetTapToClick::Params> params(
|
| api::autotest_private::SetTapToClick::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| @@ -257,10 +258,11 @@ bool AutotestPrivateSetTapToClickFunction::RunSync() {
|
| #if defined(OS_CHROMEOS)
|
| chromeos::system::InputDeviceSettings::Get()->SetTapToClick(params->enabled);
|
| #endif
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateSetThreeFingerClickFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction
|
| +AutotestPrivateSetThreeFingerClickFunction::Run() {
|
| std::unique_ptr<api::autotest_private::SetThreeFingerClick::Params> params(
|
| api::autotest_private::SetThreeFingerClick::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| @@ -271,10 +273,10 @@ bool AutotestPrivateSetThreeFingerClickFunction::RunSync() {
|
| chromeos::system::InputDeviceSettings::Get()->SetThreeFingerClick(
|
| params->enabled);
|
| #endif
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateSetTapDraggingFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction AutotestPrivateSetTapDraggingFunction::Run() {
|
| std::unique_ptr<api::autotest_private::SetTapDragging::Params> params(
|
| api::autotest_private::SetTapDragging::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| @@ -284,10 +286,11 @@ bool AutotestPrivateSetTapDraggingFunction::RunSync() {
|
| #if defined(OS_CHROMEOS)
|
| chromeos::system::InputDeviceSettings::Get()->SetTapDragging(params->enabled);
|
| #endif
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateSetNaturalScrollFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction
|
| +AutotestPrivateSetNaturalScrollFunction::Run() {
|
| std::unique_ptr<api::autotest_private::SetNaturalScroll::Params> params(
|
| api::autotest_private::SetNaturalScroll::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| @@ -298,10 +301,11 @@ bool AutotestPrivateSetNaturalScrollFunction::RunSync() {
|
| chromeos::system::InputDeviceSettings::Get()->SetNaturalScroll(
|
| params->enabled);
|
| #endif
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateSetMouseSensitivityFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction
|
| +AutotestPrivateSetMouseSensitivityFunction::Run() {
|
| std::unique_ptr<api::autotest_private::SetMouseSensitivity::Params> params(
|
| api::autotest_private::SetMouseSensitivity::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| @@ -312,10 +316,11 @@ bool AutotestPrivateSetMouseSensitivityFunction::RunSync() {
|
| chromeos::system::InputDeviceSettings::Get()->SetMouseSensitivity(
|
| params->value);
|
| #endif
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| -bool AutotestPrivateSetPrimaryButtonRightFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction
|
| +AutotestPrivateSetPrimaryButtonRightFunction::Run() {
|
| std::unique_ptr<api::autotest_private::SetPrimaryButtonRight::Params> params(
|
| api::autotest_private::SetPrimaryButtonRight::Params::Create(*args_));
|
| EXTENSION_FUNCTION_VALIDATE(params.get());
|
| @@ -326,7 +331,7 @@ bool AutotestPrivateSetPrimaryButtonRightFunction::RunSync() {
|
| chromeos::system::InputDeviceSettings::Get()->SetPrimaryButtonRight(
|
| params->right);
|
| #endif
|
| - return true;
|
| + return RespondNow(NoArguments());
|
| }
|
|
|
| // static
|
| @@ -351,7 +356,8 @@ std::string AutotestPrivateGetVisibleNotificationsFunction::ConvertToString(
|
| return "unknown";
|
| }
|
|
|
| -bool AutotestPrivateGetVisibleNotificationsFunction::RunSync() {
|
| +ExtensionFunction::ResponseAction
|
| +AutotestPrivateGetVisibleNotificationsFunction::Run() {
|
| DVLOG(1) << "AutotestPrivateGetVisibleNotificationsFunction";
|
| std::unique_ptr<base::ListValue> values(new base::ListValue);
|
| #if defined(OS_CHROMEOS)
|
| @@ -368,8 +374,7 @@ bool AutotestPrivateGetVisibleNotificationsFunction::RunSync() {
|
| }
|
|
|
| #endif
|
| - SetResult(std::move(values));
|
| - return true;
|
| + return RespondNow(OneArgument(std::move(values)));
|
| }
|
|
|
| static base::LazyInstance<BrowserContextKeyedAPIFactory<AutotestPrivateAPI> >
|
|
|