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

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: Can compile and no crash on extensions. 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 for details. 6 // See web_view.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
(...skipping 12 matching lines...) Expand all
23 this.guest.getId(), dataUrl, baseUrl, virtualUrl, function() { 23 this.guest.getId(), dataUrl, baseUrl, virtualUrl, function() {
24 // Report any errors. 24 // Report any errors.
25 if (chrome.runtime.lastError != undefined) { 25 if (chrome.runtime.lastError != undefined) {
26 window.console.error( 26 window.console.error(
27 'Error while running webview.loadDataWithBaseUrl: ' + 27 'Error while running webview.loadDataWithBaseUrl: ' +
28 chrome.runtime.lastError.message); 28 chrome.runtime.lastError.message);
29 } 29 }
30 }); 30 });
31 }; 31 };
32 32
33 WebViewImpl.prototype.addContentScripts = function() {
34 if (!this.guest.getId()) {
35 window.console.error(WebViewConstants.ERROR_MSG_CANNOT_INJECT_SCRIPT);
36 return false;
37 }
38 var args = $Array.concat([this.guest.getId()], $Array.slice(arguments));
39 return $Function.apply(WebViewInternal.addContentScripts, null, args);
40 };
41
42 WebViewImpl.prototype.removeContentScripts = function(var_args) {
43 if (!this.guest.getId()) {
44 window.console.error(WebViewConstants.ERROR_MSG_CANNOT_INJECT_SCRIPT);
45 return false;
46 }
47 var args = $Array.concat([this.guest.getId()], $Array.slice(arguments));
48 return $Function.apply(WebViewInternal.removeContentScripts, null, args);
49 };
50
33 // An array of <webview>'s experimental API methods. See |WEB_VIEW_API_METHODS| 51 // An array of <webview>'s experimental API methods. See |WEB_VIEW_API_METHODS|
34 // in web_view_api_methods.js for more details. 52 // in web_view_api_methods.js for more details.
35 var WEB_VIEW_EXPERIMENTAL_API_METHODS = [ 53 var WEB_VIEW_EXPERIMENTAL_API_METHODS = [
36 'loadDataWithBaseUrl' 54 'loadDataWithBaseUrl',
55 'addContentScripts',
56 'removeContentScripts'
37 ]; 57 ];
38 58
39 // Registers the experimantal WebVIew API when available. 59 // Registers the experimantal WebVIew API when available.
40 WebViewImpl.maybeGetExperimentalApiMethods = function() { 60 WebViewImpl.maybeGetExperimentalApiMethods = function() {
41 return WEB_VIEW_EXPERIMENTAL_API_METHODS; 61 return WEB_VIEW_EXPERIMENTAL_API_METHODS;
42 }; 62 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698