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

Unified Diff: chrome/common/extensions/api/webview_tag.json

Issue 1133903004: <webview> documentation: addContentScripts/removeContentScripts should be in alphabetical order. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « no previous file | extensions/common/api/web_view_internal.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/api/webview_tag.json
diff --git a/chrome/common/extensions/api/webview_tag.json b/chrome/common/extensions/api/webview_tag.json
index 517ebb92d3cef6f4d06c38047126add695691410..cd3f36805be7a432370e491e442878525ed2119a 100644
--- a/chrome/common/extensions/api/webview_tag.json
+++ b/chrome/common/extensions/api/webview_tag.json
@@ -676,6 +676,23 @@
],
"functions": [
{
+ "name": "addContentScripts",
+ "type": "function",
+ "description": "<p>Adds content script injection rules to the <code>webview</code>. When the <code>webview</code> navigates to a page matching one or more rules, the associated scripts will be injected. You can programmatically add rules or update existing rules.</p><p>The following example adds two rules to the <code>webview</code>: 'myRule' and 'anotherRule'.</p><pre>webview.addContentScripts([\r {\r name: 'myRule',\r matches: ['http://www.foo.com/*'],\r css: { files: ['mystyles.css'] },\r js: { files: ['jquery.js', 'myscript.js'] },\r run_at: 'document_start'\r },\r {\r name: 'anotherRule',\r matches: ['http://www.bar.com/*'],\r js: { code: \"document.body.style.backgroundColor = 'red';\" },\r run_at: 'document_end'\r }]);\r ...\r\r// Navigates webview.\rwebview.src = 'http://www.foo.com';</pre><p>You can defer addContentScripts call until you needs to inject scripts.</p><p>The following example shows how to overwrite an existing rule.</p><pre>webview.addContentScripts([{\r name: 'rule',\r matches: ['http://www.foo.com/*'],\r js: { files: ['scriptA.js'] },\r run_at: 'document_start'}]);\r\r// Do something.\rwebview.src = 'http://www.foo.com/*';\r ...\r// Overwrite 'rule' defined before.\rwebview.addContentScripts([{\r name: 'rule',\r matches: ['http://www.bar.com/*'],\r js: { files: ['scriptB.js'] },\r run_at: 'document_end'}]);</pre><p>If <code>webview</code> has been naviagted to the origin (e.g., foo.com) and calls <code>webview.addContentScripts</code> to add 'myRule', you need to wait for next navigation to make the scripts injected. If you want immediate injection, <code>executeScript</code> will do the right thing.</p><p>Rules are preserved even if the guest process crashes or is killed or even if the <code>webview</code> is reparented.</p><p>Refer to the <a href='/extensions/content_scripts'>content scripts</a> documentation for more details.</p>",
+ "parameters": [
+ {
+ "type": "array",
+ "name": "contentScriptList",
+ "items": {
+ "$ref": "ContentScriptDetails",
+ "name": "contentScriptDetails"
+ },
+ "description": "Details of the content scripts to add.",
+ "minItems": 1
+ }
+ ]
+ },
+ {
"name": "back",
"type": "function",
"description": "Navigates backward one history entry if possible. Equivalent to <code>go(-1)</code>.",
@@ -732,41 +749,6 @@
]
},
{
- "name": "addContentScripts",
- "type": "function",
- "description": "<p>Adds content script injection rules to the <code>webview</code>. When the <code>webview</code> navigates to a page matching one or more rules, the associated scripts will be injected. You can programmatically add rules or update existing rules.</p><p>The following example adds two rules to the <code>webview</code>: 'myRule' and 'anotherRule'.</p><pre>webview.addContentScripts([\r {\r name: 'myRule',\r matches: ['http://www.foo.com/*'],\r css: { files: ['mystyles.css'] },\r js: { files: ['jquery.js', 'myscript.js'] },\r run_at: 'document_start'\r },\r {\r name: 'anotherRule',\r matches: ['http://www.bar.com/*'],\r js: { code: \"document.body.style.backgroundColor = 'red';\" },\r run_at: 'document_end'\r }]);\r ...\r\r// Navigates webview.\rwebview.src = 'http://www.foo.com';</pre><p>You can defer addContentScripts call until you needs to inject scripts.</p><p>The following example shows how to overwrite an existing rule.</p><pre>webview.addContentScripts([{\r name: 'rule',\r matches: ['http://www.foo.com/*'],\r js: { files: ['scriptA.js'] },\r run_at: 'document_start'}]);\r\r// Do something.\rwebview.src = 'http://www.foo.com/*';\r ...\r// Overwrite 'rule' defined before.\rwebview.addContentScripts([{\r name: 'rule',\r matches: ['http://www.bar.com/*'],\r js: { files: ['scriptB.js'] },\r run_at: 'document_end'}]);</pre><p>If <code>webview</code> has been naviagted to the origin (e.g., foo.com) and calls <code>webview.addContentScripts</code> to add 'myRule', you need to wait for next navigation to make the scripts injected. If you want immediate injection, <code>executeScript</code> will do the right thing.</p><p>Rules are preserved even if the guest process crashes or is killed or even if the <code>webview</code> is reparented.</p><p>Refer to the <a href='/extensions/content_scripts'>content scripts</a> documentation for more details.</p>",
- "parameters": [
- {
- "type": "array",
- "name": "contentScriptList",
- "items": {
- "$ref": "ContentScriptDetails",
- "name": "contentScriptDetails",
- "minimum": 1
- },
- "description": "Details of the content scripts to add."
- }
- ]
- },
- {
- "name": "removeContentScripts",
- "type": "function",
- "description": "<p>Removes content scripts from a <code>webview</code>.</p><p>The following example removes \"myRule\" which was added before.</p><pre>webview.removeContentScripts(['myRule']);</pre><p>You can remove all the rules by calling:</p><pre>webview.removeContentScripts();</pre>",
- "parameters": [
- {
- "type": "array",
- "name": "scriptNameList",
- "items": {
- "type": "string",
- "minimum": 0,
- "description": "The name of a content script that will be removed."
- },
- "optional": true,
- "description": "A list of names of content scripts that will be removed. If the list is empty, all the content scripts added to the <code>webview</code> will be removed."
- }
- ]
- },
- {
"name": "executeScript",
"type": "function",
"description": "<p>Injects JavaScript code into the guest page.</p><p>The following sample code uses script injection to set the guest page's background color to red:</p><pre>webview.executeScript({ code: \"document.body.style.backgroundColor = 'red'\" });</pre>",
@@ -958,6 +940,23 @@
"parameters": []
},
{
+ "name": "removeContentScripts",
+ "type": "function",
+ "description": "<p>Removes content scripts from a <code>webview</code>.</p><p>The following example removes \"myRule\" which was added before.</p><pre>webview.removeContentScripts(['myRule']);</pre><p>You can remove all the rules by calling:</p><pre>webview.removeContentScripts();</pre>",
+ "parameters": [
+ {
+ "type": "array",
+ "name": "scriptNameList",
+ "items": {
+ "type": "string",
+ "description": "The name of a content script that will be removed."
+ },
+ "optional": true,
+ "description": "A list of names of content scripts that will be removed. If the list is empty, all the content scripts added to the <code>webview</code> will be removed."
+ }
+ ]
+ },
+ {
"name": "setUserAgentOverride",
"type": "function",
"description": "Override the user agent string used by the <code>webview</code> for guest page requests.",
« no previous file with comments | « no previous file | extensions/common/api/web_view_internal.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698