Index: chrome/browser/resources/extensions/extension_list.js |
diff --git a/chrome/browser/resources/extensions/extension_list.js b/chrome/browser/resources/extensions/extension_list.js |
index 012bc877c1db3980ea653d768cecf0e0f2b3cb95..e765a3e0355cd47a313f3762b3e5badd6471defc 100644 |
--- a/chrome/browser/resources/extensions/extension_list.js |
+++ b/chrome/browser/resources/extensions/extension_list.js |
@@ -33,6 +33,15 @@ cr.define('options', function() { |
ExtensionsList.prototype = { |
__proto__: HTMLDivElement.prototype, |
+ /** |
+ * Indicates whether an embedded options page that was navigated to through |
+ * the '?options=' URL query has been shown to the user. This is necessary |
+ * to prevent showExtensionNodes_ from opening the options more than once. |
+ * @type {boolean} |
+ * @private |
+ */ |
+ optionsShown_: false, |
+ |
/** @override */ |
decorate: function() { |
this.textContent = ''; |
@@ -44,6 +53,10 @@ cr.define('options', function() { |
return parseQueryParams(document.location)['id']; |
}, |
+ getOptionsQueryParam_: function() { |
+ return parseQueryParams(document.location)['options']; |
+ }, |
+ |
/** |
* Creates all extension items from scratch. |
* @private |
@@ -53,15 +66,14 @@ cr.define('options', function() { |
this.data_.extensions.forEach(this.createNode_, this); |
var idToHighlight = this.getIdQueryParam_(); |
- if (idToHighlight && $(idToHighlight)) { |
- // Scroll offset should be calculated slightly higher than the actual |
- // offset of the element being scrolled to, so that it ends up not all |
- // the way at the top. That way it is clear that there are more elements |
- // above the element being scrolled to. |
- var scrollFudge = 1.2; |
- var scrollTop = $(idToHighlight).offsetTop - scrollFudge * |
- $(idToHighlight).clientHeight; |
- setScrollTopForDocument(document, scrollTop); |
+ if (idToHighlight && $(idToHighlight)) |
+ this.scrollToNode_(idToHighlight); |
not at google - send to devlin
2014/08/25 18:11:07
I'm seeing some weird behaviour when you specify a
|
+ |
+ var idToOpenOptions = this.getOptionsQueryParam_(); |
+ if (idToOpenOptions && $(idToOpenOptions) && !this.optionsShown_) { |
+ this.scrollToNode_(idToOpenOptions); |
+ $(idToOpenOptions).querySelector('.options-link').click(); |
not at google - send to devlin
2014/08/25 18:11:07
Why clicking on this link? Seems kinda roundabout.
ericzeng
2014/08/25 21:42:34
Done.
|
+ this.optionsShown_ = true; |
} |
if (this.data_.extensions.length == 0) |
@@ -71,6 +83,22 @@ cr.define('options', function() { |
}, |
/** |
+ * Scrolls the page down to the extension node with the given id. |
+ * @param {string} extensionId The id of the extension to scroll to. |
+ * @private |
+ */ |
+ scrollToNode_: function(extensionId) { |
+ // Scroll offset should be calculated slightly higher than the actual |
+ // offset of the element being scrolled to, so that it ends up not all |
+ // the way at the top. That way it is clear that there are more elements |
+ // above the element being scrolled to. |
+ var scrollFudge = 1.2; |
+ var scrollTop = $(extensionId).offsetTop - scrollFudge * |
+ $(extensionId).clientHeight; |
+ setScrollTopForDocument(document, scrollTop); |
+ }, |
+ |
+ /** |
* Synthesizes and initializes an HTML element for the extension metadata |
* given in |extension|. |
* @param {Object} extension A dictionary of extension metadata. |
@@ -194,6 +222,15 @@ cr.define('options', function() { |
var options = node.querySelector('.options-link'); |
options.addEventListener('click', function(e) { |
if (this.data_.enableEmbeddedExtensionOptions) { |
+ // Add the options query string. |
not at google - send to devlin
2014/08/25 18:11:07
Mention why you need to postMessage here.
ericzeng
2014/08/25 21:42:34
Done.
|
+ window.parent.postMessage({ |
+ method: 'updateHistory', |
+ params: { |
+ state: {}, |
+ path: '?options=' + extension.id, |
+ replace: false |
not at google - send to devlin
2014/08/25 18:11:07
I think that clicking on an icon should replace th
ericzeng
2014/08/25 21:42:34
Replace state is done.
It looks like the crash is
|
+ } |
+ }, 'chrome://chrome'); |
extensions.ExtensionOptionsOverlay.getInstance(). |
setExtensionAndShowOverlay(extension.id, |
extension.name, |