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

Side by Side Diff: extensions/renderer/resources/guest_view/web_view_experimental.js

Issue 959413003: Implement <webview>.addContentScript/removeContentScript API [1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This module implements experimental API for <webview>. 5 // This module implements experimental API for <webview>.
6 // See web_view.js and web_view_api_methods.js for details. 6 // See web_view.js and web_view_api_methods.js for details.
7 // 7 //
8 // <webview> Experimental API is only available on canary and dev channels of 8 // <webview> Experimental API is only available on canary and dev channels of
9 // Chrome. 9 // Chrome.
10 10
11 var WebViewImpl = require('webView').WebViewImpl; 11 var WebViewImpl = require('webView').WebViewImpl;
12 var WebViewInternal = require('webViewInternal').WebViewInternal; 12 var WebViewInternal = require('webViewInternal').WebViewInternal;
13 13
14 WebViewImpl.prototype.addContentScripts = function() {
15 if (!this.guest.getId()) {
16 window.console.error(WebViewConstants.ERROR_MSG_CANNOT_INJECT_SCRIPT);
17 return false;
18 }
19 var args = $Array.concat([this.guest.getId()], $Array.slice(arguments));
20 return $Function.apply(WebViewInternal.addContentScripts, null, args);
21 };
22
23 WebViewImpl.prototype.removeContentScripts = function(var_args) {
24 if (!this.guest.getId()) {
25 window.console.error(WebViewConstants.ERROR_MSG_CANNOT_INJECT_SCRIPT);
26 return false;
27 }
28 var args = $Array.concat([this.guest.getId()], $Array.slice(arguments));
29 return $Function.apply(WebViewInternal.removeContentScripts, null, args);
30 };
31
14 // An array of <webview>'s experimental API methods. See |WEB_VIEW_API_METHODS| 32 // An array of <webview>'s experimental API methods. See |WEB_VIEW_API_METHODS|
15 // in web_view_api_methods.js for more details. 33 // in web_view_api_methods.js for more details.
16 var WEB_VIEW_EXPERIMENTAL_API_METHODS = [ 34 var WEB_VIEW_EXPERIMENTAL_API_METHODS = [
35 'addContentScripts',
36 'removeContentScripts'
17 ]; 37 ];
18 38
19 // Registers the experimantal WebVIew API when available. 39 // Registers the experimantal WebVIew API when available.
20 WebViewImpl.maybeGetExperimentalApiMethods = function() { 40 WebViewImpl.maybeGetExperimentalApiMethods = function() {
21 return WEB_VIEW_EXPERIMENTAL_API_METHODS; 41 return WEB_VIEW_EXPERIMENTAL_API_METHODS;
22 }; 42 };
OLDNEW
« extensions/browser/user_script_loader.cc ('K') | « extensions/common/api/web_view_internal.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698