OLD | NEW |
| (Empty) |
1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: | |
2 1) The <head> information in this page is significant, should be uniform | |
3 across api docs and should be edited only with knowledge of the | |
4 templating mechanism. | |
5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a | |
6 browser, it will be re-generated from the template, json schema and | |
7 authored overview content. | |
8 4) The <body>.innerHTML is also generated by an offline step so that this | |
9 page may easily be indexed by search engines. | |
10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> | |
11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
12 <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css"> | |
13 <link href="css/print.css" rel="stylesheet" type="text/css" media="print"> | |
14 <script type="text/javascript" src="../../../third_party/jstemplate/jstempla
te_compiled.js"> | |
15 </script> | |
16 <script type="text/javascript" src="../../../../third_party/json_minify/mini
fy-sans-regexp.js"> | |
17 </script> | |
18 <script type="text/javascript" src="js/api_page_generator.js"></script> | |
19 <script type="text/javascript" src="js/bootstrap.js"></script> | |
20 <script type="text/javascript" src="js/sidebar.js"></script> | |
21 <meta name="description" content="Documentation for the chrome.permissions mod
ule, which is part of the Google Chrome extension APIs."><title>Optional Permis
sions - Google Chrome Extensions - Google Code</title></head> | |
22 <body> <div id="devModeWarning" class="displayModeWarning"> | |
23 You are viewing extension docs in chrome via the 'file:' scheme: are you exp
ecting to see local changes when you refresh? You'll need run chrome with --allo
w-file-access-from-files. | |
24 </div> | |
25 <div id="branchWarning" class="displayModeWarning"> | |
26 <span>WARNING: This is the <span id="branchName">BETA</span> documentation. | |
27 It may not work with the stable release of Chrome.</span> | |
28 <select id="branchChooser"> | |
29 <option>Choose a different version... | |
30 </option><option value="">Stable | |
31 </option><option value="beta">Beta | |
32 </option><option value="dev">Dev | |
33 </option><option value="trunk">Trunk | |
34 </option></select> | |
35 </div> | |
36 <div id="unofficialWarning" class="displayModeWarning"> | |
37 <span>WARNING: This is unofficial documentation. It may not work with the | |
38 current release of Chrome.</span> | |
39 <button id="goToOfficialDocs">Go to the official docs</button> | |
40 </div> | |
41 <div id="gc-container" class="labs"> | |
42 <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION --> | |
43 <!-- In particular, sub-templates that recurse, must be used by allowing | |
44 jstemplate to make a copy of the template in this section which | |
45 are not operated on by way of the jsskip="true" --> | |
46 <!-- /SUBTEMPLATES --> | |
47 <a id="top"></a> | |
48 <div id="skipto"> | |
49 <a href="#gc-pagecontent">Skip to page content</a> | |
50 <a href="#gc-toc">Skip to main navigation</a> | |
51 </div> | |
52 <!-- API HEADER --> | |
53 <table id="header" width="100%" cellspacing="0" border="0"> | |
54 <tbody><tr> | |
55 <td valign="middle"><a href="http://code.google.com/"><img src="images/c
ode_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:
0; margin:0;"></a></td> | |
56 <td valign="middle" width="100%" style="padding-left:0.6em;"> | |
57 <form action="http://www.google.com/cse" id="cse" style="margin-top:0.
5em"> | |
58 <div id="gsc-search-box"> | |
59 <input type="hidden" name="cx" value="002967670403910741006:61_cvz
fqtno"> | |
60 <input type="hidden" name="ie" value="UTF-8"> | |
61 <input type="text" name="q" value="" size="55"> | |
62 <input class="gsc-search-button" type="submit" name="sa" value="Se
arch"> | |
63 <br> | |
64 <span class="greytext">e.g. "page action" or "tabs"</span> | |
65 </div> | |
66 </form> | |
67 <script type="text/javascript" src="https://www.google.com/jsapi"></sc
ript> | |
68 <script type="text/javascript">google.load("elements", "1", {packages:
"transliteration"});</script> | |
69 <script type="text/javascript" src="https://www.google.com/coop/cse/t1
3n?form=cse&t13n_langs=en"></script> | |
70 <script type="text/javascript" src="https://www.google.com/coop/cse/br
and?form=cse&lang=en"></script> | |
71 </td> | |
72 </tr> | |
73 </tbody></table> | |
74 <div id="codesiteContent" class=""> | |
75 <a id="gc-topnav-anchor"></a> | |
76 <div id="gc-topnav"> | |
77 <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Lab
s</a>)</h1> | |
78 <ul id="home" class="gc-topnav-tabs"> | |
79 <li id="home_link"> | |
80 <a href="index.html" title="Google Chrome Extensions home page">Home
</a> | |
81 </li> | |
82 <li id="docs_link"> | |
83 <a href="docs.html" title="Official Google Chrome Extensions documen
tation">Docs</a> | |
84 </li> | |
85 <li id="faq_link"> | |
86 <a href="faq.html" title="Answers to frequently asked questions abou
t Google Chrome Extensions">FAQ</a> | |
87 </li> | |
88 <li id="samples_link"> | |
89 <a href="samples.html" title="Sample extensions (with source code)">
Samples</a> | |
90 </li> | |
91 <li id="group_link"> | |
92 <a href="http://groups.google.com/a/chromium.org/group/chromium-exte
nsions" title="Google Chrome Extensions developer forum">Group</a> | |
93 </li> | |
94 <li id="so_link"> | |
95 <a href="http://stackoverflow.com/questions/tagged/google-chrome-ext
ension" title="[google-chrome-extension] tag on Stack Overflow">Questions?</a> | |
96 </li> | |
97 </ul> | |
98 </div> <!-- end gc-topnav --> | |
99 <div class="g-section g-tpl-170"> | |
100 <!-- SIDENAV --> | |
101 <div class="g-unit g-first" id="gc-toc"> | |
102 <ul> | |
103 <li><a href="getstarted.html">Getting Started</a></li> | |
104 <li><a href="overview.html">Overview</a></li> | |
105 <li><a href="whats_new.html">What's New?</a></li> | |
106 <li><h2><a href="devguide.html">Developer's Guide</a></h2> | |
107 <ul> | |
108 <li>Browser UI | |
109 <ul> | |
110 <li><a href="browserAction.html">Browser Actions</a></li> | |
111 <li><a href="contextMenus.html">Context Menus</a></li> | |
112 <li><a href="notifications.html">Desktop Notifications</a></li
> | |
113 <li><a href="omnibox.html">Omnibox</a></li> | |
114 <li><a href="options.html">Options Pages</a></li> | |
115 <li><a href="override.html">Override Pages</a></li> | |
116 <li><a href="pageAction.html">Page Actions</a></li> | |
117 </ul> | |
118 </li> | |
119 <li>Browser Interaction | |
120 <ul> | |
121 <li><a href="bookmarks.html">Bookmarks</a></li> | |
122 <li><a href="cookies.html">Cookies</a></li> | |
123 <li><a href="devtools.html">Developer Tools</a></li> | |
124 <li><a href="events.html">Events</a></li> | |
125 <li><a href="history.html">History</a></li> | |
126 <li><a href="management.html">Management</a></li> | |
127 <li><a href="tabs.html">Tabs</a></li> | |
128 <li><a href="windows.html">Windows</a></li> | |
129 </ul> | |
130 </li> | |
131 <li>Implementation | |
132 <ul> | |
133 <li><a href="a11y.html">Accessibility</a></li> | |
134 <li><a href="background_pages.html">Background Pages</a></li> | |
135 <li><a href="content_scripts.html">Content Scripts</a></li> | |
136 <li><a href="xhr.html">Cross-Origin XHR</a></li> | |
137 <li><a href="i18n.html">Internationalization</a></li> | |
138 <li><a href="messaging.html">Message Passing</a></li> | |
139 <li class="leftNavSelected">Optional Permissions</li> | |
140 <li><a href="npapi.html">NPAPI Plugins</a></li> | |
141 </ul> | |
142 </li> | |
143 <li>Finishing | |
144 <ul> | |
145 <li><a href="hosting.html">Hosting</a></li> | |
146 <li><a href="external_extensions.html">Other Deployment Option
s</a></li> | |
147 </ul> | |
148 </li> | |
149 </ul> | |
150 </li> | |
151 <li><h2><a href="apps.html">Packaged Apps</a></h2></li> | |
152 <li><h2><a href="tutorials.html">Tutorials</a></h2> | |
153 <ul> | |
154 <li><a href="tut_debugging.html">Debugging</a></li> | |
155 <li><a href="tut_analytics.html">Google Analytics</a></li> | |
156 <li><a href="tut_oauth.html">OAuth</a></li> | |
157 </ul> | |
158 </li> | |
159 <li><h2>Reference</h2> | |
160 <ul> | |
161 <li>Formats | |
162 <ul> | |
163 <li><a href="manifest.html">Manifest Files</a></li> | |
164 <li><a href="match_patterns.html">Match Patterns</a></li> | |
165 </ul> | |
166 </li> | |
167 <li><a href="permission_warnings.html">Permission Warnings</a></li
> | |
168 <li><a href="api_index.html">chrome.* APIs</a></li> | |
169 <li><a href="api_other.html">Other APIs</a></li> | |
170 </ul> | |
171 </li> | |
172 <li><h2><a href="samples.html">Samples</a></h2></li> | |
173 <div class="line"> </div> | |
174 <li><h2>More</h2> | |
175 <ul> | |
176 <li><a href="http://code.google.com/chrome/webstore/docs/index.htm
l">Chrome Web Store</a></li> | |
177 <li><a href="http://code.google.com/chrome/apps/docs/developers_gu
ide.html">Hosted Apps</a></li> | |
178 <li><a href="themes.html">Themes</a></li> | |
179 </ul> | |
180 </li> | |
181 </ul> | |
182 </div> | |
183 <script> | |
184 initToggles(); | |
185 </script> | |
186 <div class="g-unit" id="gc-pagecontent"> | |
187 <div id="pageTitle"> | |
188 <h1 class="page_title">Optional Permissions</h1> | |
189 </div> | |
190 <!-- TABLE OF CONTENTS --> | |
191 <div id="toc"> | |
192 <h2>Contents</h2> | |
193 <ol> | |
194 <li> | |
195 <a href="#howto"> Implementing optional permissions </a> | |
196 <ol> | |
197 <li> | |
198 <a href="#types"> | |
199 Step 1: Decide which permissions are optional and required | |
200 </a> | |
201 </li><li> | |
202 <a href="#manifest"> Step 2: Declare optional permissions in t
he manifest </a> | |
203 </li><li> | |
204 <a href="#request"> Step 3: Request optional permissions </a> | |
205 </li><li> | |
206 <a href="#contains"> Step 4: Check the extension's current per
missions </a> | |
207 </li><li> | |
208 <a href="#remove"> Step 5: Remove the permissions </a> | |
209 </li> | |
210 </ol> | |
211 </li> | |
212 <li> | |
213 <a href="#apiReference">API reference: chrome.permissions</a> | |
214 <ol> | |
215 <li> | |
216 <a href="#global-methods">Methods</a> | |
217 <ol> | |
218 <li> | |
219 <a href="#method-contains">contains</a> | |
220 </li><li> | |
221 <a href="#method-getAll">getAll</a> | |
222 </li><li> | |
223 <a href="#method-remove">remove</a> | |
224 </li><li> | |
225 <a href="#method-request">request</a> | |
226 </li> | |
227 </ol> | |
228 </li> | |
229 <li> | |
230 <a href="#global-events">Events</a> | |
231 <ol> | |
232 <li> | |
233 <a href="#event-onAdded">onAdded</a> | |
234 </li><li> | |
235 <a href="#event-onRemoved">onRemoved</a> | |
236 </li> | |
237 </ol> | |
238 </li> | |
239 <li> | |
240 <a href="#types">Types</a> | |
241 <ol> | |
242 <li> | |
243 <a href="#type-Permissions">Permissions</a> | |
244 <ol> | |
245 </ol> | |
246 </li> | |
247 </ol> | |
248 </li> | |
249 </ol> | |
250 </li> | |
251 </ol> | |
252 </div> | |
253 <!-- /TABLE OF CONTENTS --> | |
254 <!-- Standard content lead-in for experimental API pages --> | |
255 <!-- STATIC CONTENT PLACEHOLDER --> | |
256 <div id="static"><div id="pageData-name" class="pageData">Optional Permi
ssions</div> | |
257 <!-- BEGIN AUTHORED CONTENT --> | |
258 <p id="classSummary"> | |
259 Use the <code>chrome.permissions</code> module to implement | |
260 optional permissions. You can request optional permissions during your | |
261 extension's regular application flow rather than at install time, so users | |
262 understand why the permissions are needed and use only those that are | |
263 necessary. | |
264 </p> | |
265 <p> | |
266 For general information about permissions and details about each permission, | |
267 see the <a href="manifest.html#permissions">permissions</a> section of the | |
268 manifest documentation. | |
269 </p> | |
270 <h2 id="howto"> Implementing optional permissions </h2> | |
271 <h3 id="types"> | |
272 Step 1: Decide which permissions are optional and required | |
273 </h3> | |
274 <p> | |
275 Extensions should generally require permissions when they are needed for the | |
276 extension's basic functionality and employ optional permissions for optional | |
277 features. | |
278 </p> | |
279 <p> | |
280 Advantages of optional permissions: | |
281 </p><ul> | |
282 <li> | |
283 Users run with less permissions since they enable only what is needed. | |
284 </li> | |
285 <li> | |
286 The extension can help explain why it needs particular permissions by | |
287 requesting them when the user enables the relevant feature. | |
288 </li> | |
289 <li> | |
290 Chrome can avoid disabling extensions that upgrade if they add permissions | |
291 as optional rather than required. | |
292 </li> | |
293 </ul> | |
294 <p></p> | |
295 <p> | |
296 Advantages of required permissions: | |
297 </p><ul> | |
298 <li> | |
299 The extension can prompt the user once to accept all permissions. | |
300 </li> | |
301 <li> | |
302 They simplify extension development by guaranteeing which permissions are | |
303 present. | |
304 </li> | |
305 </ul> | |
306 <p></p> | |
307 <h3 id="manifest"> Step 2: Declare optional permissions in the manifest </h3> | |
308 <p> | |
309 Declare optional permissions in your <a href="manifest.html">extension | |
310 manifest</a> with the <code>optional_permissions</code> key, using the | |
311 same format as the <a href="manifest.html#permissions">permissions</a> | |
312 field: | |
313 </p><pre>{ | |
314 "name": "My extension", | |
315 ... | |
316 <b>"optional_permissions": [ "tabs", "http://www.google.com/" ],</b> | |
317 ... | |
318 }</pre> | |
319 <p></p> | |
320 <p> | |
321 You can specify any of the following as optional permissions: | |
322 </p><ul> | |
323 <li><i>host permissions</i></li> | |
324 <li>appNotifications</li> | |
325 <li>background</li> | |
326 <li>bookmarks</li> | |
327 <li>clipboardRead</li> | |
328 <li>clipboardWrite</li> | |
329 <li>contentSettings</li> | |
330 <li>contextMenus</li> | |
331 <li>cookies</li> | |
332 <li>debugger</li> | |
333 <li>history</li> | |
334 <li>idle</li> | |
335 <li>management</li> | |
336 <li>notifications</li> | |
337 <li>pageCapture</li> | |
338 <li>tabs</li> | |
339 <li>topSites</li> | |
340 <li>webNavigation</li> | |
341 <li>webRequest</li> | |
342 <li>webRequestBlocking</li> | |
343 </ul> | |
344 <p></p> | |
345 <p class="note"> | |
346 <b>Version note:</b> This list is correct as of Chrome 17. | |
347 More optional permissions might be allowed in future releases. | |
348 </p> | |
349 <h3 id="request"> Step 3: Request optional permissions </h3> | |
350 <p> | |
351 Request the permissions from within a user gesture using | |
352 <code>permissions.request()</code>: | |
353 </p><pre>document.querySelector('#my-button').addEventListener('click', function
(event) { | |
354 // Permissions must be requested from inside a user gesture, like a button's | |
355 // click handler. | |
356 chrome.permissions.request({ | |
357 permissions: ['tabs'], | |
358 origins: ['http://www.google.com/'] | |
359 }, function(granted) { | |
360 // The callback argument will be true if the user granted the permissions. | |
361 if (granted) { | |
362 doSomething(); | |
363 } else { | |
364 doSomethingElse(); | |
365 } | |
366 }); | |
367 }); | |
368 </pre> | |
369 <p></p> | |
370 <p> | |
371 Chrome prompts the user if adding the permissions results in different | |
372 <a href="permission_warnings.html">warning messages</a> than the user has | |
373 already seen and accepted. For example, the previous code might result in | |
374 a prompt like this: | |
375 </p> | |
376 <p style="text-align: center"> | |
377 <img src="images/perms-optional.png" alt="example permission confirmation prom
pt" width="416" height="234"> | |
378 </p> | |
379 <h3 id="contains"> Step 4: Check the extension's current permissions </h3> | |
380 <p> | |
381 To check whether your extension has a specific permission or set of | |
382 permissions, use <code>permission.contains()</code>: | |
383 </p> | |
384 <pre>chrome.permissions.contains({ | |
385 permissions: ['tabs'], | |
386 origins: ['http://www.google.com/'] | |
387 }, function(result) { | |
388 if (result) { | |
389 // The extension has the permissions. | |
390 } else { | |
391 // The extension doesn't have the permissions. | |
392 } | |
393 }); | |
394 </pre> | |
395 <h3 id="remove"> Step 5: Remove the permissions </h3> | |
396 <p> | |
397 You should remove permissions when you no longer need them. | |
398 After a permission has been removed, calling | |
399 <code>permissions.request()</code> usually adds the permission back without | |
400 prompting the user. | |
401 </p> | |
402 <pre>chrome.permissions.remove({ | |
403 permissions: ['tabs'], | |
404 origins: ['http://www.google.com/'] | |
405 }, function(removed) { | |
406 if (removed) { | |
407 // The permissions have been removed. | |
408 } else { | |
409 // The permissions have not been removed (e.g., you tried to remove | |
410 // required permissions). | |
411 } | |
412 }); | |
413 </pre> | |
414 <!-- END AUTHORED CONTENT --> | |
415 </div> | |
416 <!-- API PAGE --> | |
417 <div class="apiPage"> | |
418 <a name="apiReference"></a> | |
419 <h2>API reference: chrome.permissions</h2> | |
420 <!-- PROPERTIES --> | |
421 <!-- /apiGroup --> | |
422 <!-- METHODS --> | |
423 <div id="methodsTemplate" class="apiGroup"> | |
424 <a name="global-methods"></a> | |
425 <h3>Methods</h3> | |
426 <!-- iterates over all functions --> | |
427 <div class="apiItem"> | |
428 <a name="method-contains"></a> <!-- method-anchor --> | |
429 <h4>contains</h4> | |
430 <div class="summary"> | |
431 <!-- Note: intentionally longer 80 columns --> | |
432 <span>chrome.permissions.contains</span>(<span class="null"><s
pan>Permissions</span> | |
433 <var><span>permissions</span></var></span><span class="nul
l"><span>, </span><span>function</span> | |
434 <var><span>callback</span></var></span>)</div> | |
435 <div class="description"> | |
436 <p>Checks if the extension has the specified permissions.</p> | |
437 <!-- PARAMETERS --> | |
438 <h4>Parameters</h4> | |
439 <dl> | |
440 <div> | |
441 <div> | |
442 <dt> | |
443 <var>permissions</var> | |
444 <em> | |
445 <!-- TYPE --> | |
446 <div style="display:inline"> | |
447 ( | |
448 <span id="typeTemplate"> | |
449 <span> | |
450 <a href="permissions.html#type-Permissions">Permissions<
/a> | |
451 </span> | |
452 </span> | |
453 ) | |
454 </div> | |
455 </em> | |
456 </dt> | |
457 <dd class="todo"> | |
458 Undocumented. | |
459 </dd> | |
460 <!-- OBJECT PROPERTIES --> | |
461 <!-- OBJECT METHODS --> | |
462 <!-- OBJECT EVENT FIELDS --> | |
463 <!-- FUNCTION PARAMETERS --> | |
464 </div> | |
465 </div><div> | |
466 <div> | |
467 <dt> | |
468 <var>callback</var> | |
469 <em> | |
470 <!-- TYPE --> | |
471 <div style="display:inline"> | |
472 ( | |
473 <span id="typeTemplate"> | |
474 <span> | |
475 <span>function</span> | |
476 </span> | |
477 </span> | |
478 ) | |
479 </div> | |
480 </em> | |
481 </dt> | |
482 <dd class="todo"> | |
483 Undocumented. | |
484 </dd> | |
485 <!-- OBJECT PROPERTIES --> | |
486 <!-- OBJECT METHODS --> | |
487 <!-- OBJECT EVENT FIELDS --> | |
488 <!-- FUNCTION PARAMETERS --> | |
489 </div> | |
490 </div> | |
491 </dl> | |
492 <!-- RETURNS --> | |
493 <dl> | |
494 </dl> | |
495 <!-- CALLBACK --> | |
496 <div> | |
497 <div> | |
498 <h4>Callback function</h4> | |
499 <p> | |
500 The <em>callback</em> parameter should specify a function | |
501 that looks like this: | |
502 </p> | |
503 <!-- Note: intentionally longer 80 columns --> | |
504 <pre>function(<span>boolean result</span>) <span class="subdue
d">{...}</span>;</pre> | |
505 <dl> | |
506 <div> | |
507 <div> | |
508 <dt> | |
509 <var>result</var> | |
510 <em> | |
511 <!-- TYPE --> | |
512 <div style="display:inline"> | |
513 ( | |
514 <span id="typeTemplate"> | |
515 <span> | |
516 <span>boolean</span> | |
517 </span> | |
518 </span> | |
519 ) | |
520 </div> | |
521 </em> | |
522 </dt> | |
523 <dd>True if the extension has the specified permissions.</dd> | |
524 <!-- OBJECT PROPERTIES --> | |
525 <!-- OBJECT METHODS --> | |
526 <!-- OBJECT EVENT FIELDS --> | |
527 <!-- FUNCTION PARAMETERS --> | |
528 </div> | |
529 </div> | |
530 </dl> | |
531 </div> | |
532 </div> | |
533 <!-- MIN_VERSION --> | |
534 </div> <!-- /description --> | |
535 </div><div class="apiItem"> | |
536 <a name="method-getAll"></a> <!-- method-anchor --> | |
537 <h4>getAll</h4> | |
538 <div class="summary"> | |
539 <!-- Note: intentionally longer 80 columns --> | |
540 <span>chrome.permissions.getAll</span>(<span class="null"><spa
n>function</span> | |
541 <var><span>callback</span></var></span>)</div> | |
542 <div class="description"> | |
543 <p>Gets the extension's current set of permissions.</p> | |
544 <!-- PARAMETERS --> | |
545 <h4>Parameters</h4> | |
546 <dl> | |
547 <div> | |
548 <div> | |
549 <dt> | |
550 <var>callback</var> | |
551 <em> | |
552 <!-- TYPE --> | |
553 <div style="display:inline"> | |
554 ( | |
555 <span id="typeTemplate"> | |
556 <span> | |
557 <span>function</span> | |
558 </span> | |
559 </span> | |
560 ) | |
561 </div> | |
562 </em> | |
563 </dt> | |
564 <dd class="todo"> | |
565 Undocumented. | |
566 </dd> | |
567 <!-- OBJECT PROPERTIES --> | |
568 <!-- OBJECT METHODS --> | |
569 <!-- OBJECT EVENT FIELDS --> | |
570 <!-- FUNCTION PARAMETERS --> | |
571 </div> | |
572 </div> | |
573 </dl> | |
574 <!-- RETURNS --> | |
575 <dl> | |
576 </dl> | |
577 <!-- CALLBACK --> | |
578 <div> | |
579 <div> | |
580 <h4>Callback function</h4> | |
581 <p> | |
582 The <em>callback</em> parameter should specify a function | |
583 that looks like this: | |
584 </p> | |
585 <!-- Note: intentionally longer 80 columns --> | |
586 <pre>function(<span>Permissions permissions</span>) <span clas
s="subdued">{...}</span>;</pre> | |
587 <dl> | |
588 <div> | |
589 <div> | |
590 <dt> | |
591 <var>permissions</var> | |
592 <em> | |
593 <!-- TYPE --> | |
594 <div style="display:inline"> | |
595 ( | |
596 <span id="typeTemplate"> | |
597 <span> | |
598 <a href="permissions.html#type-Permissions">Permissions<
/a> | |
599 </span> | |
600 </span> | |
601 ) | |
602 </div> | |
603 </em> | |
604 </dt> | |
605 <dd>The extension's active permissions.</dd> | |
606 <!-- OBJECT PROPERTIES --> | |
607 <!-- OBJECT METHODS --> | |
608 <!-- OBJECT EVENT FIELDS --> | |
609 <!-- FUNCTION PARAMETERS --> | |
610 </div> | |
611 </div> | |
612 </dl> | |
613 </div> | |
614 </div> | |
615 <!-- MIN_VERSION --> | |
616 </div> <!-- /description --> | |
617 </div><div class="apiItem"> | |
618 <a name="method-remove"></a> <!-- method-anchor --> | |
619 <h4>remove</h4> | |
620 <div class="summary"> | |
621 <!-- Note: intentionally longer 80 columns --> | |
622 <span>chrome.permissions.remove</span>(<span class="null"><spa
n>Permissions</span> | |
623 <var><span>permissions</span></var></span><span class="opt
ional"><span>, </span><span>function</span> | |
624 <var><span>callback</span></var></span>)</div> | |
625 <div class="description"> | |
626 <p>Removes access to the specified permissions. If there are any
problems removing the permissions, <a href="extension.html#property-lastError">
chrome.extension.lastError</a> will be set.</p> | |
627 <!-- PARAMETERS --> | |
628 <h4>Parameters</h4> | |
629 <dl> | |
630 <div> | |
631 <div> | |
632 <dt> | |
633 <var>permissions</var> | |
634 <em> | |
635 <!-- TYPE --> | |
636 <div style="display:inline"> | |
637 ( | |
638 <span id="typeTemplate"> | |
639 <span> | |
640 <a href="permissions.html#type-Permissions">Permissions<
/a> | |
641 </span> | |
642 </span> | |
643 ) | |
644 </div> | |
645 </em> | |
646 </dt> | |
647 <dd class="todo"> | |
648 Undocumented. | |
649 </dd> | |
650 <!-- OBJECT PROPERTIES --> | |
651 <!-- OBJECT METHODS --> | |
652 <!-- OBJECT EVENT FIELDS --> | |
653 <!-- FUNCTION PARAMETERS --> | |
654 </div> | |
655 </div><div> | |
656 <div> | |
657 <dt> | |
658 <var>callback</var> | |
659 <em> | |
660 <!-- TYPE --> | |
661 <div style="display:inline"> | |
662 ( | |
663 <span class="optional">optional</span> | |
664 <span id="typeTemplate"> | |
665 <span> | |
666 <span>function</span> | |
667 </span> | |
668 </span> | |
669 ) | |
670 </div> | |
671 </em> | |
672 </dt> | |
673 <dd class="todo"> | |
674 Undocumented. | |
675 </dd> | |
676 <!-- OBJECT PROPERTIES --> | |
677 <!-- OBJECT METHODS --> | |
678 <!-- OBJECT EVENT FIELDS --> | |
679 <!-- FUNCTION PARAMETERS --> | |
680 </div> | |
681 </div> | |
682 </dl> | |
683 <!-- RETURNS --> | |
684 <dl> | |
685 </dl> | |
686 <!-- CALLBACK --> | |
687 <div> | |
688 <div> | |
689 <h4>Callback function</h4> | |
690 <p> | |
691 If you specify the <em>callback</em> parameter, it should | |
692 specify a function that looks like this: | |
693 </p> | |
694 <!-- Note: intentionally longer 80 columns --> | |
695 <pre>function(<span>boolean removed</span>) <span class="subdu
ed">{...}</span>;</pre> | |
696 <dl> | |
697 <div> | |
698 <div> | |
699 <dt> | |
700 <var>removed</var> | |
701 <em> | |
702 <!-- TYPE --> | |
703 <div style="display:inline"> | |
704 ( | |
705 <span id="typeTemplate"> | |
706 <span> | |
707 <span>boolean</span> | |
708 </span> | |
709 </span> | |
710 ) | |
711 </div> | |
712 </em> | |
713 </dt> | |
714 <dd>True if the permissions were removed.</dd> | |
715 <!-- OBJECT PROPERTIES --> | |
716 <!-- OBJECT METHODS --> | |
717 <!-- OBJECT EVENT FIELDS --> | |
718 <!-- FUNCTION PARAMETERS --> | |
719 </div> | |
720 </div> | |
721 </dl> | |
722 </div> | |
723 </div> | |
724 <!-- MIN_VERSION --> | |
725 </div> <!-- /description --> | |
726 </div><div class="apiItem"> | |
727 <a name="method-request"></a> <!-- method-anchor --> | |
728 <h4>request</h4> | |
729 <div class="summary"> | |
730 <!-- Note: intentionally longer 80 columns --> | |
731 <span>chrome.permissions.request</span>(<span class="null"><sp
an>Permissions</span> | |
732 <var><span>permissions</span></var></span><span class="opt
ional"><span>, </span><span>function</span> | |
733 <var><span>callback</span></var></span>)</div> | |
734 <div class="description"> | |
735 <p>Requests access to the specified permissions. These permissio
ns must be defined in the optional_permissions field of the manifest. If there a
re any problems requesting the permissions, <a href="extension.html#property-las
tError">chrome.extension.lastError</a> will be set.</p> | |
736 <!-- PARAMETERS --> | |
737 <h4>Parameters</h4> | |
738 <dl> | |
739 <div> | |
740 <div> | |
741 <dt> | |
742 <var>permissions</var> | |
743 <em> | |
744 <!-- TYPE --> | |
745 <div style="display:inline"> | |
746 ( | |
747 <span id="typeTemplate"> | |
748 <span> | |
749 <a href="permissions.html#type-Permissions">Permissions<
/a> | |
750 </span> | |
751 </span> | |
752 ) | |
753 </div> | |
754 </em> | |
755 </dt> | |
756 <dd class="todo"> | |
757 Undocumented. | |
758 </dd> | |
759 <!-- OBJECT PROPERTIES --> | |
760 <!-- OBJECT METHODS --> | |
761 <!-- OBJECT EVENT FIELDS --> | |
762 <!-- FUNCTION PARAMETERS --> | |
763 </div> | |
764 </div><div> | |
765 <div> | |
766 <dt> | |
767 <var>callback</var> | |
768 <em> | |
769 <!-- TYPE --> | |
770 <div style="display:inline"> | |
771 ( | |
772 <span class="optional">optional</span> | |
773 <span id="typeTemplate"> | |
774 <span> | |
775 <span>function</span> | |
776 </span> | |
777 </span> | |
778 ) | |
779 </div> | |
780 </em> | |
781 </dt> | |
782 <dd class="todo"> | |
783 Undocumented. | |
784 </dd> | |
785 <!-- OBJECT PROPERTIES --> | |
786 <!-- OBJECT METHODS --> | |
787 <!-- OBJECT EVENT FIELDS --> | |
788 <!-- FUNCTION PARAMETERS --> | |
789 </div> | |
790 </div> | |
791 </dl> | |
792 <!-- RETURNS --> | |
793 <dl> | |
794 </dl> | |
795 <!-- CALLBACK --> | |
796 <div> | |
797 <div> | |
798 <h4>Callback function</h4> | |
799 <p> | |
800 If you specify the <em>callback</em> parameter, it should | |
801 specify a function that looks like this: | |
802 </p> | |
803 <!-- Note: intentionally longer 80 columns --> | |
804 <pre>function(<span>boolean granted</span>) <span class="subdu
ed">{...}</span>;</pre> | |
805 <dl> | |
806 <div> | |
807 <div> | |
808 <dt> | |
809 <var>granted</var> | |
810 <em> | |
811 <!-- TYPE --> | |
812 <div style="display:inline"> | |
813 ( | |
814 <span id="typeTemplate"> | |
815 <span> | |
816 <span>boolean</span> | |
817 </span> | |
818 </span> | |
819 ) | |
820 </div> | |
821 </em> | |
822 </dt> | |
823 <dd>True if the user granted the specified permissions.</dd> | |
824 <!-- OBJECT PROPERTIES --> | |
825 <!-- OBJECT METHODS --> | |
826 <!-- OBJECT EVENT FIELDS --> | |
827 <!-- FUNCTION PARAMETERS --> | |
828 </div> | |
829 </div> | |
830 </dl> | |
831 </div> | |
832 </div> | |
833 <!-- MIN_VERSION --> | |
834 </div> <!-- /description --> | |
835 </div> <!-- /apiItem --> | |
836 </div> <!-- /apiGroup --> | |
837 <!-- EVENTS --> | |
838 <div id="eventsTemplate" class="apiGroup"> | |
839 <a name="global-events"></a> | |
840 <h3>Events</h3> | |
841 <!-- iterates over all events --> | |
842 <div class="apiItem"> | |
843 <a name="event-onAdded"></a> | |
844 <h4>onAdded</h4> | |
845 <div class="summary"> | |
846 <!-- Note: intentionally longer 80 columns --> | |
847 <span class="subdued">chrome.permissions.</span><span>onAdded</s
pan><span class="subdued">.addListener</span>(function(<span>Permissions permiss
ions</span>) <span class="subdued">{...}</span><span></span>); | |
848 </div> | |
849 <div class="description"> | |
850 <p>Fired when the extension acquires new permissions.</p> | |
851 <!-- LISTENER PARAMETERS --> | |
852 <div> | |
853 <h4>Listener parameters</h4> | |
854 <dl> | |
855 <div> | |
856 <div> | |
857 <dt> | |
858 <var>permissions</var> | |
859 <em> | |
860 <!-- TYPE --> | |
861 <div style="display:inline"> | |
862 ( | |
863 <span id="typeTemplate"> | |
864 <span> | |
865 <a href="permissions.html#type-Permissions">Permissions<
/a> | |
866 </span> | |
867 </span> | |
868 ) | |
869 </div> | |
870 </em> | |
871 </dt> | |
872 <dd>The newly acquired permissions.</dd> | |
873 <!-- OBJECT PROPERTIES --> | |
874 <!-- OBJECT METHODS --> | |
875 <!-- OBJECT EVENT FIELDS --> | |
876 <!-- FUNCTION PARAMETERS --> | |
877 </div> | |
878 </div> | |
879 </dl> | |
880 </div> | |
881 <!-- EXTRA PARAMETERS --> | |
882 <!-- LISTENER RETURN VALUE --> | |
883 <dl> | |
884 </dl> | |
885 </div> <!-- /description --> | |
886 <!-- /description --> | |
887 </div><div class="apiItem"> | |
888 <a name="event-onRemoved"></a> | |
889 <h4>onRemoved</h4> | |
890 <div class="summary"> | |
891 <!-- Note: intentionally longer 80 columns --> | |
892 <span class="subdued">chrome.permissions.</span><span>onRemoved<
/span><span class="subdued">.addListener</span>(function(<span>Permissions permi
ssions</span>) <span class="subdued">{...}</span><span></span>); | |
893 </div> | |
894 <div class="description"> | |
895 <p>Fired when access to permissions has been removed from the ex
tension.</p> | |
896 <!-- LISTENER PARAMETERS --> | |
897 <div> | |
898 <h4>Listener parameters</h4> | |
899 <dl> | |
900 <div> | |
901 <div> | |
902 <dt> | |
903 <var>permissions</var> | |
904 <em> | |
905 <!-- TYPE --> | |
906 <div style="display:inline"> | |
907 ( | |
908 <span id="typeTemplate"> | |
909 <span> | |
910 <a href="permissions.html#type-Permissions">Permissions<
/a> | |
911 </span> | |
912 </span> | |
913 ) | |
914 </div> | |
915 </em> | |
916 </dt> | |
917 <dd>The permissions that have been removed.</dd> | |
918 <!-- OBJECT PROPERTIES --> | |
919 <!-- OBJECT METHODS --> | |
920 <!-- OBJECT EVENT FIELDS --> | |
921 <!-- FUNCTION PARAMETERS --> | |
922 </div> | |
923 </div> | |
924 </dl> | |
925 </div> | |
926 <!-- EXTRA PARAMETERS --> | |
927 <!-- LISTENER RETURN VALUE --> | |
928 <dl> | |
929 </dl> | |
930 </div> <!-- /description --> | |
931 <!-- /description --> | |
932 </div> <!-- /apiItem --> | |
933 </div> <!-- /apiGroup --> | |
934 <!-- TYPES --> | |
935 <div class="apiGroup"> | |
936 <a name="types"></a> | |
937 <h3 id="types">Types</h3> | |
938 <!-- iterates over all types --> | |
939 <div class="apiItem"> | |
940 <a name="type-Permissions"></a> | |
941 <h4>Permissions</h4> | |
942 <div> | |
943 <dt> | |
944 <em> | |
945 <!-- TYPE --> | |
946 <div style="display:inline"> | |
947 ( | |
948 <span id="typeTemplate"> | |
949 <span> | |
950 <span>object</span> | |
951 </span> | |
952 </span> | |
953 ) | |
954 </div> | |
955 </em> | |
956 </dt> | |
957 <dd class="todo"> | |
958 Undocumented. | |
959 </dd> | |
960 <!-- OBJECT PROPERTIES --> | |
961 <dd> | |
962 <dl> | |
963 <div> | |
964 <div> | |
965 <dt> | |
966 <var>permissions</var> | |
967 <em> | |
968 <!-- TYPE --> | |
969 <div style="display:inline"> | |
970 ( | |
971 <span class="optional">optional</span> | |
972 <span id="typeTemplate"> | |
973 <span> | |
974 <span> | |
975 array of <span><span> | |
976 <span> | |
977 <span>string</span> | |
978 </span> | |
979 </span></span> | |
980 </span> | |
981 </span> | |
982 </span> | |
983 ) | |
984 </div> | |
985 </em> | |
986 </dt> | |
987 <dd>List of named permissions (does not include hosts or origins).</dd
> | |
988 <!-- OBJECT PROPERTIES --> | |
989 <!-- OBJECT METHODS --> | |
990 <!-- OBJECT EVENT FIELDS --> | |
991 <!-- FUNCTION PARAMETERS --> | |
992 </div> | |
993 </div><div> | |
994 <div> | |
995 <dt> | |
996 <var>origins</var> | |
997 <em> | |
998 <!-- TYPE --> | |
999 <div style="display:inline"> | |
1000 ( | |
1001 <span class="optional">optional</span> | |
1002 <span id="typeTemplate"> | |
1003 <span> | |
1004 <span> | |
1005 array of <span><span> | |
1006 <span> | |
1007 <span>string</span> | |
1008 </span> | |
1009 </span></span> | |
1010 </span> | |
1011 </span> | |
1012 </span> | |
1013 ) | |
1014 </div> | |
1015 </em> | |
1016 </dt> | |
1017 <dd>List of origin permissions.</dd> | |
1018 <!-- OBJECT PROPERTIES --> | |
1019 <!-- OBJECT METHODS --> | |
1020 <!-- OBJECT EVENT FIELDS --> | |
1021 <!-- FUNCTION PARAMETERS --> | |
1022 </div> | |
1023 </div> | |
1024 </dl> | |
1025 </dd> | |
1026 <!-- OBJECT METHODS --> | |
1027 <!-- OBJECT EVENT FIELDS --> | |
1028 <!-- FUNCTION PARAMETERS --> | |
1029 </div> | |
1030 </div> <!-- /apiItem --> | |
1031 </div> <!-- /apiGroup --> | |
1032 </div> <!-- /apiPage --> | |
1033 </div> <!-- /gc-pagecontent --> | |
1034 </div> <!-- /g-section --> | |
1035 </div> <!-- /codesiteContent --> | |
1036 <div id="gc-footer" --=""> | |
1037 <div class="text"> | |
1038 <p> | |
1039 Except as otherwise <a href="http://code.google.com/policies.html#restrictions
">noted</a>, | |
1040 the content of this page is licensed under the <a rel="license" href="http://c
reativecommons.org/licenses/by/3.0/">Creative Commons | |
1041 Attribution 3.0 License</a>, and code samples are licensed under the | |
1042 <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD Lic
ense</a>. | |
1043 </p> | |
1044 <p> | |
1045 ©2011 Google | |
1046 </p> | |
1047 <!-- begin analytics --> | |
1048 <script src="https://www.google-analytics.com/urchin.js" type="text/javascript">
</script> | |
1049 <script src="https://www.google-analytics.com/ga.js" type="text/javascript"></sc
ript> | |
1050 <script type="text/javascript"> | |
1051 // chrome doc tracking | |
1052 try { | |
1053 var engdocs = _gat._getTracker("YT-10763712-2"); | |
1054 engdocs._trackPageview(); | |
1055 } catch(err) {} | |
1056 // code.google.com site-wide tracking | |
1057 try { | |
1058 _uacct="UA-18071-1"; | |
1059 _uanchor=1; | |
1060 _uff=0; | |
1061 urchinTracker(); | |
1062 } | |
1063 catch(e) {/* urchinTracker not available. */} | |
1064 </script> | |
1065 <!-- end analytics --> | |
1066 </div> | |
1067 </div> <!-- /gc-footer --> | |
1068 </div> <!-- /gc-container --> | |
1069 </body></html> | |
OLD | NEW |