diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-14 00:13:49 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-14 00:13:49 +0000 |
commit | edad1b14f8cd0afa402fcdc99e27612496540c3a (patch) | |
tree | 7238492d24e665ee04818bfb475e1f866b256540 | |
parent | 942efaa6d01c225e3771cd49d9baabaf24de67f6 (diff) | |
download | chromium_src-edad1b14f8cd0afa402fcdc99e27612496540c3a.zip chromium_src-edad1b14f8cd0afa402fcdc99e27612496540c3a.tar.gz chromium_src-edad1b14f8cd0afa402fcdc99e27612496540c3a.tar.bz2 |
UberPage: Simplify caching of the title.
BUG=none
TEST=none
R=csilv@chromium.org,estade@chromium.org
Review URL: http://codereview.chromium.org/9174015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117733 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/options/options_bundle.js | 4 | ||||
-rw-r--r-- | chrome/browser/resources/options2/options_bundle.js | 4 | ||||
-rw-r--r-- | chrome/browser/resources/options2/options_page.js | 21 | ||||
-rw-r--r-- | chrome/browser/resources/uber/uber.js | 29 |
4 files changed, 14 insertions, 44 deletions
diff --git a/chrome/browser/resources/options/options_bundle.js b/chrome/browser/resources/options/options_bundle.js index f28b9da..0298858 100644 --- a/chrome/browser/resources/options/options_bundle.js +++ b/chrome/browser/resources/options/options_bundle.js @@ -71,8 +71,8 @@ <include src="extension_settings.js"></include> <include src="font_settings.js"></include> <if expr="pp_ifdef('enable_register_protocol_handler')"> - <include src="handler_options.js"></script> - <include src="handler_options_list.js"></script> + <include src="handler_options.js"></include> + <include src="handler_options_list.js"></include> </if> <include src="import_data_overlay.js"></include> <include src="instant_confirm_overlay.js"></include> diff --git a/chrome/browser/resources/options2/options_bundle.js b/chrome/browser/resources/options2/options_bundle.js index c4ed778..cd08786 100644 --- a/chrome/browser/resources/options2/options_bundle.js +++ b/chrome/browser/resources/options2/options_bundle.js @@ -71,8 +71,8 @@ <include src="cookies_view.js"></include> <include src="font_settings.js"></include> <if expr="pp_ifdef('enable_register_protocol_handler')"> - <include src="handler_options.js"></script> - <include src="handler_options_list.js"></script> + <include src="handler_options.js"></include> + <include src="handler_options_list.js"></include> </if> <include src="home_page_overlay.js"></include> <include src="import_data_overlay.js"></include> diff --git a/chrome/browser/resources/options2/options_page.js b/chrome/browser/resources/options2/options_page.js index a092825..9955e6c 100644 --- a/chrome/browser/resources/options2/options_page.js +++ b/chrome/browser/resources/options2/options_page.js @@ -46,13 +46,6 @@ cr.define('options', function() { OptionsPage.initialized_ = false; /** - * The current title. Used to update the parent container's title when this - * page is activated. - * @private - */ - OptionsPage.title_ = ''; - - /** * Gets the default page (to be shown on initial load). */ OptionsPage.getDefaultPage = function() { @@ -194,7 +187,6 @@ cr.define('options', function() { * @private */ OptionsPage.setTitle_ = function(title) { - this.title_ = title; uber.invokeMethodOnParent('setTitle', {title: title}); }; @@ -631,7 +623,6 @@ cr.define('options', function() { document.addEventListener('scroll', this.handleScroll_.bind(this)); window.addEventListener('resize', this.handleResize_.bind(this)); - window.addEventListener('message', this.handleWindowMessage_.bind(this)); if (!document.documentElement.classList.contains('hide-menu')) { // Close subpages if the user clicks on the html body. Listen in the @@ -678,18 +669,6 @@ cr.define('options', function() { }; /** - * Handles postMessage calls from the container of this page. - * @param {Event} e The posted object. - * @private - */ - OptionsPage.handleWindowMessage_ = function(e) { - if (e.data === 'onPageActivated') - uber.invokeMethodOnParent('setTitle', {title: this.title_}); - else - console.error('Received unexpected message: ' + e.data); - }, - - /** * Does a bounds check for the element on the given x, y client coordinates. * @param {Element} e The DOM element. * @param {number} x The client X to check. diff --git a/chrome/browser/resources/uber/uber.js b/chrome/browser/resources/uber/uber.js index ea6659e..a55a6ef 100644 --- a/chrome/browser/resources/uber/uber.js +++ b/chrome/browser/resources/uber/uber.js @@ -5,13 +5,6 @@ cr.define('uber', function() { /** - * Map from |iframe.src| to the title of |iframe|, cached so the contained - * pages don't have to update the title on each activation. - * @private - */ - var titleMap_ = {}; - - /** * Handles page initialization. */ function onLoad() { @@ -63,10 +56,8 @@ cr.define('uber', function() { return false; // Restore the cached title. - var iframeEl = iframe.querySelector('iframe'); - var title = titleMap_[iframeEl.src]; - if (title) - document.title = title; + if (iframe.title) + document.title = iframe.title; currentIframe.classList.remove('selected'); iframe.classList.add('selected'); @@ -142,19 +133,19 @@ cr.define('uber', function() { * @private */ function setTitle_(origin, params) { - var container = getSelectedIframe_(); - var iframe = container.querySelector('iframe'); - // |iframe.src| always contains a trailing backslash while |origin| does not // so add the trailing source for normalization. - origin += '/'; + var query = '.iframe-container > iframe[src="' + origin + '/"]'; + + // Cache the title for the client iframe, i.e., the iframe setting the + // title. querySelector returns the actual iframe element, so use parentNode + // to get back to the container. + var container = document.querySelector(query).parentNode; + container.title = params.title; // Only update the currently displayed title if this is the visible frame. - if (iframe.src === origin) + if (container == getSelectedIframe_()) document.title = params.title; - - // Cache the title for the selected iframe. - titleMap_[origin] = params.title; } return { |