OLD | NEW |
1 <p>Use browser actions to put icons | 1 <p>Use browser actions to put icons |
2 in the main Google Chrome toolbar, | 2 in the main Google Chrome toolbar, |
3 to the right of the address bar. | 3 to the right of the address bar. |
4 In addition to its <a href="#icon">icon</a>, | 4 In addition to its <a href="#icon">icon</a>, |
5 a browser action can also have | 5 a browser action can also have |
6 a <a href="#tooltip">tooltip</a>, | 6 a <a href="#tooltip">tooltip</a>, |
7 a <a href="#badge">badge</a>, | 7 a <a href="#badge">badge</a>, |
8 and a <a href="#popups">popup</a>. | 8 and a <a href="#popups">popup</a>. |
9 </p> | 9 </p> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 <p> | 37 <p> |
38 Register your browser action in the | 38 Register your browser action in the |
39 <a href="manifest.html">extension manifest</a> | 39 <a href="manifest.html">extension manifest</a> |
40 like this: | 40 like this: |
41 </p> | 41 </p> |
42 | 42 |
43 <pre>{ | 43 <pre>{ |
44 "name": "My extension", | 44 "name": "My extension", |
45 ... | 45 ... |
46 <b>"browser_action": { | 46 <b>"browser_action": { |
47 "default_icon": "images/icon19.png", <em>// optional</em> | 47 "default_icon": { <em>// optional</em> |
| 48 "19": "images/icon19.png", <em>// optional</em> |
| 49 "38": "images/icon38.png" <em>// optional</em> |
| 50 }, |
48 "default_title": "Google Mail", <em>// optional; shown in tooltip</em> | 51 "default_title": "Google Mail", <em>// optional; shown in tooltip</em> |
49 "default_popup": "popup.html" <em>// optional</em> | 52 "default_popup": "popup.html" <em>// optional</em> |
50 }</b>, | 53 }</b>, |
51 ... | 54 ... |
52 }</pre> | 55 }</pre> |
53 | 56 |
| 57 <p> |
| 58 If you only provide one of the 19px or 38px icon size, the extension system will |
| 59 scale the icon you provide to the pixel density of the user's display, which |
| 60 can lose detail or make it look fuzzy. The old syntax for registering the |
| 61 default icon is still supported: |
| 62 </p> |
| 63 |
| 64 <pre>{ |
| 65 "name": "My extension", |
| 66 ... |
| 67 <b>"browser_action": { |
| 68 ... |
| 69 "default_icon": "images/icon19.png" <em>// optional</em> |
| 70 <em>// equivalent to "default_icon": { "19": "images/icon19.png" }</em> |
| 71 }</b>, |
| 72 ... |
| 73 }</pre> |
| 74 |
54 <h2 id="ui">Parts of the UI</h2> | 75 <h2 id="ui">Parts of the UI</h2> |
55 | 76 |
56 <p> | 77 <p> |
57 A browser action can have an <a href="#icon">icon</a>, | 78 A browser action can have an <a href="#icon">icon</a>, |
58 a <a href="#tooltip">tooltip</a>, | 79 a <a href="#tooltip">tooltip</a>, |
59 a <a href="#badge">badge</a>, | 80 a <a href="#badge">badge</a>, |
60 and a <a href="#popups">popup</a>. | 81 and a <a href="#popups">popup</a>. |
61 </p> | 82 </p> |
62 | 83 |
63 <h3 id="icon">Icon</h3> | 84 <h3 id="icon">Icon</h3> |
64 | 85 |
65 <p>Browser action icons can be up to 19 pixels wide and high. | 86 <p>Browser action icons can be up to 19 dips (device-independent pixels) |
66 Larger icons are resized to fit, but for best results, | 87 wide and high. Larger icons are resized to fit, but for best results, |
67 use a 19-pixel square icon.</p> | 88 use a 19-dip square icon.</p> |
68 | 89 |
69 <p>You can set the icon in two ways: | 90 <p>You can set the icon in two ways: |
70 using a static image or using the | 91 using a static image or using the |
71 HTML5 <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the
-canvas-element.html">canvas element</a>. | 92 HTML5 <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the
-canvas-element.html">canvas element</a>. |
72 Using static images is easier for simple applications, | 93 Using static images is easier for simple applications, |
73 but you can create more dynamic UIs — | 94 but you can create more dynamic UIs — |
74 such as smooth animation — | 95 such as smooth animation — |
75 using the canvas element. | 96 using the canvas element. |
76 </p> | 97 </p> |
77 | 98 |
78 <p>Static images can be in any format WebKit can display, | 99 <p>Static images can be in any format WebKit can display, |
79 including BMP, GIF, ICO, JPEG, or PNG. | 100 including BMP, GIF, ICO, JPEG, or PNG. |
80 </p> | 101 </p> |
81 | 102 |
82 <p>To set the icon, | 103 <p>To set the icon, |
83 use the <b>default_icon</b> field of <b>browser_action</b> | 104 use the <b>default_icon</b> field of <b>browser_action</b> |
84 in the <a href="#manifest">manifest</a>, | 105 in the <a href="#manifest">manifest</a>, |
85 or call the <a href="#method-setIcon">setIcon()</a> method. | 106 or call the <a href="#method-setIcon">setIcon()</a> method. |
| 107 </p> |
86 | 108 |
| 109 <p>To properly display icon when screen pixel density (ratio |
| 110 <code>size_in_pixel / size_in_dip</code>) is different than 1, |
| 111 the icon can be defined as set of images with different sizes. |
| 112 The actual image to display will be selected from the set to |
| 113 best fit the pixel size of 19 dip icon. |
| 114 At the moment, the icon set can contain images with pixel sizes 19 and 38. |
| 115 </p> |
87 | 116 |
88 <h3 id="tooltip">Tooltip</h3> | 117 <h3 id="tooltip">Tooltip</h3> |
89 | 118 |
90 <p> | 119 <p> |
91 To set the tooltip, | 120 To set the tooltip, |
92 use the <b>default_title</b> field of <b>browser_action</b> | 121 use the <b>default_title</b> field of <b>browser_action</b> |
93 in the <a href="#manifest">manifest</a>, | 122 in the <a href="#manifest">manifest</a>, |
94 or call the <a href="#method-setTitle">setTitle()</a> method. | 123 or call the <a href="#method-setTitle">setTitle()</a> method. |
95 You can specify locale-specific strings for the <b>default_title</b> field; | 124 You can specify locale-specific strings for the <b>default_title</b> field; |
96 see <a href="i18n.html">Internationalization</a> for details. | 125 see <a href="i18n.html">Internationalization</a> for details. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 </ul> | 191 </ul> |
163 | 192 |
164 <h2 id="examples"> Examples </h2> | 193 <h2 id="examples"> Examples </h2> |
165 | 194 |
166 <p> | 195 <p> |
167 You can find simple examples of using browser actions in the | 196 You can find simple examples of using browser actions in the |
168 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension
s/docs/examples/api/browserAction/">examples/api/browserAction</a> | 197 <a href="http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extension
s/docs/examples/api/browserAction/">examples/api/browserAction</a> |
169 directory. | 198 directory. |
170 For other examples and for help in viewing the source code, see | 199 For other examples and for help in viewing the source code, see |
171 <a href="samples.html">Samples</a>. | 200 <a href="samples.html">Samples</a>. |
172 </p> | 201 </p> |
OLD | NEW |