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

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

Issue 2452683002: [Extensions Docs] Update browser/page action documentation (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/templates/intros/pageAction.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <p> 1 <p>
2 In the following figure, 2 In the following figure,
3 the multicolored square 3 the multicolored square
4 to the right of the address bar 4 to the right of the address bar
5 is the icon for a browser action. 5 is the icon for a browser action.
6 A popup is below the icon. 6 A popup is below the icon.
7 </p> 7 </p>
8 8
9 <img src="{{static}}/images/browser-action.png" 9 <img src="{{static}}/images/browser-action.png"
10 width="363" height="226" /> 10 width="363" height="226" />
(...skipping 11 matching lines...) Expand all
22 <a href="manifest">extension manifest</a> 22 <a href="manifest">extension manifest</a>
23 like this: 23 like this:
24 </p> 24 </p>
25 25
26 <pre data-filename="manifest.json"> 26 <pre data-filename="manifest.json">
27 { 27 {
28 "name": "My extension", 28 "name": "My extension",
29 ... 29 ...
30 <b>"browser_action": { 30 <b>"browser_action": {
31 "default_icon": { <em>// optional</em> 31 "default_icon": { <em>// optional</em>
32 "19": "images/icon19.png", <em>// optional</em> 32 "16": "images/icon16.png", <em>// optional</em>
33 "38": "images/icon38.png" <em>// optional</em> 33 "24": "images/icon24.png", <em>// optional</em>
34 "32": "images/icon32.png" <em>// optional</em>
34 }, 35 },
35 "default_title": "Google Mail", <em>// optional; shown in tooltip</em> 36 "default_title": "Google Mail", <em>// optional; shown in tooltip</em>
36 "default_popup": "popup.html" <em>// optional</em> 37 "default_popup": "popup.html" <em>// optional</em>
37 }</b>, 38 }</b>,
38 ... 39 ...
39 } 40 }
40 </pre> 41 </pre>
41 42
42 <p> 43 <p>
43 If you only provide one of the 19px or 38px icon size, the extension system will 44 You can provide any size icon to be used in Chrome, and Chrome will select the
44 scale the icon you provide to the pixel density of the user's display, which 45 closest one and scale it to the appropriate size to fill the 16-dip space.
45 can lose detail or make it look fuzzy. The old syntax for registering the 46 However, if the exact size isn't provided, this scaling can cause the icon to
46 default icon is still supported: 47 lose detail or look fuzzy.
48 </p>
49
50 <p>
51 Since devices with less-common scale factors like 1.5x or 1.2x are becoming more
52 common, you are encouraged to provide multiple sizes for your icons. This also
53 ensures that if the icon display size is ever changed, you don't need to do any
54 more work to provide different icons!
55 </p>
56
57 <p>
58 The old syntax for registering the default icon is still supported:
47 </p> 59 </p>
48 60
49 <pre data-filename="manifest.json"> 61 <pre data-filename="manifest.json">
50 { 62 {
51 "name": "My extension", 63 "name": "My extension",
52 ... 64 ...
53 <b>"browser_action": { 65 <b>"browser_action": {
54 ... 66 ...
55 "default_icon": "images/icon38.png" <em>// optional</em> 67 "default_icon": "images/icon32.png" <em>// optional</em>
56 <em>// equivalent to "default_icon": { "38": "images/icon38.png" }</em> 68 <em>// equivalent to "default_icon": { "32": "images/icon32.png" }</em>
57 }</b>, 69 }</b>,
58 ... 70 ...
59 } 71 }
60 </pre> 72 </pre>
61 73
62 <h2 id="ui">Parts of the UI</h2> 74 <h2 id="ui">Parts of the UI</h2>
63 75
64 <p> 76 <p>
65 A browser action can have an <a href="#icon">icon</a>, 77 A browser action can have an <a href="#icon">icon</a>,
66 a <a href="#tooltip">tooltip</a>, 78 a <a href="#tooltip">tooltip</a>,
67 a <a href="#badge">badge</a>, 79 a <a href="#badge">badge</a>,
68 and a <a href="#popups">popup</a>. 80 and a <a href="#popups">popup</a>.
69 </p> 81 </p>
70 82
71 <h3 id="icon">Icon</h3> 83 <h3 id="icon">Icon</h3>
72 84
73 <p>Browser action icons can be up to 19 dips (device-independent pixels) 85 <p>The browser action icons in Chrome are 16 dips (device-independent pixels)
74 wide and high. Larger icons are resized to fit, but for best results, 86 wide and high. Larger icons are resized to fit, but for best results,
75 use a 19-dip square icon.</p> 87 use a 16-dip square icon.</p>
76 88
77 <p>You can set the icon in two ways: 89 <p>You can set the icon in two ways:
78 using a static image or using the 90 using a static image or using the
79 HTML5 <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the -canvas-element.html">canvas element</a>. 91 HTML5 <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the -canvas-element.html">canvas element</a>.
80 Using static images is easier for simple applications, 92 Using static images is easier for simple applications,
81 but you can create more dynamic UIs &mdash; 93 but you can create more dynamic UIs &mdash;
82 such as smooth animation &mdash; 94 such as smooth animation &mdash;
83 using the canvas element. 95 using the canvas element.
84 </p> 96 </p>
85 97
86 <p>Static images can be in any format WebKit can display, 98 <p>Static images can be in any format WebKit can display,
87 including BMP, GIF, ICO, JPEG, or PNG. 99 including BMP, GIF, ICO, JPEG, or PNG.
88 For unpacked extensions, images must be in the PNG format. 100 For unpacked extensions, images must be in the PNG format.
89 </p> 101 </p>
90 102
91 <p>To set the icon, 103 <p>To set the icon,
92 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>
93 in the <a href="#manifest">manifest</a>, 105 in the <a href="#manifest">manifest</a>,
94 or call the $(ref:browserAction.setIcon) method. 106 or call the $(ref:browserAction.setIcon) method.
95 </p> 107 </p>
96 108
97 <p>To properly display icon when screen pixel density (ratio 109 <p>To properly display icon when screen pixel density (ratio
98 <code>size_in_pixel / size_in_dip</code>) is different than 1, 110 <code>size_in_pixel / size_in_dip</code>) is different than 1,
99 the icon can be defined as set of images with different sizes. 111 the icon can be defined as set of images with different sizes.
100 The actual image to display will be selected from the set to 112 The actual image to display will be selected from the set to
101 best fit the pixel size of 19 dip icon. 113 best fit the pixel size of 16 dip.
102 At the moment, the icon set can contain images with pixel sizes 19 and 38. 114 The icon set can contain any size icon specification, and Chrome will
103 </p> 115 select the most appropriate one.
116 </p>
104 117
105 <h3 id="tooltip">Tooltip</h3> 118 <h3 id="tooltip">Tooltip</h3>
106 119
107 <p> 120 <p>
108 To set the tooltip, 121 To set the tooltip,
109 use the <b>default_title</b> field of <b>browser_action</b> 122 use the <b>default_title</b> field of <b>browser_action</b>
110 in the <a href="#manifest">manifest</a>, 123 in the <a href="#manifest">manifest</a>,
111 or call the $(ref:browserAction.setTitle) method. 124 or call the $(ref:browserAction.setTitle) method.
112 You can specify locale-specific strings for the <b>default_title</b> field; 125 You can specify locale-specific strings for the <b>default_title</b> field;
113 see <a href="i18n">Internationalization</a> for details. 126 see <a href="i18n">Internationalization</a> for details.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 <p>For the best visual impact, 168 <p>For the best visual impact,
156 follow these guidelines:</p> 169 follow these guidelines:</p>
157 170
158 <ul> 171 <ul>
159 <li><b>Do</b> use browser actions for features 172 <li><b>Do</b> use browser actions for features
160 that make sense on most pages. 173 that make sense on most pages.
161 <li><b>Don't</b> use browser actions for features 174 <li><b>Don't</b> use browser actions for features
162 that make sense for only a few pages. 175 that make sense for only a few pages.
163 Use <a href="pageAction">page actions</a> instead. 176 Use <a href="pageAction">page actions</a> instead.
164 <li><b>Do</b> use big, colorful icons that make the most of 177 <li><b>Do</b> use big, colorful icons that make the most of
165 the 38x38-pixel space. 178 the 16x16-dip space.
166 Browser action icons should seem a little bigger 179 Browser action icons should seem a little bigger
167 and heavier than page action icons. 180 and heavier than page action icons.
168 <li><b>Don't</b> attempt to mimic 181 <li><b>Don't</b> attempt to mimic
169 Google Chrome's monochrome menu icon. 182 Google Chrome's monochrome menu icon.
170 That doesn't work well with themes, and anyway, 183 That doesn't work well with themes, and anyway,
171 extensions should stand out a little. 184 extensions should stand out a little.
172 <li><b>Do</b> use alpha transparency 185 <li><b>Do</b> use alpha transparency
173 to add soft edges to your icon. 186 to add soft edges to your icon.
174 Because many people use themes, 187 Because many people use themes,
175 your icon should look nice 188 your icon should look nice
176 on a variety of background colors. 189 on a variety of background colors.
177 <li><b>Don't</b> constantly animate your icon. 190 <li><b>Don't</b> constantly animate your icon.
178 That's just annoying. 191 That's just annoying.
179 </ul> 192 </ul>
180 193
181 <h2 id="examples"> Examples </h2> 194 <h2 id="examples"> Examples </h2>
182 195
183 <p> 196 <p>
184 You can find simple examples of using browser actions in the 197 You can find simple examples of using browser actions in the
185 <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/e xtensions/docs/examples/api/browserAction/">examples/api/browserAction</a> 198 <a href="https://chromium.googlesource.com/chromium/src/+/master/chrome/common/e xtensions/docs/examples/api/browserAction/">examples/api/browserAction</a>
186 directory. 199 directory.
187 For other examples and for help in viewing the source code, see 200 For other examples and for help in viewing the source code, see
188 <a href="samples">Samples</a>. 201 <a href="samples">Samples</a>.
189 </p> 202 </p>
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/templates/intros/pageAction.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698