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

Unified Diff: chrome/browser/resources/uber/uber.js

Issue 9325005: Merge 120006 - [uber page] Fix url handling for uber-page sub-paths. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1025/src/
Patch Set: Created 8 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/uber/uber.js
===================================================================
--- chrome/browser/resources/uber/uber.js (revision 120231)
+++ chrome/browser/resources/uber/uber.js (working copy)
@@ -25,18 +25,11 @@
* Handles page initialization.
*/
function onLoad(e) {
- // If the pathname points to a sub-page, we may need to alter the location
- // of one of the frames.
- var params = resolvePageInfoFromPath(window.location.pathname);
- if (params.path) {
- var iframe = $(params.id).querySelector('iframe');
- iframe.contentWindow.location.replace(iframe.src + params.path);
- }
-
navFrame = $('navigation');
// Select a page based on the page-URL.
- showPage(params.id, HISTORY_STATE_OPTION.REPLACE);
+ var params = resolvePageInfoFromPath(window.location.pathname);
+ showPage(params.id, HISTORY_STATE_OPTION.REPLACE, params.path);
window.addEventListener('message', handleWindowMessage);
window.setTimeout(function() {
@@ -190,8 +183,9 @@
* @param {String} pageId Should matche an id of one of the iframe containers.
* @param {integer} historyOption Indicates whether we should push or replace
* browser history.
+ * @param {String=} path An optional sub-page path.
*/
- function showPage(pageId, historyOption) {
+ function showPage(pageId, historyOption, path) {
var container = $(pageId);
var lastSelected = document.querySelector('.iframe-container.selected');
if (lastSelected === container)
@@ -199,8 +193,12 @@
// Lazy load of iframe contents.
var frame = container.querySelector('iframe');
+ var sourceURL = frame.dataset.url;
if (!frame.getAttribute('src'))
- frame.setAttribute('src', frame.dataset.url);
+ frame.src = sourceURL;
+ // If there is a non-empty path, alter the location of the frame.
+ if (path && path.length)
+ frame.contentWindow.location.replace(sourceURL + path);
if (lastSelected)
lastSelected.classList.remove('selected');
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698