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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/templates/articles/optionsV2.html
diff --git a/chrome/common/extensions/docs/templates/articles/optionsV2.html b/chrome/common/extensions/docs/templates/articles/optionsV2.html
index 51062587a8ce6fe5fa8efa62feb58d8e1f93b3d1..139f3e50ba8585a40485556a7259ecd5b5a7b2e1 100644
--- a/chrome/common/extensions/docs/templates/articles/optionsV2.html
+++ b/chrome/common/extensions/docs/templates/articles/optionsV2.html
@@ -134,30 +134,41 @@ hosted inside their own tabs.
</p>
<h3 id="linking">Linking to your options page</h3>
-<p>
-To link to your extension's options page, use a URL like
-<em style="white-space:nowrap">chrome://extensions<strong>?options=yourextensionid</strong></em>.
-This loads <em>chrome://extensions</em> then automatically opens your options
-page in a dialogue.
-<pre data-filename="popup.html">
-&lt;a href="chrome://extensions?options=aebdgjojlaaljcehfkjaknmlilmblnip"&gt;
- Go to options.
-&lt;/a&gt;
-</pre>
+<p>
+If you want to link to your options page, call
+<code>$(ref:runtime.openOptionsPage chrome.runtime.openOptionsPage())</code>.
+This has been available since Chrome 42.
</p>
<p>
-Of course, this is only supported in Chrome 40 onwards.
-</p>
+Linking directly to
+<em style="white-space:nowrap">chrome-extension://<strong>yourextensionid/youroptionspage.html</strong></em>
+will be a bad user experience. Linking directly to
+<em style="white-space:nowrap">chrome://extensions<strong>?options=yourextensionid</strong></em>
+isn't advisable either, as Chrome may change the embedding URL in the future.
<p>
-If you link to your options page directly with <em
-style="white-space:nowrap">chrome-extension://<strong>yourextensionid/youroptionspage.html</strong></em>,
-it will always open in its own tab. This is a bad user experience (but it can
-be useful in development).
+<code>$(ref:runtime.openOptionsPage chrome.runtime.openOptionsPage())</code>
+will always open the canonical location, and has nice behavior like re-focusing
+an open options page if there is one.
</p>
+<pre data-filename="popup.html">
+&lt;button id="go-to-options"&gt;Go to options&lt;/button&gt;
+</pre>
+<pre data-filename="popup.js">
+document.querySelector('#go-to-options').addEventListener(function() {
+ if (chrome.runtime.openOptionsPage) {
+ // New way to open options pages, if supported (Chrome 42+).
+ chrome.runtime.openOptionsPage();
+ } else {
+ // Reasonable fallback.
+ window.open(chrome.runtime.getURL('options.html'));
+ }
+});
+</pre>
+
<h3 id="tabs-api">Tabs API</h3>
<p>
Options page code cannot assume that it's hosted inside a tab, and this may
« 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