Commit 027f954c authored by Randy Rossi's avatar Randy Rossi Committed by Commit Bot

Begin moving automation api into //extensions

Moving automation manifest handler into //extensions. Other
automation bits & pieces to follow in subsequent CLs.

Bug: 822747, b/74537394
Test: Tested install of ChromeVox on ChromiumOs and Google branded Chrome build
Change-Id: I18d828f76c17cb120e7cc9ed8022f107f3f3a2ea
Reviewed-on: https://chromium-review.googlesource.com/964732
Commit-Queue: Randy Rossi <rmrossi@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545067}
parent a8b44439
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "chrome/common/extensions/api/automation_api_constants.h" #include "chrome/common/extensions/api/automation_api_constants.h"
#include "chrome/common/extensions/api/automation_internal.h" #include "chrome/common/extensions/api/automation_internal.h"
#include "chrome/common/extensions/chrome_extension_messages.h" #include "chrome/common/extensions/chrome_extension_messages.h"
#include "chrome/common/extensions/manifest_handlers/automation.h"
#include "content/public/browser/ax_event_notification_details.h" #include "content/public/browser/ax_event_notification_details.h"
#include "content/public/browser/browser_accessibility_state.h" #include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
...@@ -36,6 +35,7 @@ ...@@ -36,6 +35,7 @@
#include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h" #include "content/public/browser/web_contents_user_data.h"
#include "extensions/common/extension_messages.h" #include "extensions/common/extension_messages.h"
#include "extensions/common/manifest_handlers/automation.h"
#include "extensions/common/permissions/permissions_data.h" #include "extensions/common/permissions/permissions_data.h"
#include "ui/accessibility/ax_action_data.h" #include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enum_util.h" #include "ui/accessibility/ax_enum_util.h"
......
...@@ -339,8 +339,6 @@ static_library("common") { ...@@ -339,8 +339,6 @@ static_library("common") {
"extensions/manifest_handlers/app_launch_info.h", "extensions/manifest_handlers/app_launch_info.h",
"extensions/manifest_handlers/app_theme_color_info.cc", "extensions/manifest_handlers/app_theme_color_info.cc",
"extensions/manifest_handlers/app_theme_color_info.h", "extensions/manifest_handlers/app_theme_color_info.h",
"extensions/manifest_handlers/automation.cc",
"extensions/manifest_handlers/automation.h",
"extensions/manifest_handlers/extension_action_handler.cc", "extensions/manifest_handlers/extension_action_handler.cc",
"extensions/manifest_handlers/extension_action_handler.h", "extensions/manifest_handlers/extension_action_handler.h",
"extensions/manifest_handlers/linked_app_icons.cc", "extensions/manifest_handlers/linked_app_icons.cc",
......
...@@ -129,34 +129,6 @@ ...@@ -129,34 +129,6 @@
} }
} }
}, },
{
"id": "automation",
"description": "This API provides programmatic access to the user interface elements of Chrome. This includes everything in the web view, and optionally Chrome's full user interface.",
"choices": [
{ "type": "boolean",
"description": "If true, enables non-interactive access to the automation tree only for the sites for which the extension has a <a href='https://developer.chrome.com/extensions/declare_permissions#host-permissions'>host permission</a> or <a href='https://developer.chrome.com/extensions/declare_permissions#activeTab'>activeTab permission</a>)." },
{ "type": "object",
"properties": {
"desktop": {
"description": "Whether to request permission to the whole ChromeOS desktop. If granted, this gives the extension access to every aspect of the desktop, and every site and app. If this permission is requested, all other permissions are implicitly included and do not need to be requested separately.",
"optional": true,
"type": "boolean"
},
"matches": {
"description": "A list of URL patterns for which this extension may request an automation tree. If not specified, automation permission will be granted for the sites for which the extension has a <a href='https://developer.chrome.com/extensions/declare_permissions#host-permissions'>host permission</a> or <a href='https://developer.chrome.com/extensions/declare_permissions#activeTab'>activeTab permission</a>).",
"optional": true,
"type": "array",
"items": { "type": "string" }
},
"interact": {
"description": "Whether the extension is allowed interactive access (true) or read-only access (false; default) to the automation tree.",
"optional": true,
"type": "boolean"
}
}
}
]
},
{ {
"id": "FileSystemProviderSource", "id": "FileSystemProviderSource",
"type": "string", "type": "string",
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "chrome/common/extensions/manifest_handlers/app_icon_color_info.h" #include "chrome/common/extensions/manifest_handlers/app_icon_color_info.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h" #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/extensions/manifest_handlers/app_theme_color_info.h" #include "chrome/common/extensions/manifest_handlers/app_theme_color_info.h"
#include "chrome/common/extensions/manifest_handlers/automation.h"
#include "chrome/common/extensions/manifest_handlers/extension_action_handler.h" #include "chrome/common/extensions/manifest_handlers/extension_action_handler.h"
#include "chrome/common/extensions/manifest_handlers/linked_app_icons.h" #include "chrome/common/extensions/manifest_handlers/linked_app_icons.h"
#include "chrome/common/extensions/manifest_handlers/minimum_chrome_version_checker.h" #include "chrome/common/extensions/manifest_handlers/minimum_chrome_version_checker.h"
...@@ -24,6 +23,7 @@ ...@@ -24,6 +23,7 @@
#include "chrome/common/extensions/manifest_handlers/theme_handler.h" #include "chrome/common/extensions/manifest_handlers/theme_handler.h"
#include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h" #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
#include "extensions/common/manifest_handlers/app_isolation_info.h" #include "extensions/common/manifest_handlers/app_isolation_info.h"
#include "extensions/common/manifest_handlers/automation.h"
#include "extensions/common/manifest_handlers/content_scripts_handler.h" #include "extensions/common/manifest_handlers/content_scripts_handler.h"
#include "extensions/common/manifest_handlers/options_page_info.h" #include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/manifest_url_handlers.h" #include "extensions/common/manifest_url_handlers.h"
......
...@@ -2,13 +2,13 @@ ...@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/common/extensions/manifest_handlers/automation.h"
#include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/version_info/version_info.h" #include "components/version_info/version_info.h"
#include "extensions/common/error_utils.h" #include "extensions/common/error_utils.h"
#include "extensions/common/features/feature_channel.h" #include "extensions/common/features/feature_channel.h"
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/automation.h"
#include "extensions/common/permissions/permission_message_test_util.h" #include "extensions/common/permissions/permission_message_test_util.h"
#include "extensions/common/permissions/permissions_data.h" #include "extensions/common/permissions/permissions_data.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
......
...@@ -15,12 +15,12 @@ ...@@ -15,12 +15,12 @@
#include "base/values.h" #include "base/values.h"
#include "chrome/common/extensions/api/automation_api_constants.h" #include "chrome/common/extensions/api/automation_api_constants.h"
#include "chrome/common/extensions/chrome_extension_messages.h" #include "chrome/common/extensions/chrome_extension_messages.h"
#include "chrome/common/extensions/manifest_handlers/automation.h"
#include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_thread.h" #include "content/public/renderer/render_thread.h"
#include "content/public/renderer/render_view.h" #include "content/public/renderer/render_view.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "extensions/common/manifest.h" #include "extensions/common/manifest.h"
#include "extensions/common/manifest_handlers/automation.h"
#include "extensions/common/manifest_handlers/background_info.h" #include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/renderer/extension_bindings_system.h" #include "extensions/renderer/extension_bindings_system.h"
#include "extensions/renderer/script_context.h" #include "extensions/renderer/script_context.h"
......
...@@ -179,6 +179,8 @@ if (enable_extensions) { ...@@ -179,6 +179,8 @@ if (enable_extensions) {
"manifest_handler_helpers.h", "manifest_handler_helpers.h",
"manifest_handlers/app_isolation_info.cc", "manifest_handlers/app_isolation_info.cc",
"manifest_handlers/app_isolation_info.h", "manifest_handlers/app_isolation_info.h",
"manifest_handlers/automation.cc",
"manifest_handlers/automation.h",
"manifest_handlers/background_info.cc", "manifest_handlers/background_info.cc",
"manifest_handlers/background_info.h", "manifest_handlers/background_info.h",
"manifest_handlers/content_capabilities_handler.cc", "manifest_handlers/content_capabilities_handler.cc",
......
...@@ -10,6 +10,34 @@ ...@@ -10,6 +10,34 @@
"description": "Schemas for structured manifest entries", "description": "Schemas for structured manifest entries",
"compiler_options": { "generate_error_messages": true }, "compiler_options": { "generate_error_messages": true },
"types": [ "types": [
{
"id": "automation",
"description": "This API provides programmatic access to the user interface elements of Chrome. This includes everything in the web view, and optionally Chrome's full user interface.",
"choices": [
{ "type": "boolean",
"description": "If true, enables non-interactive access to the automation tree only for the sites for which the extension has a <a href='https://developer.chrome.com/extensions/declare_permissions#host-permissions'>host permission</a> or <a href='https://developer.chrome.com/extensions/declare_permissions#activeTab'>activeTab permission</a>)." },
{ "type": "object",
"properties": {
"desktop": {
"description": "Whether to request permission to the whole ChromeOS desktop. If granted, this gives the extension access to every aspect of the desktop, and every site and app. If this permission is requested, all other permissions are implicitly included and do not need to be requested separately.",
"optional": true,
"type": "boolean"
},
"matches": {
"description": "A list of URL patterns for which this extension may request an automation tree. If not specified, automation permission will be granted for the sites for which the extension has a <a href='https://developer.chrome.com/extensions/declare_permissions#host-permissions'>host permission</a> or <a href='https://developer.chrome.com/extensions/declare_permissions#activeTab'>activeTab permission</a>).",
"optional": true,
"type": "array",
"items": { "type": "string" }
},
"interact": {
"description": "Whether the extension is allowed interactive access (true) or read-only access (false; default) to the automation tree.",
"optional": true,
"type": "boolean"
}
}
}
]
},
{ {
"id": "ContentCapabilities", "id": "ContentCapabilities",
"type": "object", "type": "object",
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/common/extensions/manifest_handlers/automation.h" #include "extensions/common/manifest_handlers/automation.h"
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/common/extensions/api/manifest_types.h" #include "extensions/common/api/extensions_manifest_types.h"
#include "extensions/common/error_utils.h" #include "extensions/common/error_utils.h"
#include "extensions/common/extensions_client.h" #include "extensions/common/extensions_client.h"
#include "extensions/common/manifest_constants.h" #include "extensions/common/manifest_constants.h"
...@@ -32,11 +32,11 @@ const char kErrorDesktopTrueMatchesSpecified[] = ...@@ -32,11 +32,11 @@ const char kErrorDesktopTrueMatchesSpecified[] =
"matches will be ignored."; "matches will be ignored.";
const char kErrorInvalidMatch[] = "Invalid match pattern '*': *"; const char kErrorInvalidMatch[] = "Invalid match pattern '*': *";
const char kErrorNoMatchesProvided[] = "No valid match patterns provided."; const char kErrorNoMatchesProvided[] = "No valid match patterns provided.";
} } // namespace automation_errors
namespace errors = manifest_errors; namespace errors = manifest_errors;
namespace keys = extensions::manifest_keys; namespace keys = extensions::manifest_keys;
using api::manifest_types::Automation; using api::extensions_manifest_types::Automation;
class AutomationManifestPermission : public ManifestPermission { class AutomationManifestPermission : public ManifestPermission {
public: public:
...@@ -102,9 +102,9 @@ PermissionIDSet AutomationManifestPermission::GetPermissions() const { ...@@ -102,9 +102,9 @@ PermissionIDSet AutomationManifestPermission::GetPermissions() const {
bool AutomationManifestPermission::FromValue(const base::Value* value) { bool AutomationManifestPermission::FromValue(const base::Value* value) {
base::string16 error; base::string16 error;
automation_info_.reset(AutomationInfo::FromValue(*value, automation_info_.reset(
NULL /* install_warnings */, AutomationInfo::FromValue(*value, NULL /* install_warnings */, &error)
&error).release()); .release());
return error.empty(); return error.empty();
} }
...@@ -154,11 +154,9 @@ ManifestPermission* AutomationManifestPermission::Intersect( ...@@ -154,11 +154,9 @@ ManifestPermission* AutomationManifestPermission::Intersect(
base::WrapUnique(new const AutomationInfo(desktop, matches, interact))); base::WrapUnique(new const AutomationInfo(desktop, matches, interact)));
} }
AutomationHandler::AutomationHandler() { AutomationHandler::AutomationHandler() {}
}
AutomationHandler::~AutomationHandler() { AutomationHandler::~AutomationHandler() {}
}
bool AutomationHandler::Parse(Extension* extension, base::string16* error) { bool AutomationHandler::Parse(Extension* extension, base::string16* error) {
const base::Value* automation = NULL; const base::Value* automation = NULL;
...@@ -211,12 +209,12 @@ std::unique_ptr<AutomationInfo> AutomationInfo::FromValue( ...@@ -211,12 +209,12 @@ std::unique_ptr<AutomationInfo> AutomationInfo::FromValue(
base::string16* error) { base::string16* error) {
std::unique_ptr<Automation> automation = Automation::FromValue(value, error); std::unique_ptr<Automation> automation = Automation::FromValue(value, error);
if (!automation) if (!automation)
return std::unique_ptr<AutomationInfo>(); return nullptr;
if (automation->as_boolean) { if (automation->as_boolean) {
if (*automation->as_boolean) if (*automation->as_boolean)
return base::WrapUnique(new AutomationInfo()); return base::WrapUnique(new AutomationInfo());
return std::unique_ptr<AutomationInfo>(); return nullptr;
} }
const Automation::Object& automation_object = *automation->as_object; const Automation::Object& automation_object = *automation->as_object;
...@@ -245,8 +243,7 @@ std::unique_ptr<AutomationInfo> AutomationInfo::FromValue( ...@@ -245,8 +243,7 @@ std::unique_ptr<AutomationInfo> AutomationInfo::FromValue(
for (std::vector<std::string>::iterator it = for (std::vector<std::string>::iterator it =
automation_object.matches->begin(); automation_object.matches->begin();
it != automation_object.matches->end(); it != automation_object.matches->end(); ++it) {
++it) {
// TODO(aboxhall): Refactor common logic from content_scripts_handler, // TODO(aboxhall): Refactor common logic from content_scripts_handler,
// manifest_url_handler and user_script.cc into a single location and // manifest_url_handler and user_script.cc into a single location and
// re-use here. // re-use here.
...@@ -257,8 +254,7 @@ std::unique_ptr<AutomationInfo> AutomationInfo::FromValue( ...@@ -257,8 +254,7 @@ std::unique_ptr<AutomationInfo> AutomationInfo::FromValue(
if (parse_result != URLPattern::PARSE_SUCCESS) { if (parse_result != URLPattern::PARSE_SUCCESS) {
install_warnings->push_back( install_warnings->push_back(
InstallWarning(ErrorUtils::FormatErrorMessage( InstallWarning(ErrorUtils::FormatErrorMessage(
automation_errors::kErrorInvalidMatch, automation_errors::kErrorInvalidMatch, *it,
*it,
URLPattern::GetParseResultString(parse_result)))); URLPattern::GetParseResultString(parse_result))));
continue; continue;
} }
...@@ -299,15 +295,13 @@ std::unique_ptr<Automation> AutomationInfo::AsManifestType( ...@@ -299,15 +295,13 @@ std::unique_ptr<Automation> AutomationInfo::AsManifestType(
return automation; return automation;
} }
AutomationInfo::AutomationInfo() : desktop(false), interact(false) { AutomationInfo::AutomationInfo() : desktop(false), interact(false) {}
}
AutomationInfo::AutomationInfo(bool desktop, AutomationInfo::AutomationInfo(bool desktop,
const URLPatternSet& matches, const URLPatternSet& matches,
bool interact) bool interact)
: desktop(desktop), matches(matches), interact(interact) {} : desktop(desktop), matches(matches), interact(interact) {}
AutomationInfo::~AutomationInfo() { AutomationInfo::~AutomationInfo() {}
}
} // namespace extensions } // namespace extensions
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ #ifndef EXTENSIONS_COMMON_MANIFEST_HANDLERS_AUTOMATION_H_
#define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ #define EXTENSIONS_COMMON_MANIFEST_HANDLERS_AUTOMATION_H_
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
namespace extensions { namespace extensions {
namespace api { namespace api {
namespace manifest_types { namespace extensions_manifest_types {
struct Automation; struct Automation;
} }
} } // namespace api
class URLPatternSet; class URLPatternSet;
class AutomationManifestPermission; class AutomationManifestPermission;
...@@ -32,7 +32,7 @@ extern const char kErrorDesktopTrueMatchesSpecified[]; ...@@ -32,7 +32,7 @@ extern const char kErrorDesktopTrueMatchesSpecified[];
extern const char kErrorURLMalformed[]; extern const char kErrorURLMalformed[];
extern const char kErrorInvalidMatch[]; extern const char kErrorInvalidMatch[];
extern const char kErrorNoMatchesProvided[]; extern const char kErrorNoMatchesProvided[];
} } // namespace automation_errors
// The parsed form of the automation manifest entry. // The parsed form of the automation manifest entry.
struct AutomationInfo : public Extension::ManifestData { struct AutomationInfo : public Extension::ManifestData {
...@@ -61,8 +61,8 @@ struct AutomationInfo : public Extension::ManifestData { ...@@ -61,8 +61,8 @@ struct AutomationInfo : public Extension::ManifestData {
AutomationInfo(); AutomationInfo();
AutomationInfo(bool desktop, const URLPatternSet& matches, bool interact); AutomationInfo(bool desktop, const URLPatternSet& matches, bool interact);
static std::unique_ptr<api::manifest_types::Automation> AsManifestType( static std::unique_ptr<api::extensions_manifest_types::Automation>
const AutomationInfo& info); AsManifestType(const AutomationInfo& info);
DISALLOW_COPY_AND_ASSIGN(AutomationInfo); DISALLOW_COPY_AND_ASSIGN(AutomationInfo);
friend class AutomationManifestPermission; friend class AutomationManifestPermission;
...@@ -89,4 +89,4 @@ class AutomationHandler : public ManifestHandler { ...@@ -89,4 +89,4 @@ class AutomationHandler : public ManifestHandler {
} // namespace extensions } // namespace extensions
#endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_AUTOMATION_H_ #endif // EXTENSIONS_COMMON_MANIFEST_HANDLERS_AUTOMATION_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment