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

Side by Side Diff: chrome/browser/resources/uber/uber.js

Issue 2894923002: Fix dataset type conversion bug in uber.js (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('uber', function() { 5 cr.define('uber', function() {
6 /** 6 /**
7 * Options for how web history should be handled. 7 * Options for how web history should be handled.
8 */ 8 */
9 var HISTORY_STATE_OPTION = { 9 var HISTORY_STATE_OPTION = {
10 PUSH: 1, // Push a new history state. 10 PUSH: 1, // Push a new history state.
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 /** 290 /**
291 * Invokes a method on a subpage. If the subpage has not signaled readiness, 291 * Invokes a method on a subpage. If the subpage has not signaled readiness,
292 * queue the message for when it does. 292 * queue the message for when it does.
293 * @param {string} pageId Should match an id of one of the iframe containers. 293 * @param {string} pageId Should match an id of one of the iframe containers.
294 * @param {string} method The name of the method to invoke. 294 * @param {string} method The name of the method to invoke.
295 * @param {Object=} opt_params Optional property page of parameters to pass to 295 * @param {Object=} opt_params Optional property page of parameters to pass to
296 * the invoked method. 296 * the invoked method.
297 */ 297 */
298 function invokeMethodOnPage(pageId, method, opt_params) { 298 function invokeMethodOnPage(pageId, method, opt_params) {
299 var frame = $(pageId).querySelector('iframe'); 299 var frame = $(pageId).querySelector('iframe');
300 if (!frame || !frame.dataset.ready) { 300 if (!frame || !frame.hasAttribute('ready')) {
301 queuedInvokes[pageId] = (queuedInvokes[pageId] || []); 301 queuedInvokes[pageId] = (queuedInvokes[pageId] || []);
302 queuedInvokes[pageId].push([method, opt_params]); 302 queuedInvokes[pageId].push([method, opt_params]);
303 } else { 303 } else {
304 uber.invokeMethodOnWindow(frame.contentWindow, method, opt_params); 304 uber.invokeMethodOnWindow(frame.contentWindow, method, opt_params);
305 } 305 }
306 } 306 }
307 307
308 /** 308 /**
309 * Called in response to a page declaring readiness. Calls any deferred method 309 * Called in response to a page declaring readiness. Calls any deferred method
310 * invocations from invokeMethodOnPage. 310 * invocations from invokeMethodOnPage.
311 * @param {string} origin The origin of the source iframe. 311 * @param {string} origin The origin of the source iframe.
312 */ 312 */
313 function pageReady(origin) { 313 function pageReady(origin) {
314 var frame = getIframeFromOrigin(origin); 314 var frame = getIframeFromOrigin(origin);
315 var container = frame.parentNode; 315 var container = frame.parentNode;
316 frame.dataset.ready = true; 316 frame.setAttribute('ready', '');
317 var queue = queuedInvokes[container.id] || []; 317 var queue = queuedInvokes[container.id] || [];
318 queuedInvokes[container.id] = undefined; 318 queuedInvokes[container.id] = undefined;
319 for (var i = 0; i < queue.length; i++) { 319 for (var i = 0; i < queue.length; i++) {
320 uber.invokeMethodOnWindow(frame.contentWindow, queue[i][0], queue[i][1]); 320 uber.invokeMethodOnWindow(frame.contentWindow, queue[i][0], queue[i][1]);
321 } 321 }
322 } 322 }
323 323
324 /** 324 /**
325 * Selects and navigates a subpage. This is called from uber-frame. 325 * Selects and navigates a subpage. This is called from uber-frame.
326 * @param {string} pageId Should match an id of one of the iframe containers. 326 * @param {string} pageId Should match an id of one of the iframe containers.
(...skipping 11 matching lines...) Expand all
338 frame = container.ownerDocument.createElement('iframe'); 338 frame = container.ownerDocument.createElement('iframe');
339 frame.name = pageId; 339 frame.name = pageId;
340 frame.setAttribute('role', 'presentation'); 340 frame.setAttribute('role', 'presentation');
341 container.appendChild(frame); 341 container.appendChild(frame);
342 frame.src = sourceUrl; 342 frame.src = sourceUrl;
343 } else { 343 } else {
344 // There's no particularly good way to know what the current URL of the 344 // There's no particularly good way to know what the current URL of the
345 // content frame is as we don't have access to its contentWindow's 345 // content frame is as we don't have access to its contentWindow's
346 // location, so just replace every time until necessary to do otherwise. 346 // location, so just replace every time until necessary to do otherwise.
347 frame.contentWindow.location.replace(sourceUrl); 347 frame.contentWindow.location.replace(sourceUrl);
348 frame.dataset.ready = false; 348 frame.removeAttribute('ready');
349 } 349 }
350 350
351 // If the last selected container is already showing, ignore the rest. 351 // If the last selected container is already showing, ignore the rest.
352 var lastSelected = document.querySelector('.iframe-container.selected'); 352 var lastSelected = document.querySelector('.iframe-container.selected');
353 if (lastSelected === container) 353 if (lastSelected === container)
354 return; 354 return;
355 355
356 if (lastSelected) { 356 if (lastSelected) {
357 lastSelected.classList.remove('selected'); 357 lastSelected.classList.remove('selected');
358 // Setting aria-hidden hides the container from assistive technology 358 // Setting aria-hidden hides the container from assistive technology
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } 467 }
468 468
469 return { 469 return {
470 onLoad: onLoad, 470 onLoad: onLoad,
471 onPopHistoryState: onPopHistoryState 471 onPopHistoryState: onPopHistoryState
472 }; 472 };
473 }); 473 });
474 474
475 window.addEventListener('popstate', uber.onPopHistoryState); 475 window.addEventListener('popstate', uber.onPopHistoryState);
476 document.addEventListener('DOMContentLoaded', uber.onLoad); 476 document.addEventListener('DOMContentLoaded', uber.onLoad);
OLDNEW
« 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