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

Unified Diff: chrome/browser/resources/options/options_page.js

Issue 6480039: chrome://settings - Provide method for pages to prevent themselves being shown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: other cases Created 9 years, 10 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
Index: chrome/browser/resources/options/options_page.js
diff --git a/chrome/browser/resources/options/options_page.js b/chrome/browser/resources/options/options_page.js
index 7ab09caafc72583256290ceb4f565e33a14f7a9d..efbeea3ee50ba8ee635b7bd95d2fa9dc9bac3252 100644
--- a/chrome/browser/resources/options/options_page.js
+++ b/chrome/browser/resources/options/options_page.js
@@ -43,10 +43,17 @@ cr.define('options', function() {
OptionsPage.initialized_ = false;
/**
+ * Gets the default page (to be shown on initial load).
+ */
+ OptionsPage.getDefaultPage = function() {
+ return BrowserOptions.getInstance();
+ };
+
+ /**
* Shows the default page.
*/
OptionsPage.showDefaultPage = function() {
- this.navigateToPage(BrowserOptions.getInstance().name);
+ this.navigateToPage(this.getDefaultPage().name);
};
/**
@@ -67,13 +74,19 @@ cr.define('options', function() {
*/
OptionsPage.showPageByName = function(pageName, updateHistory) {
var targetPage = this.registeredPages[pageName];
- if (!targetPage) {
- this.showOverlay_(pageName);
- if (updateHistory)
- this.updateHistoryState_();
- return;
+ if (!targetPage || !targetPage.canShowPage()) {
+ // If it's not a page, try it as an overlay.
+ if (this.showOverlay_(pageName)) {
stuartmorgan 2011/02/12 01:09:06 Change to |if (!targetPage && this.showOverlay_(pa
Evan Stade 2011/02/12 03:06:42 Done.
+ if (updateHistory)
+ this.updateHistoryState_();
+ return;
+ } else {
+ targetPage = this.getDefaultPage();
+ }
}
+ pageName = targetPage.name;
stuartmorgan 2011/02/12 01:09:06 Setting paramaters generally makes code harder to
Evan Stade 2011/02/12 03:06:42 on the other hand, I don't want someone coming in
+
// Determine if the root page is 'sticky', meaning that it
// shouldn't change when showing a sub-page. This can happen for special
// pages like Search.
@@ -149,27 +162,20 @@ cr.define('options', function() {
};
/**
- * Called on load. Dispatch the URL hash to the given page's handleHash
- * function.
- * @param {string} pageName The string name of the (registered) options page.
- * @param {string} hash The value of the hash component of the URL.
- */
- OptionsPage.handleHashForPage = function(pageName, hash) {
- var page = this.registeredPages[pageName];
- page.handleHash(hash);
- };
-
- /**
* Shows a registered Overlay page. Does not update history.
* @param {string} overlayName Page name.
+ * @return {boolean} whether we showed an overlay.
*/
OptionsPage.showOverlay_ = function(overlayName) {
var overlay = this.registeredOverlayPages[overlayName];
+ if (!overlay || !overlay.canShowPage())
+ return false;
if (overlay.parentPage)
this.showPageByName(overlay.parentPage.name, false);
this.registeredOverlayPages[overlayName].visible = true;
+ return true;
};
/**
@@ -726,11 +732,11 @@ cr.define('options', function() {
},
/**
- * Handles a hash value in the URL (such as bar in
- * chrome://options/foo#bar). Called on page load.
- * @param {string} hash The hash value.
+ * Whether it should be possible to show the page.
+ * @return {boolean} True if the page should be shown
*/
- handleHash: function(hash) {
+ canShowPage: function() {
+ return true;
},
};

Powered by Google App Engine
This is Rietveld 408576698