OLD | NEW |
(Empty) | |
| 1 <!-- BEGIN AUTHORED CONTENT --> |
| 2 <p>Use browser actions to put icons |
| 3 in the main Google Chrome toolbar, |
| 4 to the right of the address bar. |
| 5 In addition to its <a href="#icon">icon</a>, |
| 6 a browser action can also have |
| 7 a <a href="#tooltip">tooltip</a>, |
| 8 a <a href="#badge">badge</a>, |
| 9 and a <a href="#popups">popup</a>. |
| 10 </p> |
| 11 <p> |
| 12 In the following figure, |
| 13 the multicolored square |
| 14 to the right of the address bar |
| 15 is the icon for a browser action. |
| 16 A popup is below the icon. |
| 17 </p> |
| 18 <img src="/static/images/browser-action.png" |
| 19 width="363" height="226" /> |
| 20 <p> |
| 21 If you want to create an icon that isn't always visible, |
| 22 use a <a href="pageAction.html">page action</a> |
| 23 instead of a browser action. |
| 24 </p> |
| 25 <p class="caution"> |
| 26 <strong>Note:</strong> |
| 27 Packaged apps cannot use browser actions. |
| 28 </p> |
| 29 <!-- [PENDING: We should show tooltips and badges, as well.] --> |
| 30 <h2 id="manifest">Manifest</h2> |
| 31 <p> |
| 32 Register your browser action in the |
| 33 <a href="manifest.html">extension manifest</a> |
| 34 like this: |
| 35 </p> |
| 36 <pre>{ |
| 37 "name": "My extension", |
| 38 ... |
| 39 <b>"browser_action": { |
| 40 "default_icon": "images/icon19.png", <em>// optional</em> |
| 41 "default_title": "Google Mail", <em>// optional; shown in tooltip</em> |
| 42 "default_popup": "popup.html" <em>// optional</em> |
| 43 }</b>, |
| 44 ... |
| 45 }</pre> |
| 46 <h2 id="ui">Parts of the UI</h2> |
| 47 <p> |
| 48 A browser action can have an <a href="#icon">icon</a>, |
| 49 a <a href="#tooltip">tooltip</a>, |
| 50 a <a href="#badge">badge</a>, |
| 51 and a <a href="#popups">popup</a>. |
| 52 </p> |
| 53 <h3 id="icon">Icon</h3> |
| 54 <p>Browser action icons can be up to 19 pixels wide and high. |
| 55 Larger icons are resized to fit, but for best results, |
| 56 use a 19-pixel square icon.</p> |
| 57 <p>You can set the icon in two ways: |
| 58 using a static image or using the |
| 59 HTML5 <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the
-canvas-element.html">canvas element</a>. |
| 60 Using static images is easier for simple applications, |
| 61 but you can create more dynamic UIs — |
| 62 such as smooth animation — |
| 63 using the canvas element. |
| 64 </p> |
| 65 <p>Static images can be in any format WebKit can display, |
| 66 including BMP, GIF, ICO, JPEG, or PNG. |
| 67 </p> |
| 68 <p>To set the icon, |
| 69 use the <b>default_icon</b> field of <b>browser_action</b> |
| 70 in the <a href="#manifest">manifest</a>, |
| 71 or call the <a href="#method-setIcon">setIcon()</a> method. |
| 72 <h3 id="tooltip">Tooltip</h3> |
| 73 <p> |
| 74 To set the tooltip, |
| 75 use the <b>default_title</b> field of <b>browser_action</b> |
| 76 in the <a href="#manifest">manifest</a>, |
| 77 or call the <a href="#method-setTitle">setTitle()</a> method. |
| 78 You can specify locale-specific strings for the <b>default_title</b> field; |
| 79 see <a href="i18n.html">Internationalization</a> for details. |
| 80 </p> |
| 81 <h3 id="badge">Badge</h3> |
| 82 <p>Browser actions can optionally display a <em>badge</em> — |
| 83 a bit of text that is layered over the icon. |
| 84 Badges make it easy to update the browser action |
| 85 to display a small amount of information |
| 86 about the state of the extension.</p> |
| 87 <p>Because the badge has limited space, |
| 88 it should have 4 characters or less. |
| 89 </p> |
| 90 <p> |
| 91 Set the text and color of the badge using |
| 92 <a href="#method-setBadgeText">setBadgeText()</a> and |
| 93 <a href="#method-setBadgeBackgroundColor">setBadgeBackgroundColor()</a>, |
| 94 respectively. |
| 95 <!-- [PENDING: if you have a color but no text, will anything display?] --> |
| 96 </p> |
| 97 <h3 id="popups">Popup</h3> |
| 98 <p>If a browser action has a popup, |
| 99 the popup appears when the user clicks the icon. |
| 100 The popup can contain any HTML contents that you like, |
| 101 and it's automatically sized to fit its contents. |
| 102 </p> |
| 103 <p> |
| 104 To add a popup to your browser action, |
| 105 create an HTML file with the popup's contents. |
| 106 Specify the HTML file in the <b>default_popup</b> field of <b>browser_action</b> |
| 107 in the <a href="#manifest">manifest</a>, or call the |
| 108 <a href="#method-setPopup">setPopup()</a> method. |
| 109 </p> |
| 110 <h2>Tips</h2> |
| 111 <p>For the best visual impact, |
| 112 follow these guidelines:</p> |
| 113 <ul> |
| 114 <li><b>Do</b> use browser actions for features |
| 115 that make sense on most pages. |
| 116 <li><b>Don't</b> use browser actions for features |
| 117 that make sense for only a few pages. |
| 118 Use <a href="pageAction.html">page actions</a> instead. |
| 119 <li><b>Do</b> use big, colorful icons that make the most of |
| 120 the 19x19-pixel space. |
| 121 Browser action icons should seem a little bigger |
| 122 and heavier than page action icons. |
| 123 <li><b>Don't</b> attempt to mimic |
| 124 Google Chrome's monochrome "wrench" icon. |
| 125 That doesn't work well with themes, and anyway, |
| 126 extensions should stand out a little. |
| 127 <li><b>Do</b> use alpha transparency |
| 128 to add soft edges to your icon. |
| 129 Because many people use themes, |
| 130 your icon should look nice |
| 131 on a variety of background colors. |
| 132 <li><b>Don't</b> constantly animate your icon. |
| 133 That's just annoying. |
| 134 </ul> |
| 135 <h2 id="examples"> Examples </h2> |
| 136 <p> |
| 137 You can find simple examples of using browser actions in the |
| 138 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension
s/docs/examples/api/browserAction/">examples/api/browserAction</a> |
| 139 directory. |
| 140 For other examples and for help in viewing the source code, see |
| 141 <a href="samples.html">Samples</a>. |
| 142 </p> |
| 143 <!-- END AUTHORED CONTENT --> |
OLD | NEW |