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

Side by Side Diff: chrome/common/extensions/docs/templates/articles/optionsV2.html

Issue 1084873003: Update extension docs for options V2 to mention chrome.runtime.openOptionsPage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 8 months 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <h1>Options</h1> 1 <h1>Options</h1>
2 2
3 <p class="warning"> 3 <p class="warning">
4 This new way of writing options is only supported from Chrome 40 onwards. 4 This new way of writing options is only supported from Chrome 40 onwards.
5 <a href="options">See the old documentation</a>, or you can 5 <a href="options">See the old documentation</a>, or you can
6 <a href="#migration">start migrating now</a>. 6 <a href="#migration">start migrating now</a>.
7 </p> 7 </p>
8 8
9 <p> 9 <p>
10 To allow users to customize the behavior of your extension, you may wish to 10 To allow users to customize the behavior of your extension, you may wish to
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 127
128 <h2 id="considerations">Considerations</h2> 128 <h2 id="considerations">Considerations</h2>
129 129
130 <p> 130 <p>
131 Options pages embedded inside <em>chrome://extensions</em> have some subtle 131 Options pages embedded inside <em>chrome://extensions</em> have some subtle
132 behavior you should consider while writing them, mostly caused by not being 132 behavior you should consider while writing them, mostly caused by not being
133 hosted inside their own tabs. 133 hosted inside their own tabs.
134 </p> 134 </p>
135 135
136 <h3 id="linking">Linking to your options page</h3> 136 <h3 id="linking">Linking to your options page</h3>
137
137 <p> 138 <p>
138 To link to your extension's options page, use a URL like 139 If you want to link to your options page, call
139 <em style="white-space:nowrap">chrome://extensions<strong>?options=yourextension id</strong></em>. 140 <code>$(ref:runtime.openOptionsPage chrome.runtime.openOptionsPage())</code>.
140 This loads <em>chrome://extensions</em> then automatically opens your options 141 This has been available since Chrome 42.
141 page in a dialogue.
142
143 <pre data-filename="popup.html">
144 &lt;a href="chrome://extensions?options=aebdgjojlaaljcehfkjaknmlilmblnip"&gt;
145 Go to options.
146 &lt;/a&gt;
147 </pre>
148 </p> 142 </p>
149 143
150 <p> 144 <p>
151 Of course, this is only supported in Chrome 40 onwards. 145 Linking directly to
146 <em style="white-space:nowrap">chrome-extension://<strong>yourextensionid/yourop tionspage.html</strong></em>
147 will be a bad user experience. Linking directly to
148 <em style="white-space:nowrap">chrome://extensions<strong>?options=yourextension id</strong></em>
149 isn't advisable either, as Chrome may change the embedding URL in the future.
150
151 <p>
152 <code>$(ref:runtime.openOptionsPage chrome.runtime.openOptionsPage())</code>
153 will always open the canonical location, and has nice behavior like re-focusing
154 an open options page if there is one.
152 </p> 155 </p>
153 156
154 <p> 157 <pre data-filename="popup.html">
155 If you link to your options page directly with <em 158 &lt;button id="go-to-options"&gt;Go to options&lt;/button&gt;
156 style="white-space:nowrap">chrome-extension://<strong>yourextensionid/youroption spage.html</strong></em>, 159 </pre>
157 it will always open in its own tab. This is a bad user experience (but it can 160 <pre data-filename="popup.js">
158 be useful in development). 161 document.querySelector('#go-to-options').addEventListener(function() {
159 </p> 162 if (chrome.runtime.openOptionsPage) {
163 // New way to open options pages, if supported (Chrome 42+).
164 chrome.runtime.openOptionsPage();
165 } else {
166 // Reasonable fallback.
167 window.open(chrome.runtime.getURL('options.html'));
168 }
169 });
170 </pre>
160 171
161 <h3 id="tabs-api">Tabs API</h3> 172 <h3 id="tabs-api">Tabs API</h3>
162 <p> 173 <p>
163 Options page code cannot assume that it's hosted inside a tab, and this may 174 Options page code cannot assume that it's hosted inside a tab, and this may
164 affect how the $(ref:tabs Tabs API) can be used. For example, 175 affect how the $(ref:tabs Tabs API) can be used. For example,
165 <ul> 176 <ul>
166 <li>$(ref:tabs.query) will never find a tab with your extension's options 177 <li>$(ref:tabs.query) will never find a tab with your extension's options
167 page URL.</li> 178 page URL.</li>
168 <li>$(ref:tabs.onCreated) will not fire when your options page is 179 <li>$(ref:tabs.onCreated) will not fire when your options page is
169 opened.</li> 180 opened.</li>
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 <p> 252 <p>
242 If you specify both, Chrome 40 and onwards will ignore the value of 253 If you specify both, Chrome 40 and onwards will ignore the value of
243 <code>options_page</code>. 254 <code>options_page</code>.
244 </p> 255 </p>
245 <p> 256 <p>
246 In a future version of Chrome, any extension which specifies 257 In a future version of Chrome, any extension which specifies
247 <code>options_page</code> will change to match the <code>options_ui</code> 258 <code>options_page</code> will change to match the <code>options_ui</code>
248 behavior - most importantly, they will always be embedded in 259 behavior - most importantly, they will always be embedded in
249 <em>chrome://extensions</em> - so migrate as soon as possible. 260 <em>chrome://extensions</em> - so migrate as soon as possible.
250 </p> 261 </p>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698