Index: chrome/browser/resources/options2/options_page.js |
diff --git a/chrome/browser/resources/options2/options_page.js b/chrome/browser/resources/options2/options_page.js |
index 7401694e4ac36ea58bd75543bc8f5e235f4ce79a..5355d15e8a62b080f6668c692744c120ec891920 100644 |
--- a/chrome/browser/resources/options2/options_page.js |
+++ b/chrome/browser/resources/options2/options_page.js |
@@ -72,15 +72,15 @@ cr.define('options', function() { |
* @param {string} pageName Page name. |
* @param {boolean} updateHistory True if we should update the history after |
* showing the page. |
- * @param {Object=} opt_propertyBag An optional bag of properties including |
- * replaceState (if history state should be replaced instead of pushed). |
+ * @param {{replaceState: (boolean|undefined), hash: (string|undefined)}=} |
+ * opt_historyOptions An optional bag of history behavior modifiers. |
* @private |
*/ |
OptionsPage.showPageByName = function(pageName, |
updateHistory, |
- opt_propertyBag) { |
+ opt_historyOptions) { |
// If |opt_propertyBag| is non-truthy, homogenize to object. |
- opt_propertyBag = opt_propertyBag || {}; |
+ opt_historyOptions = opt_historyOptions || {}; |
// Find the currently visible root-level page. |
var rootPage = null; |
@@ -97,8 +97,10 @@ cr.define('options', function() { |
if (!targetPage || !targetPage.canShowPage()) { |
// If it's not a page, try it as an overlay. |
if (!targetPage && this.showOverlay_(pageName, rootPage)) { |
- if (updateHistory) |
- this.updateHistoryState_(!!opt_propertyBag.replaceState); |
+ if (updateHistory) { |
+ this.updateHistoryState_(!!opt_historyOptions.replaceState, |
+ {hash: opt_historyOptions.hash}); |
+ } |
return; |
} else { |
targetPage = this.getDefaultPage(); |
@@ -142,8 +144,10 @@ cr.define('options', function() { |
} |
// Update the history and current location. |
- if (updateHistory) |
- this.updateHistoryState_(!!opt_propertyBag.replaceState); |
+ if (updateHistory) { |
+ this.updateHistoryState_( |
+ !!opt_historyOptions.replaceState, {hash: opt_historyOptions.hash}); |
+ } |
// Update tab title. |
this.setTitle_(targetPage.title); |
@@ -204,7 +208,19 @@ cr.define('options', function() { |
return; |
} |
- var hash = opt_params && opt_params.ignoreHash ? '' : window.location.hash; |
+ opt_params = opt_params || {}; |
+ assert(!(opt_params.ignoreHash && opt_params.hash), |
+ 'mutually exclusive hash params given to updateHistoryState_'); |
+ |
+ var hash = ''; |
+ if (!opt_params.ignoreHash) { |
+ if (opt_params.hash) { |
+ assert('#' == opt_params.hash.substr(0, 1)); |
+ hash = opt_params.hash; |
+ } else { |
+ hash = window.location.hash; |
+ } |
+ } |
// If settings are embedded, tell the outer page to set its "path" to the |
// inner frame's path. |