Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <h1>The activeTab permission</h1> | |
| 2 | |
| 3 <p> | |
| 4 The <code>activeTab</code> permission gives an extension temporary access to the currently active tab when the user <em>invokes</em> the extension - for example by clicking its <a href="browserAction.html">browser action</a>. Access to the tab lasts until it is navigated or closed. | |
| 5 </p> | |
| 6 | |
| 7 <p> | |
| 8 The main benefit of the <code>activeTab</code> permission is that it displays <e m>no warning message</em> during installation: | |
| 9 | |
| 10 <table> | |
| 11 <tr> | |
| 12 <td>Without <code>activeTab</code>:</td> | |
| 13 <td><img src="{{static}}/images/active-tab-before.png"></td> | |
| 14 </tr> | |
| 15 <tr> | |
| 16 <td>With <code>activeTab</code>:</td> | |
| 17 <td><img src="{{static}}/images/active-tab-after.png"></td> | |
| 18 </tr> | |
| 19 </table> | |
| 20 | |
| 21 <h2>Manifest</h2> | |
|
Aaron Boodman
2012/09/21 03:10:59
Can you make this an actual working example, like
not at google - send to devlin
2012/09/21 05:08:13
I didn't see an example in the Google doc, but I s
| |
| 22 | |
| 23 <p> | |
| 24 Declare <code>activeTab</code> in your extension's <a href="manifest.html">manif est</a> like this: | |
| 25 </p> | |
| 26 | |
| 27 <pre>{ | |
| 28 "name": "My extension", | |
| 29 ... | |
| 30 "permissions": [ | |
| 31 <b>"activeTab"</b> | |
| 32 ], | |
| 33 ... | |
| 34 }</pre> | |
| 35 | |
| 36 <h2>Motivation</h2> | |
|
Aaron Boodman
2012/09/21 03:10:59
I updated this section slightly in the Google Doc
not at google - send to devlin
2012/09/21 05:08:13
Done.
| |
| 37 | |
| 38 <p> | |
| 39 Consider a web clipping extension that has a <a href="browserAction.html">browse r action</a> and <a href="contextMenus.html">context menu item</a>. This extensi on may only really need to access tabs when its browser action is clicked, or wh en its context menu item is executed. | |
| 40 </p> | |
| 41 | |
| 42 <p> | |
| 43 Without <code>activeTab</code>, this extension would need to request full, persi stent access to every web site, just so that it could do its work if it happened to be called upon by the user. This is a very large amount of privilege for an extension to have, especially when it doesn’t really need it. And if the extensi on is ever compromised by an attacker, the attacker gets all the privilege the e xtension had. | |
| 44 </p> | |
| 45 | |
| 46 <p> | |
| 47 In contrast, an extension with the <code>activeTab</code> permission only obtain s access to a tab in response to an explicit user gesture. If the extension is c ompromised the attacker would need to wait for the user to invoke the extension before obtaining access. And that access only lasts until the tab is navigated o r closed. | |
| 48 </p> | |
| 49 | |
| 50 <h2>What activeTab allows</h2> | |
| 51 | |
| 52 <p> | |
| 53 While the <code>activeTab</code> permission is enabled for a tab, an extension c an: | |
| 54 <ul> | |
| 55 <li>Call <code><a href="tabs.html#method-executeScript">executeScript()</a></c ode> on that tab. | |
| 56 <li>Get the URL, title, and favicon for that tab via an API that returns a <co de><a href="tabs.html#type-Tab">Tab</a></code> object (essentially, <code>active Tab</code> grants the <code><a href="tabs.html#manifest">tabs</a></code> permiss ion temporarily). | |
| 57 </ul> | |
| 58 </p> | |
| 59 | |
| 60 <h2>Invoking activeTab</h2> | |
| 61 | |
| 62 <p> | |
| 63 The following user gestures enable <code>activeTab</code>: | |
| 64 <ul> | |
| 65 <li>Executing a browser action | |
| 66 <li>Executing a page action | |
| 67 <li>Executing a context menu item | |
| 68 <li>Executing a keyboard shortcut from the commands API | |
| 69 <li>Accepting a suggestion from the omnibox API | |
| 70 </ul> | |
| 71 </p> | |
| OLD | NEW |