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

Side by Side Diff: chrome/common/extensions/docs/templates/intros/permissions.html

Issue 116093007: Document that all-hosts works as an optional permission. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ben's review Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/api/permissions.json ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <h2 id="howto"> Implementing optional permissions </h2> 1 <h2 id="howto"> Implementing optional permissions </h2>
2 2
3 <h3 id="types"> 3 <h3 id="types">
4 Step 1: Decide which permissions are required and which are optional 4 Step 1: Decide which permissions are required and which are optional
5 </h3> 5 </h3>
6 6
7 <p> 7 <p>
8 An extension can declare both required and optional permissions. In general, you should: 8 An extension can declare both required and optional permissions. In general, you should:
9 <ul> 9 <ul>
10 <li>Use required permissions when they are needed for your extension’s basic f unctionality.</li> 10 <li>Use required permissions when they are needed for your extension’s basic f unctionality.</li>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 <li>notifications</li> 70 <li>notifications</li>
71 <li>pageCapture</li> 71 <li>pageCapture</li>
72 <li>tabs</li> 72 <li>tabs</li>
73 <li>topSites</li> 73 <li>topSites</li>
74 <li>webNavigation</li> 74 <li>webNavigation</li>
75 <li>webRequest</li> 75 <li>webRequest</li>
76 <li>webRequestBlocking</li> 76 <li>webRequestBlocking</li>
77 </ul> 77 </ul>
78 </p> 78 </p>
79 79
80 <p>If you want to request hosts that you only discover at runtime, include
81 <code>"http://*/"</code> and/or <code>"https://*/"</code> as an
82 <code>optional_permission</code>. This lets you specify any origin in
83 $ref:Permissions.origins as long as it has a matching scheme.
84 </p>
85
80 <h3 id="request"> Step 3: Request optional permissions </h3> 86 <h3 id="request"> Step 3: Request optional permissions </h3>
81 <p> 87 <p>
82 Request the permissions from within a user gesture using 88 Request the permissions from within a user gesture using
83 <code>permissions.request()</code>: 89 <code>permissions.request()</code>:
84 <pre> 90 <pre>
85 document.querySelector('#my-button').addEventListener('click', function(event) { 91 document.querySelector('#my-button').addEventListener('click', function(event) {
86 // Permissions must be requested from inside a user gesture, like a button's 92 // Permissions must be requested from inside a user gesture, like a button's
87 // click handler. 93 // click handler.
88 chrome.permissions.request({ 94 chrome.permissions.request({
89 permissions: ['tabs'], 95 permissions: ['tabs'],
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 origins: ['http://www.google.com/'] 152 origins: ['http://www.google.com/']
147 }, function(removed) { 153 }, function(removed) {
148 if (removed) { 154 if (removed) {
149 // The permissions have been removed. 155 // The permissions have been removed.
150 } else { 156 } else {
151 // The permissions have not been removed (e.g., you tried to remove 157 // The permissions have not been removed (e.g., you tried to remove
152 // required permissions). 158 // required permissions).
153 } 159 }
154 }); 160 });
155 </pre> 161 </pre>
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/permissions.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698