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

Unified Diff: extensions/renderer/resources/guest_view/web_view/web_view_api_methods.js

Issue 959413003: Implement <webview>.addContentScript/removeContentScript API [1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comments. Created 5 years, 9 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: extensions/renderer/resources/guest_view/web_view/web_view_api_methods.js
diff --git a/extensions/renderer/resources/guest_view/web_view/web_view_api_methods.js b/extensions/renderer/resources/guest_view/web_view/web_view_api_methods.js
index e42396e716b274ee11b02ef3c5adbe83513ae704..047436da0ff1c807f66e03e23f6f66ebdb38263e 100644
--- a/extensions/renderer/resources/guest_view/web_view/web_view_api_methods.js
+++ b/extensions/renderer/resources/guest_view/web_view/web_view_api_methods.js
@@ -11,6 +11,9 @@ var WebViewImpl = require('webView').WebViewImpl;
// implementations will be given default implementations. Default
// implementations come from createDefaultApiMethod() in web_view.js.
var WEB_VIEW_API_METHODS = [
+ // Add content scripts for the guest page.
+ 'addContentScripts',
+
// Navigates to the previous history entry.
'back',
@@ -64,6 +67,9 @@ var WEB_VIEW_API_METHODS = [
// Prints the contents of the webview.
'print',
+ // Removes content scripts for the guest page.
+ 'removeContentScripts',
+
// Reloads the current top-level page.
'reload',
@@ -89,6 +95,11 @@ var WEB_VIEW_API_METHODS = [
// -----------------------------------------------------------------------------
// Custom API method implementations.
+WebViewImpl.prototype.addContentScripts = function() {
+ var args = $Array.concat([this.viewInstanceId], $Array.slice(arguments));
+ return $Function.apply(WebViewInternal.addContentScripts, null, args);
+};
+
WebViewImpl.prototype.back = function(callback) {
return this.go(-1, callback);
};
@@ -148,6 +159,11 @@ WebViewImpl.prototype.print = function() {
return this.executeScript({code: 'window.print();'});
};
+WebViewImpl.prototype.removeContentScripts = function(var_args) {
+ var args = $Array.concat([this.viewInstanceId], $Array.slice(arguments));
+ return $Function.apply(WebViewInternal.removeContentScripts, null, args);
+};
+
WebViewImpl.prototype.setUserAgentOverride = function(userAgentOverride) {
this.userAgentOverride = userAgentOverride;
if (!this.guest.getId()) {

Powered by Google App Engine
This is Rietveld 408576698