summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/extensions/api/chrome_extensions_api_client.cc9
-rw-r--r--chrome/browser/extensions/api/chrome_extensions_api_client.h4
-rw-r--r--chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc32
-rw-r--r--chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h1
-rw-r--r--chrome/chrome_renderer.gypi3
-rw-r--r--chrome/common/extensions/api/_api_features.json34
-rw-r--r--chrome/common/extensions/api/_permission_features.json14
-rw-r--r--chrome/common/extensions/chrome_extensions_client.cc4
-rw-r--r--chrome/common/extensions/permissions/chrome_api_permissions.cc6
-rw-r--r--chrome/common/extensions_api_resources.grd1
-rw-r--r--chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc2
-rw-r--r--chrome/renderer/resources/extensions/chrome_web_view.js91
-rw-r--r--chrome/renderer/resources/renderer_resources.grd1
-rw-r--r--extensions/browser/api/declarative/declarative_api.cc5
-rw-r--r--extensions/browser/api/declarative/rules_registry_service.cc6
-rw-r--r--extensions/browser/api/extensions_api_client.cc7
-rw-r--r--extensions/browser/api/extensions_api_client.h7
-rw-r--r--extensions/browser/guest_view/web_view/web_view_guest.cc25
-rw-r--r--extensions/browser/guest_view/web_view/web_view_guest_delegate.h3
-rw-r--r--extensions/common/BUILD.gn1
-rw-r--r--extensions/common/api/_api_features.json34
-rw-r--r--extensions/common/api/_permission_features.json18
-rw-r--r--extensions/common/api/web_view_request.json (renamed from chrome/common/extensions/api/web_view_request.json)0
-rw-r--r--extensions/common/extension_api.cc6
-rw-r--r--extensions/common/permissions/extensions_api_permissions.cc6
-rw-r--r--extensions/extensions.gyp3
-rw-r--r--extensions/extensions_resources.grd1
-rw-r--r--extensions/extensions_strings.grd3
-rw-r--r--extensions/renderer/BUILD.gn3
-rw-r--r--extensions/renderer/dispatcher.cc3
-rw-r--r--extensions/renderer/resources/extensions_renderer_resources.grd1
-rw-r--r--extensions/renderer/resources/web_view.js6
-rw-r--r--extensions/renderer/resources/web_view_events.js92
-rw-r--r--extensions/renderer/resources/web_view_request_custom_bindings.js (renamed from chrome/renderer/resources/extensions/web_view_request_custom_bindings.js)0
35 files changed, 200 insertions, 235 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 7784c64..6e9873c 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4474,9 +4474,6 @@ Make sure you do not expose any sensitive information.
<message name="IDS_EXTENSION_PROMPT_WARNING_DESKTOP_CAPTURE" desc="Permission string for Desktop Capture API.">
Capture content of your screen
</message>
- <message name="IDS_EXTENSION_PROMPT_WARNING_DECLARATIVE_WEB_REQUEST" desc="Permission string for Declarative Web Request API.">
- Block parts of web pages
- </message>
<message name="IDS_EXTENSION_PROMPT_WARNING_BLUETOOTH_PRIVATE" desc="Permission string for Bluetooth Private API.">
Control Bluetooth adapter state and pairing
</message>
diff --git a/chrome/browser/extensions/api/chrome_extensions_api_client.cc b/chrome/browser/extensions/api/chrome_extensions_api_client.cc
index ee7974f..a64d1e9 100644
--- a/chrome/browser/extensions/api/chrome_extensions_api_client.cc
+++ b/chrome/browser/extensions/api/chrome_extensions_api_client.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/guest_view/web_view/chrome_web_view_permission_helper_delegate.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
-#include "extensions/browser/api/declarative/rules_registry_service.h"
#include "extensions/browser/guest_view/web_view/web_view_guest.h"
#include "extensions/browser/guest_view/web_view/web_view_permission_helper.h"
@@ -75,14 +74,6 @@ WebViewPermissionHelperDelegate* ChromeExtensionsAPIClient::
return new ChromeWebViewPermissionHelperDelegate(web_view_permission_helper);
}
-scoped_refptr<RulesRegistry> ChromeExtensionsAPIClient::GetRulesRegistry(
- content::BrowserContext* browser_context,
- const RulesRegistry::WebViewKey& webview_key,
- const std::string& event_name) {
- return RulesRegistryService::Get(browser_context)->
- GetRulesRegistry(webview_key, event_name);
-}
-
WebRequestEventRouterDelegate*
ChromeExtensionsAPIClient::CreateWebRequestEventRouterDelegate() const {
return new ChromeExtensionWebRequestEventRouterDelegate();
diff --git a/chrome/browser/extensions/api/chrome_extensions_api_client.h b/chrome/browser/extensions/api/chrome_extensions_api_client.h
index d6ed2dd..254f727 100644
--- a/chrome/browser/extensions/api/chrome_extensions_api_client.h
+++ b/chrome/browser/extensions/api/chrome_extensions_api_client.h
@@ -34,10 +34,6 @@ class ChromeExtensionsAPIClient : public ExtensionsAPIClient {
virtual WebViewPermissionHelperDelegate*
CreateWebViewPermissionHelperDelegate(
WebViewPermissionHelper* web_view_permission_helper) const OVERRIDE;
- virtual scoped_refptr<RulesRegistry> GetRulesRegistry(
- content::BrowserContext* browser_context,
- const RulesRegistry::WebViewKey& webview_key,
- const std::string& event_name) OVERRIDE;
virtual WebRequestEventRouterDelegate* CreateWebRequestEventRouterDelegate()
const OVERRIDE;
virtual scoped_refptr<ContentRulesRegistry> CreateContentRulesRegistry(
diff --git a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
index 1a6b9f7..428b72a 100644
--- a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
+++ b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc
@@ -26,19 +26,6 @@
#endif // defined(ENABLE_FULL_PRINTING)
#endif // defined(ENABLE_PRINTING)
-void RemoveWebViewEventListenersOnIOThread(
- void* profile,
- const std::string& extension_id,
- int embedder_process_id,
- int view_instance_id) {
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
- ExtensionWebRequestEventRouter::GetInstance()->RemoveWebViewEventListeners(
- profile,
- extension_id,
- embedder_process_id,
- view_instance_id);
-}
-
ChromeWebViewGuestDelegate::ChromeWebViewGuestDelegate(
extensions::WebViewGuest* web_view_guest)
: pending_context_menu_request_id_(0),
@@ -104,25 +91,6 @@ void ChromeWebViewGuestDelegate::OnAttachWebViewHelpers(
new ChromePDFWebContentsHelperClient()));
}
-void ChromeWebViewGuestDelegate::OnEmbedderDestroyed() {
- // TODO(fsamuel): WebRequest event listeners for <webview> should survive
- // reparenting of a <webview> within a single embedder. Right now, we keep
- // around the browser state for the listener for the lifetime of the embedder.
- // Ideally, the lifetime of the listeners should match the lifetime of the
- // <webview> DOM node. Once http://crbug.com/156219 is resolved we can move
- // the call to RemoveWebViewEventListenersOnIOThread back to
- // WebViewGuest::WebContentsDestroyed.
- content::BrowserThread::PostTask(
- content::BrowserThread::IO,
- FROM_HERE,
- base::Bind(
- &RemoveWebViewEventListenersOnIOThread,
- web_view_guest()->browser_context(),
- web_view_guest()->embedder_extension_id(),
- web_view_guest()->embedder_render_process_id(),
- web_view_guest()->view_instance_id()));
-}
-
void ChromeWebViewGuestDelegate::OnDidAttachToEmbedder() {
// TODO(fsamuel): This code should be implemented in GuestViewBase once the
// ZoomController moves to the extensions module.
diff --git a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h
index 7b4b892..4ddd70e 100644
--- a/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h
+++ b/chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h
@@ -32,7 +32,6 @@ class ChromeWebViewGuestDelegate : public extensions::WebViewGuestDelegate,
virtual bool HandleContextMenu(
const content::ContextMenuParams& params) OVERRIDE;
virtual void OnAttachWebViewHelpers(content::WebContents* contents) OVERRIDE;
- virtual void OnEmbedderDestroyed() OVERRIDE;
virtual void OnDidAttachToEmbedder() OVERRIDE;
virtual void OnDidCommitProvisionalLoadForFrame(bool is_main_frame) OVERRIDE;
virtual void OnDidInitialize() OVERRIDE;
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index fb28f98..f520b8b 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -169,9 +169,6 @@
'renderer/resources/extensions/system_indicator_custom_bindings.js',
'renderer/resources/extensions/tts_custom_bindings.js',
'renderer/resources/extensions/tts_engine_custom_bindings.js',
- 'renderer/resources/extensions/web_view.js',
- 'renderer/resources/extensions/web_view_events.js',
- 'renderer/resources/extensions/web_view_experimental.js',
],
'chrome_renderer_non_android_sources': [
'renderer/prerender/prerender_media_load_deferrer.cc',
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
index 4e95a5e..b7e3d05 100644
--- a/chrome/common/extensions/api/_api_features.json
+++ b/chrome/common/extensions/api/_api_features.json
@@ -250,10 +250,6 @@
"dependencies": ["permission:declarativeContent"],
"contexts": ["blessed_extension"]
},
- "declarativeWebRequest": {
- "dependencies": ["permission:declarativeWebRequest"],
- "contexts": ["blessed_extension"]
- },
"desktopCapture": {
"dependencies": ["permission:desktopCapture"],
"contexts": ["blessed_extension"]
@@ -313,13 +309,6 @@
"dependencies": ["permission:enterprise.platformKeysPrivate"],
"contexts": ["blessed_extension"]
},
- "events": {
- "internal": true,
- "channel": "stable",
- "extension_types": ["platform_app", "extension"],
- "contexts": "all",
- "matches": ["<all_urls>"]
- },
"experienceSamplingPrivate": {
"dependencies": ["permission:experienceSamplingPrivate"],
"contexts": ["blessed_extension"]
@@ -726,21 +715,6 @@
"dependencies": ["permission:webNavigation"],
"contexts": ["blessed_extension"]
},
- "webRequest": {
- "dependencies": ["permission:webRequest"],
- "contexts": ["blessed_extension"]
- },
- "webRequestInternal": [{
- "internal": true,
- "channel": "stable",
- "contexts": ["blessed_extension"]
- }, {
- // webview uses webRequestInternal API.
- "channel": "stable",
- "internal": true,
- "contexts": ["webui"],
- "matches": ["chrome://chrome-signin/*"]
- }],
"webrtcAudioPrivate": {
"dependencies": ["permission:webrtcAudioPrivate"],
"contexts": ["blessed_extension"]
@@ -768,14 +742,6 @@
// given the blessed_extension denomination. Confusing.
"contexts": ["blessed_extension"]
},
- "webViewRequest": [{
- "dependencies": ["permission:webview"],
- "contexts": ["blessed_extension"]
- }, {
- "channel": "stable",
- "contexts": ["webui"],
- "matches": ["chrome://chrome-signin/*"]
- }],
"webviewTag": {
"internal": true,
"channel": "stable",
diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json
index ebdbad1..dffeb39 100644
--- a/chrome/common/extensions/api/_permission_features.json
+++ b/chrome/common/extensions/api/_permission_features.json
@@ -329,12 +329,6 @@
"channel": "stable",
"extension_types": ["extension"]
},
- "declarativeWebRequest": [
- {
- "channel": "beta",
- "extension_types": ["extension", "legacy_packaged_app"]
- }
- ],
"desktopCapture": {
"channel": "stable",
"extension_types": ["extension", "platform_app"]
@@ -1062,13 +1056,5 @@
"2653F6F6C39BC6EEBD36A09AFB92A19782FF7EB4", // Enterprise Web Store
"2779FA8B45841D61A37207CCFAC9CB393964FE5B" // Login Proxy (prototype)
]
- },
- "webRequest": {
- "channel": "stable",
- "extension_types": ["extension", "legacy_packaged_app"]
- },
- "webRequestBlocking": {
- "channel": "stable",
- "extension_types": ["extension", "legacy_packaged_app"]
}
}
diff --git a/chrome/common/extensions/chrome_extensions_client.cc b/chrome/common/extensions/chrome_extensions_client.cc
index f9ce7e7..fb82325 100644
--- a/chrome/common/extensions/chrome_extensions_client.cc
+++ b/chrome/common/extensions/chrome_extensions_client.cc
@@ -267,8 +267,6 @@ void ChromeExtensionsClient::RegisterAPISchemaResources(
api->RegisterSchemaResource("commands", IDR_EXTENSION_API_JSON_COMMANDS);
api->RegisterSchemaResource("declarativeContent",
IDR_EXTENSION_API_JSON_DECLARATIVE_CONTENT);
- api->RegisterSchemaResource("declarativeWebRequest",
- IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST);
api->RegisterSchemaResource("fileBrowserHandler",
IDR_EXTENSION_API_JSON_FILEBROWSERHANDLER);
api->RegisterSchemaResource("inputMethodPrivate",
@@ -285,8 +283,6 @@ void ChromeExtensionsClient::RegisterAPISchemaResources(
api->RegisterSchemaResource("types.private",
IDR_EXTENSION_API_JSON_TYPES_PRIVATE);
api->RegisterSchemaResource("webstore", IDR_EXTENSION_API_JSON_WEBSTORE);
- api->RegisterSchemaResource("webViewRequest",
- IDR_EXTENSION_API_JSON_WEB_VIEW_REQUEST);
#endif // defined(ENABLE_EXTENSIONS)
}
diff --git a/chrome/common/extensions/permissions/chrome_api_permissions.cc b/chrome/common/extensions/permissions/chrome_api_permissions.cc
index 14c5578..aa1f1f5 100644
--- a/chrome/common/extensions/permissions/chrome_api_permissions.cc
+++ b/chrome/common/extensions/permissions/chrome_api_permissions.cc
@@ -38,10 +38,6 @@ std::vector<APIPermissionInfo*> ChromeAPIPermissions::GetAllPermissions()
PermissionMessage::kClipboard},
{APIPermission::kClipboardWrite, "clipboardWrite"},
{APIPermission::kDeclarativeContent, "declarativeContent"},
- {APIPermission::kDeclarativeWebRequest, "declarativeWebRequest",
- APIPermissionInfo::kFlagNone,
- IDS_EXTENSION_PROMPT_WARNING_DECLARATIVE_WEB_REQUEST,
- PermissionMessage::kDeclarativeWebRequest},
{APIPermission::kDesktopCapture, "desktopCapture",
APIPermissionInfo::kFlagNone,
IDS_EXTENSION_PROMPT_WARNING_DESKTOP_CAPTURE,
@@ -151,8 +147,6 @@ std::vector<APIPermissionInfo*> ChromeAPIPermissions::GetAllPermissions()
{APIPermission::kWebNavigation, "webNavigation",
APIPermissionInfo::kFlagNone, IDS_EXTENSION_PROMPT_WARNING_HISTORY_READ,
PermissionMessage::kTabs},
- {APIPermission::kWebRequest, "webRequest"},
- {APIPermission::kWebRequestBlocking, "webRequestBlocking"},
// Register private permissions.
{APIPermission::kScreenlockPrivate, "screenlockPrivate",
diff --git a/chrome/common/extensions_api_resources.grd b/chrome/common/extensions_api_resources.grd
index 7bf7de0..2bc6b6c 100644
--- a/chrome/common/extensions_api_resources.grd
+++ b/chrome/common/extensions_api_resources.grd
@@ -25,7 +25,6 @@
<include name="IDR_EXTENSION_API_JSON_TYPES" file="extensions\api\types.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_TYPES_PRIVATE" file="extensions\api\types_private.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_WEBSTORE" file="extensions\api\webstore.json" type="BINDATA" />
- <include name="IDR_EXTENSION_API_JSON_WEB_VIEW_REQUEST" file="extensions\api\web_view_request.json" type="BINDATA" />
</includes>
</release>
</grit>
diff --git a/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc b/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc
index b408544..4eab8ef 100644
--- a/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc
+++ b/chrome/renderer/extensions/chrome_extensions_dispatcher_delegate.cc
@@ -239,8 +239,6 @@ void ChromeExtensionsDispatcherDelegate::PopulateSourceMap(
source_map->RegisterSource("chromeWebView", IDR_CHROME_WEB_VIEW_JS);
source_map->RegisterSource("chromeWebViewExperimental",
IDR_CHROME_WEB_VIEW_EXPERIMENTAL_JS);
- source_map->RegisterSource("webViewRequest",
- IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS);
source_map->RegisterSource("denyAppView", IDR_APP_VIEW_DENY_JS);
source_map->RegisterSource("injectAppTitlebar", IDR_INJECT_APP_TITLEBAR_JS);
}
diff --git a/chrome/renderer/resources/extensions/chrome_web_view.js b/chrome/renderer/resources/extensions/chrome_web_view.js
index 8028ff0..badbf62 100644
--- a/chrome/renderer/resources/extensions/chrome_web_view.js
+++ b/chrome/renderer/resources/extensions/chrome_web_view.js
@@ -6,17 +6,9 @@
var ChromeWebView = require('chromeWebViewInternal').ChromeWebView;
var CreateEvent = require('webViewEvents').CreateEvent;
-var DeclarativeWebRequestSchema =
- requireNative('schema_registry').GetSchema('declarativeWebRequest');
var EventBindings = require('event_bindings');
-var IdGenerator = requireNative('id_generator');
-var WebRequestEvent = require('webRequestInternal').WebRequestEvent;
-var WebRequestSchema =
- requireNative('schema_registry').GetSchema('webRequest');
var WebViewInternal = require('webView').WebViewInternal
-var WebRequestMessageEvent = CreateEvent('webViewInternal.onMessage');
-
var CHROME_WEB_VIEW_EVENTS = {
'contextmenu': {
evt: CreateEvent('chromeWebViewInternal.contextmenu'),
@@ -28,25 +20,6 @@ var CHROME_WEB_VIEW_EVENTS = {
}
};
-function DeclarativeWebRequestEvent(opt_eventName,
- opt_argSchemas,
- opt_eventOptions,
- opt_webViewInstanceId) {
- var subEventName = opt_eventName + '/' + IdGenerator.GetNextId();
- EventBindings.Event.call(this, subEventName, opt_argSchemas, opt_eventOptions,
- opt_webViewInstanceId);
-
- // TODO(lazyboy): When do we dispose this listener?
- WebRequestMessageEvent.addListener(function() {
- // Re-dispatch to subEvent's listeners.
- $Function.apply(this.dispatch, this, $Array.slice(arguments));
- }.bind(this), {instanceId: opt_webViewInstanceId || 0});
-}
-
-DeclarativeWebRequestEvent.prototype = {
- __proto__: EventBindings.Event.prototype
-};
-
/**
* Implemented when the ChromeWebView API is available.
* @private
@@ -68,67 +41,3 @@ WebViewInternal.prototype.maybeHandleContextMenu = function(e, webViewEvent) {
var params = undefined;
ChromeWebView.showContextMenu(this.guestInstanceId, requestId, params);
};
-
-WebViewInternal.prototype.maybeSetupChromeWebViewEvents = function() {
- var request = {};
- var createWebRequestEvent = function(webRequestEvent) {
- return function() {
- if (!this[webRequestEvent.name]) {
- this[webRequestEvent.name] =
- new WebRequestEvent(
- 'webViewInternal.' + webRequestEvent.name,
- webRequestEvent.parameters,
- webRequestEvent.extraParameters, webRequestEvent.options,
- this.viewInstanceId);
- }
- return this[webRequestEvent.name];
- }.bind(this);
- }.bind(this);
-
- var createDeclarativeWebRequestEvent = function(webRequestEvent) {
- return function() {
- if (!this[webRequestEvent.name]) {
- // The onMessage event gets a special event type because we want
- // the listener to fire only for messages targeted for this particular
- // <webview>.
- var EventClass = webRequestEvent.name === 'onMessage' ?
- DeclarativeWebRequestEvent : EventBindings.Event;
- this[webRequestEvent.name] =
- new EventClass(
- 'webViewInternal.' + webRequestEvent.name,
- webRequestEvent.parameters,
- webRequestEvent.options,
- this.viewInstanceId);
- }
- return this[webRequestEvent.name];
- }.bind(this);
- }.bind(this);
-
- for (var i = 0; i < DeclarativeWebRequestSchema.events.length; ++i) {
- var eventSchema = DeclarativeWebRequestSchema.events[i];
- var webRequestEvent = createDeclarativeWebRequestEvent(eventSchema);
- Object.defineProperty(
- request,
- eventSchema.name,
- {
- get: webRequestEvent,
- enumerable: true
- }
- );
- }
-
- // Populate the WebRequest events from the API definition.
- for (var i = 0; i < WebRequestSchema.events.length; ++i) {
- var webRequestEvent = createWebRequestEvent(WebRequestSchema.events[i]);
- Object.defineProperty(
- request,
- WebRequestSchema.events[i].name,
- {
- get: webRequestEvent,
- enumerable: true
- }
- );
- }
-
- this.setRequestPropertyOnWebViewNode(request);
-};
diff --git a/chrome/renderer/resources/renderer_resources.grd b/chrome/renderer/resources/renderer_resources.grd
index 91dcc38..de2d49b 100644
--- a/chrome/renderer/resources/renderer_resources.grd
+++ b/chrome/renderer/resources/renderer_resources.grd
@@ -84,7 +84,6 @@
<include name="IDR_TTS_CUSTOM_BINDINGS_JS" file="extensions\tts_custom_bindings.js" type="BINDATA" />
<include name="IDR_TTS_ENGINE_CUSTOM_BINDINGS_JS" file="extensions\tts_engine_custom_bindings.js" type="BINDATA" />
<include name="IDR_WEBSTORE_CUSTOM_BINDINGS_JS" file="extensions\webstore_custom_bindings.js" type="BINDATA" />
- <include name="IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS" file="extensions\web_view_request_custom_bindings.js" type="BINDATA" />
<!-- Platform app support. -->
<include name="IDR_INJECT_APP_TITLEBAR_JS" file="extensions\inject_app_titlebar.js" type="BINDATA" />
diff --git a/extensions/browser/api/declarative/declarative_api.cc b/extensions/browser/api/declarative/declarative_api.cc
index e9b355d..5cd807e 100644
--- a/extensions/browser/api/declarative/declarative_api.cc
+++ b/extensions/browser/api/declarative/declarative_api.cc
@@ -13,6 +13,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
+#include "extensions/browser/api/declarative/rules_registry_service.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/guest_view/web_view/web_view_constants.h"
@@ -153,8 +154,8 @@ bool RulesFunction::RunAsync() {
// The following call will return a NULL pointer for apps_shell, but should
// never be called there anyways.
- rules_registry_ = ExtensionsAPIClient::Get()->GetRulesRegistry(
- browser_context(), key, event_name);
+ rules_registry_ = RulesRegistryService::Get(browser_context())->
+ GetRulesRegistry(key, event_name);
DCHECK(rules_registry_.get());
// Raw access to this function is not available to extensions, therefore
// there should never be a request for a nonexisting rules registry.
diff --git a/extensions/browser/api/declarative/rules_registry_service.cc b/extensions/browser/api/declarative/rules_registry_service.cc
index 12df013..9ddc450 100644
--- a/extensions/browser/api/declarative/rules_registry_service.cc
+++ b/extensions/browser/api/declarative/rules_registry_service.cc
@@ -95,8 +95,10 @@ void RulesRegistryService::EnsureDefaultRulesRegistriesRegistered(
scoped_refptr<ContentRulesRegistry> content_rules_registry =
ExtensionsAPIClient::Get()->CreateContentRulesRegistry(
browser_context_, content_rules_cache_delegate);
- RegisterRulesRegistry(content_rules_registry);
- content_rules_registry_ = content_rules_registry.get();
+ if (content_rules_registry.get() != nullptr) {
+ RegisterRulesRegistry(content_rules_registry);
+ content_rules_registry_ = content_rules_registry.get();
+ }
}
}
diff --git a/extensions/browser/api/extensions_api_client.cc b/extensions/browser/api/extensions_api_client.cc
index 2c3de15..09faa2d 100644
--- a/extensions/browser/api/extensions_api_client.cc
+++ b/extensions/browser/api/extensions_api_client.cc
@@ -55,13 +55,6 @@ WebViewPermissionHelperDelegate* ExtensionsAPIClient::
return new WebViewPermissionHelperDelegate(web_view_permission_helper);
}
-scoped_refptr<RulesRegistry> ExtensionsAPIClient::GetRulesRegistry(
- content::BrowserContext* browser_context,
- const RulesRegistry::WebViewKey& webview_key,
- const std::string& event_name) {
- return scoped_refptr<RulesRegistry>();
-}
-
WebRequestEventRouterDelegate*
ExtensionsAPIClient::CreateWebRequestEventRouterDelegate() const {
return NULL;
diff --git a/extensions/browser/api/extensions_api_client.h b/extensions/browser/api/extensions_api_client.h
index 7fc2c1c..878555b 100644
--- a/extensions/browser/api/extensions_api_client.h
+++ b/extensions/browser/api/extensions_api_client.h
@@ -86,13 +86,6 @@ class ExtensionsAPIClient {
CreateWebViewPermissionHelperDelegate (
WebViewPermissionHelper* web_view_permission_helper) const;
- // TODO(wjmaclean): Remove this as soon as rules_registry_service.* moves to
- // extensions/browser/api/declarative/.
- virtual scoped_refptr<RulesRegistry> GetRulesRegistry(
- content::BrowserContext* browser_context,
- const RulesRegistry::WebViewKey& webview_key,
- const std::string& event_name);
-
// Creates a delegate for WebRequestEventRouter.
virtual WebRequestEventRouterDelegate* CreateWebRequestEventRouterDelegate()
const;
diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc
index b3dda98..2e124e0 100644
--- a/extensions/browser/guest_view/web_view/web_view_guest.cc
+++ b/extensions/browser/guest_view/web_view/web_view_guest.cc
@@ -31,6 +31,7 @@
#include "content/public/common/stop_find_action.h"
#include "content/public/common/url_constants.h"
#include "extensions/browser/api/extensions_api_client.h"
+#include "extensions/browser/api/web_request/web_request_api.h"
#include "extensions/browser/api/web_view/web_view_internal_api.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/guest_view/guest_view_manager.h"
@@ -132,6 +133,19 @@ void ParsePartitionParam(const base::DictionaryValue& create_params,
}
}
+void RemoveWebViewEventListenersOnIOThread(
+ void* profile,
+ const std::string& extension_id,
+ int embedder_process_id,
+ int view_instance_id) {
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
+ ExtensionWebRequestEventRouter::GetInstance()->RemoveWebViewEventListeners(
+ profile,
+ extension_id,
+ embedder_process_id,
+ view_instance_id);
+}
+
} // namespace
// static
@@ -336,8 +350,15 @@ void WebViewGuest::DidStopLoading() {
}
void WebViewGuest::EmbedderDestroyed() {
- if (web_view_guest_delegate_)
- web_view_guest_delegate_->OnEmbedderDestroyed();
+ content::BrowserThread::PostTask(
+ content::BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(
+ &RemoveWebViewEventListenersOnIOThread,
+ browser_context(),
+ embedder_extension_id(),
+ embedder_render_process_id(),
+ view_instance_id()));
}
void WebViewGuest::GuestDestroyed() {
diff --git a/extensions/browser/guest_view/web_view/web_view_guest_delegate.h b/extensions/browser/guest_view/web_view/web_view_guest_delegate.h
index 2e27227..7a49407 100644
--- a/extensions/browser/guest_view/web_view/web_view_guest_delegate.h
+++ b/extensions/browser/guest_view/web_view/web_view_guest_delegate.h
@@ -40,9 +40,6 @@ class WebViewGuestDelegate {
// Called to attach helpers just after additional initialization is performed.
virtual void OnAttachWebViewHelpers(content::WebContents* contents) = 0;
- // Called to perform some cleanup prior to destruction.
- virtual void OnEmbedderDestroyed() = 0;
-
// Called after the guest has been attached to an embedder and suspended
// resource loads have been resumed.
virtual void OnDidAttachToEmbedder() = 0;
diff --git a/extensions/common/BUILD.gn b/extensions/common/BUILD.gn
index 09e7edc..10fd1c5 100644
--- a/extensions/common/BUILD.gn
+++ b/extensions/common/BUILD.gn
@@ -221,6 +221,7 @@ source_set("common") {
"//device/bluetooth",
"//device/usb",
"//extensions/common/api",
+ "//extensions:extensions_resources",
]
} else {
sources -= [
diff --git a/extensions/common/api/_api_features.json b/extensions/common/api/_api_features.json
index c72516f..06fb89e 100644
--- a/extensions/common/api/_api_features.json
+++ b/extensions/common/api/_api_features.json
@@ -69,6 +69,10 @@
"dependencies": ["permission:app.window.shape"],
"contexts": ["blessed_extension"]
},
+ "declarativeWebRequest": {
+ "dependencies": ["permission:declarativeWebRequest"],
+ "contexts": ["blessed_extension"]
+ },
"dns": {
"dependencies": ["permission:dns"],
"contexts": ["blessed_extension"]
@@ -81,6 +85,13 @@
"extension_types": ["extension", "legacy_packaged_app", "platform_app"],
"contexts": ["blessed_extension"]
},
+ "events": {
+ "internal": true,
+ "channel": "stable",
+ "extension_types": ["platform_app", "extension"],
+ "contexts": "all",
+ "matches": ["<all_urls>"]
+ },
"guestViewInternal": [
{
"internal": true,
@@ -241,6 +252,21 @@
"channel": "dev",
"contexts": ["webui"]
},
+ "webRequest": {
+ "dependencies": ["permission:webRequest"],
+ "contexts": ["blessed_extension"]
+ },
+ "webRequestInternal": [{
+ "internal": true,
+ "channel": "stable",
+ "contexts": ["blessed_extension"]
+ }, {
+ // webview uses webRequestInternal API.
+ "channel": "stable",
+ "internal": true,
+ "contexts": ["webui"],
+ "matches": ["chrome://chrome-signin/*"]
+ }],
"webViewExperimentalInternal": [{
"internal": true,
"channel": "dev",
@@ -268,5 +294,13 @@
"channel": "dev",
"contexts": ["webui"],
"matches": ["chrome://chrome-signin/*"]
+ }],
+ "webViewRequest": [{
+ "dependencies": ["permission:webview"],
+ "contexts": ["blessed_extension"]
+ }, {
+ "channel": "stable",
+ "contexts": ["webui"],
+ "matches": ["chrome://chrome-signin/*"]
}]
}
diff --git a/extensions/common/api/_permission_features.json b/extensions/common/api/_permission_features.json
index 68d725db..acb5951 100644
--- a/extensions/common/api/_permission_features.json
+++ b/extensions/common/api/_permission_features.json
@@ -103,6 +103,12 @@
"81986D4F846CEDDDB962643FA501D1780DD441BB" // http://crbug.com/407693
]
},
+ "declarativeWebRequest": [
+ {
+ "channel": "beta",
+ "extension_types": ["extension", "legacy_packaged_app"]
+ }
+ ],
"dns": [
{
"channel": "dev",
@@ -304,5 +310,17 @@
"D519188F86D9ACCEE0412007B227D9936EB9676B" // GAIA Component Extension
]
}
+ ],
+ "webRequest": [
+ {
+ "channel": "stable",
+ "extension_types": ["extension", "legacy_packaged_app"]
+ }
+ ],
+ "webRequestBlocking": [
+ {
+ "channel": "stable",
+ "extension_types": ["extension", "legacy_packaged_app"]
+ }
]
}
diff --git a/chrome/common/extensions/api/web_view_request.json b/extensions/common/api/web_view_request.json
index 826cfa3..826cfa3 100644
--- a/chrome/common/extensions/api/web_view_request.json
+++ b/extensions/common/api/web_view_request.json
diff --git a/extensions/common/extension_api.cc b/extensions/common/extension_api.cc
index d10084c..8267695 100644
--- a/extensions/common/extension_api.cc
+++ b/extensions/common/extension_api.cc
@@ -23,6 +23,7 @@
#include "extensions/common/features/simple_feature.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/permissions/permissions_data.h"
+#include "extensions/grit/extensions_resources.h"
#include "ui/base/resource/resource_bundle.h"
#include "url/gurl.h"
@@ -243,6 +244,11 @@ void ExtensionAPI::InitDefaultConfiguration() {
ExtensionsClient::Get()->RegisterAPISchemaResources(this);
+ RegisterSchemaResource("declarativeWebRequest",
+ IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST);
+ RegisterSchemaResource("webViewRequest",
+ IDR_EXTENSION_API_JSON_WEB_VIEW_REQUEST);
+
default_configuration_initialized_ = true;
}
diff --git a/extensions/common/permissions/extensions_api_permissions.cc b/extensions/common/permissions/extensions_api_permissions.cc
index d48eecc..61f3079 100644
--- a/extensions/common/permissions/extensions_api_permissions.cc
+++ b/extensions/common/permissions/extensions_api_permissions.cc
@@ -35,6 +35,10 @@ std::vector<APIPermissionInfo*> ExtensionsAPIPermissions::GetAllPermissions()
{APIPermission::kAudioCapture, "audioCapture",
APIPermissionInfo::kFlagNone, IDS_EXTENSION_PROMPT_WARNING_AUDIO_CAPTURE,
PermissionMessage::kAudioCapture},
+ {APIPermission::kDeclarativeWebRequest, "declarativeWebRequest",
+ APIPermissionInfo::kFlagNone,
+ IDS_EXTENSION_PROMPT_WARNING_DECLARATIVE_WEB_REQUEST,
+ PermissionMessage::kDeclarativeWebRequest},
{APIPermission::kDns, "dns"},
{APIPermission::kExternallyConnectableAllUrls,
"externally_connectable.all_urls"},
@@ -77,6 +81,8 @@ std::vector<APIPermissionInfo*> ExtensionsAPIPermissions::GetAllPermissions()
APIPermissionInfo::kFlagInternal,
IDS_EXTENSION_PROMPT_WARNING_WEB_CONNECTABLE,
PermissionMessage::kWebConnectable},
+ {APIPermission::kWebRequest, "webRequest"},
+ {APIPermission::kWebRequestBlocking, "webRequestBlocking"},
{APIPermission::kWebView, "webview",
APIPermissionInfo::kFlagCannotBeOptional},
{APIPermission::kWindowShape, "app.window.shape"},
diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp
index e2ef5d0..a8e3bbd 100644
--- a/extensions/extensions.gyp
+++ b/extensions/extensions.gyp
@@ -882,6 +882,9 @@
'renderer/resources/uncaught_exception_handler.js',
'renderer/resources/unload_event.js',
'renderer/resources/utils.js',
+ 'renderer/resources/extensions/web_view.js',
+ 'renderer/resources/extensions/web_view_events.js',
+ 'renderer/resources/extensions/web_view_experimental.js',
'renderer/resources/web_request_custom_bindings.js',
'renderer/resources/web_request_internal_custom_bindings.js',
'renderer/runtime_custom_bindings.cc',
diff --git a/extensions/extensions_resources.grd b/extensions/extensions_resources.grd
index f8b53a9..4799934 100644
--- a/extensions/extensions_resources.grd
+++ b/extensions/extensions_resources.grd
@@ -10,6 +10,7 @@
<includes>
<include name="IDR_EXTENSION_API_FEATURES" file="common\api\_api_features.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_DECLARATIVE_WEBREQUEST" file="common\api\declarative_web_request.json" type="BINDATA" />
+ <include name="IDR_EXTENSION_API_JSON_WEB_VIEW_REQUEST" file="common\api\web_view_request.json" type="BINDATA" />
<include name="IDR_EXTENSION_MANIFEST_FEATURES" file="common\api\_manifest_features.json" type="BINDATA" />
<include name="IDR_EXTENSION_PERMISSION_FEATURES" file="common\api\_permission_features.json" type="BINDATA" />
</includes>
diff --git a/extensions/extensions_strings.grd b/extensions/extensions_strings.grd
index 1553014..46ba60a 100644
--- a/extensions/extensions_strings.grd
+++ b/extensions/extensions_strings.grd
@@ -202,6 +202,9 @@
<message name="IDS_EXTENSION_MANIFEST_INVALID" desc="">
Manifest file is invalid.
</message>
+ <message name="IDS_EXTENSION_PROMPT_WARNING_DECLARATIVE_WEB_REQUEST" desc="Permission string for Declarative Web Request API.">
+ Block parts of web pages
+ </message>
<message name="IDS_LOAD_STATE_PARAMETER_EXTENSION" desc="Parameter to IDS_LOAD_STATE_WAITING_FOR_DELEGATE when we are waiting for an extension. The variable is the extension name.">
extension <ph name="EXTENSION_NAME">$1<ex>Adblock</ex></ph>
</message>
diff --git a/extensions/renderer/BUILD.gn b/extensions/renderer/BUILD.gn
index a0092c1..01577ea2 100644
--- a/extensions/renderer/BUILD.gn
+++ b/extensions/renderer/BUILD.gn
@@ -107,6 +107,9 @@ source_set("renderer") {
"resources/uncaught_exception_handler.js",
"resources/unload_event.js",
"resources/utils.js",
+ "resources/web_view.js",
+ "resources/web_view_events.js",
+ "resources/web_view_experimental.js",
"resources/web_request_custom_bindings.js",
"resources/web_request_internal_custom_bindings.js",
"runtime_custom_bindings.cc",
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index 278066c..efa95bb 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -579,6 +579,9 @@ std::vector<std::pair<std::string, int> > Dispatcher::GetJsResources() {
resources.push_back(
std::make_pair("runtime", IDR_RUNTIME_CUSTOM_BINDINGS_JS));
resources.push_back(std::make_pair("windowControls", IDR_WINDOW_CONTROLS_JS));
+ resources.push_back(
+ std::make_pair("webViewRequest",
+ IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS));
resources.push_back(std::make_pair("binding", IDR_BINDING_JS));
// Custom types sources.
diff --git a/extensions/renderer/resources/extensions_renderer_resources.grd b/extensions/renderer/resources/extensions_renderer_resources.grd
index 3a5bf11..82aee00 100644
--- a/extensions/renderer/resources/extensions_renderer_resources.grd
+++ b/extensions/renderer/resources/extensions_renderer_resources.grd
@@ -53,6 +53,7 @@
<include name="IDR_WEB_REQUEST_INTERNAL_CUSTOM_BINDINGS_JS" file="web_request_internal_custom_bindings.js" type="BINDATA" />
<include name="IDR_WINDOW_CONTROLS_JS" file="window_controls.js" type="BINDATA" />
<include name="IDR_WINDOW_CONTROLS_TEMPLATE_HTML" file="window_controls_template.html" type="BINDATA" />
+ <include name="IDR_WEB_VIEW_REQUEST_CUSTOM_BINDINGS_JS" file="web_view_request_custom_bindings.js" type="BINDATA" />
<!-- Custom types for APIs. -->
<include name="IDR_STORAGE_AREA_JS" file="storage_area.js" type="BINDATA" />
diff --git a/extensions/renderer/resources/web_view.js b/extensions/renderer/resources/web_view.js
index 98c80b9..3cf20f9 100644
--- a/extensions/renderer/resources/web_view.js
+++ b/extensions/renderer/resources/web_view.js
@@ -985,12 +985,6 @@ window.addEventListener('readystatechange', function listener(event) {
WebViewInternal.prototype.maybeGetChromeWebViewEvents = function() {};
/**
- * Implemented when the ChromeWebView API is available.
- * @private
- */
-WebViewInternal.prototype.maybeSetupChromeWebViewEvents = function() {};
-
-/**
* Implemented when the experimental API is available.
* @private
*/
diff --git a/extensions/renderer/resources/web_view_events.js b/extensions/renderer/resources/web_view_events.js
index 13af04c..f02069b 100644
--- a/extensions/renderer/resources/web_view_events.js
+++ b/extensions/renderer/resources/web_view_events.js
@@ -4,8 +4,14 @@
// Event management for WebViewInternal.
+var DeclarativeWebRequestSchema =
+ requireNative('schema_registry').GetSchema('declarativeWebRequest');
var EventBindings = require('event_bindings');
+var IdGenerator = requireNative('id_generator');
var MessagingNatives = requireNative('messaging_natives');
+var WebRequestEvent = require('webRequestInternal').WebRequestEvent;
+var WebRequestSchema =
+ requireNative('schema_registry').GetSchema('webRequest');
var WebView = require('webViewInternal').WebView;
var CreateEvent = function(name) {
@@ -15,6 +21,7 @@ var CreateEvent = function(name) {
var FrameNameChangedEvent = CreateEvent('webViewInternal.onFrameNameChanged');
var PluginDestroyedEvent = CreateEvent('webViewInternal.onPluginDestroyed');
+var WebRequestMessageEvent = CreateEvent('webViewInternal.onMessage');
// WEB_VIEW_EVENTS is a map of stable <webview> DOM event names to their
// associated extension event descriptor objects.
@@ -148,6 +155,25 @@ var WEB_VIEW_EVENTS = {
}
};
+function DeclarativeWebRequestEvent(opt_eventName,
+ opt_argSchemas,
+ opt_eventOptions,
+ opt_webViewInstanceId) {
+ var subEventName = opt_eventName + '/' + IdGenerator.GetNextId();
+ EventBindings.Event.call(this, subEventName, opt_argSchemas, opt_eventOptions,
+ opt_webViewInstanceId);
+
+ // TODO(lazyboy): When do we dispose this listener?
+ WebRequestMessageEvent.addListener(function() {
+ // Re-dispatch to subEvent's listeners.
+ $Function.apply(this.dispatch, this, $Array.slice(arguments));
+ }.bind(this), {instanceId: opt_webViewInstanceId || 0});
+}
+
+DeclarativeWebRequestEvent.prototype = {
+ __proto__: EventBindings.Event.prototype
+};
+
// Constructor.
function WebViewEvents(webViewInternal, viewInstanceId) {
this.webViewInternal = webViewInternal;
@@ -159,7 +185,7 @@ function WebViewEvents(webViewInternal, viewInstanceId) {
WebViewEvents.prototype.setup = function() {
this.setupFrameNameChangedEvent();
this.setupPluginDestroyedEvent();
- this.webViewInternal.maybeSetupChromeWebViewEvents();
+ this.setupWebRequestEvents();
this.webViewInternal.setupExperimentalContextMenus();
var events = this.getEvents();
@@ -180,6 +206,70 @@ WebViewEvents.prototype.setupPluginDestroyedEvent = function() {
}.bind(this), {instanceId: this.viewInstanceId});
};
+WebViewEvents.prototype.setupWebRequestEvents = function() {
+ var request = {};
+ var createWebRequestEvent = function(webRequestEvent) {
+ return function() {
+ if (!this[webRequestEvent.name]) {
+ this[webRequestEvent.name] =
+ new WebRequestEvent(
+ 'webViewInternal.' + webRequestEvent.name,
+ webRequestEvent.parameters,
+ webRequestEvent.extraParameters, webRequestEvent.options,
+ this.viewInstanceId);
+ }
+ return this[webRequestEvent.name];
+ }.bind(this);
+ }.bind(this);
+
+ var createDeclarativeWebRequestEvent = function(webRequestEvent) {
+ return function() {
+ if (!this[webRequestEvent.name]) {
+ // The onMessage event gets a special event type because we want
+ // the listener to fire only for messages targeted for this particular
+ // <webview>.
+ var EventClass = webRequestEvent.name === 'onMessage' ?
+ DeclarativeWebRequestEvent : EventBindings.Event;
+ this[webRequestEvent.name] =
+ new EventClass(
+ 'webViewInternal.' + webRequestEvent.name,
+ webRequestEvent.parameters,
+ webRequestEvent.options,
+ this.viewInstanceId);
+ }
+ return this[webRequestEvent.name];
+ }.bind(this);
+ }.bind(this);
+
+ for (var i = 0; i < DeclarativeWebRequestSchema.events.length; ++i) {
+ var eventSchema = DeclarativeWebRequestSchema.events[i];
+ var webRequestEvent = createDeclarativeWebRequestEvent(eventSchema);
+ Object.defineProperty(
+ request,
+ eventSchema.name,
+ {
+ get: webRequestEvent,
+ enumerable: true
+ }
+ );
+ }
+
+ // Populate the WebRequest events from the API definition.
+ for (var i = 0; i < WebRequestSchema.events.length; ++i) {
+ var webRequestEvent = createWebRequestEvent(WebRequestSchema.events[i]);
+ Object.defineProperty(
+ request,
+ WebRequestSchema.events[i].name,
+ {
+ get: webRequestEvent,
+ enumerable: true
+ }
+ );
+ }
+
+ this.webViewInternal.setRequestPropertyOnWebViewNode(request);
+};
+
WebViewEvents.prototype.getEvents = function() {
var experimentalEvents = this.webViewInternal.maybeGetExperimentalEvents();
for (var eventName in experimentalEvents) {
diff --git a/chrome/renderer/resources/extensions/web_view_request_custom_bindings.js b/extensions/renderer/resources/web_view_request_custom_bindings.js
index 62f7459..62f7459 100644
--- a/chrome/renderer/resources/extensions/web_view_request_custom_bindings.js
+++ b/extensions/renderer/resources/web_view_request_custom_bindings.js