summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/options2/options_page.js
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-12 18:08:44 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-12 18:08:44 +0000
commitee32686fbe0700957a93ffc34cd344297a7e0ee0 (patch)
tree81f16d149052e45ed659929fd02c68ffed115a8b /chrome/browser/resources/options2/options_page.js
parentb1947f5b76c636e2ba6277c5bbeed3c2083a9ea2 (diff)
downloadchromium_src-ee32686fbe0700957a93ffc34cd344297a7e0ee0.zip
chromium_src-ee32686fbe0700957a93ffc34cd344297a7e0ee0.tar.gz
chromium_src-ee32686fbe0700957a93ffc34cd344297a7e0ee0.tar.bz2
UberPage: Add an API to set the title of the page.
Use it in Settings. BUG=109364 TEST=none R=csilv@chromium.org,estade@chromium.org Review URL: http://codereview.chromium.org/9139043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117451 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/options2/options_page.js')
-rw-r--r--chrome/browser/resources/options2/options_page.js42
1 files changed, 36 insertions, 6 deletions
diff --git a/chrome/browser/resources/options2/options_page.js b/chrome/browser/resources/options2/options_page.js
index 71cf936..7da0447 100644
--- a/chrome/browser/resources/options2/options_page.js
+++ b/chrome/browser/resources/options2/options_page.js
@@ -133,7 +133,7 @@ cr.define('options', function() {
this.updateHistoryState_();
// Always update the page title.
- document.title = targetPage.title;
+ this.setTitle_(targetPage.title);
// Notify pages if they were shown.
for (var name in this.registeredPages) {
@@ -181,6 +181,38 @@ cr.define('options', function() {
};
/**
+ * Invokes a method on the parent window. This is a convenience method for
+ * API calls into the parent.
+ * @param {String} method The name of the method to invoke.
+ * @param {Object} params Optional property bag of parameters to pass to the
+ * invoked method.
+ * @private
+ */
+ OptionsPage.invokeMethodOnParent_ = function(method, params) {
+ if (!window.parent)
+ return;
+
+ var data = new Object;
+ data.method = method;
+
+ // Copy the attributes in |params| over to |data|.
+ for (var attr in params)
+ data[attr] = params[attr];
+
+ window.parent.postMessage(data, 'chrome://chrome');
+ };
+
+ /**
+ * Sets the title of the page. This is accomplished by calling into the
+ * parent page API.
+ * @param {String} title The title string.
+ * @private
+ */
+ OptionsPage.setTitle_ = function(title) {
+ this.invokeMethodOnParent_('setTitle', {title: title});
+ };
+
+ /**
* Updates the visibility and stacking order of the subpage backdrop
* according to which subpage is topmost and visible.
* @private
@@ -241,7 +273,7 @@ cr.define('options', function() {
page.title,
'/' + page.name);
// Update tab title.
- document.title = page.title;
+ this.setTitle_(page.title);
};
/**
@@ -263,8 +295,7 @@ cr.define('options', function() {
if (overlay.didShowPage) overlay.didShowPage();
}
- if (window.parent)
- window.parent.postMessage('showOverlay', 'chrome://chrome');
+ this.invokeMethodOnParent_('showOverlay');
return true;
};
@@ -301,8 +332,7 @@ cr.define('options', function() {
return;
overlay.visible = false;
- if (window.parent)
- window.parent.postMessage('hideOverlay', 'chrome://chrome');
+ this.invokeMethodOnParent_('hideOverlay');
if (overlay.didClosePage) overlay.didClosePage();
this.updateHistoryState_();