OLD | NEW |
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 * { method : "methodToInvoke", | 119 * { method : "methodToInvoke", |
120 * params : {...} | 120 * params : {...} |
121 * } | 121 * } |
122 * | 122 * |
123 * |method| is required, while |params| is optional. Extra parameters required | 123 * |method| is required, while |params| is optional. Extra parameters required |
124 * by a method must be specified by that method's documentation. | 124 * by a method must be specified by that method's documentation. |
125 * | 125 * |
126 * @param {Event} e The posted object. | 126 * @param {Event} e The posted object. |
127 */ | 127 */ |
128 function handleWindowMessage(e) { | 128 function handleWindowMessage(e) { |
129 if (e.data.method === 'beginInterceptingEvents') | 129 if (e.data.method === 'beginInterceptingEvents') { |
130 backgroundNavigation(); | 130 backgroundNavigation(); |
131 else if (e.data.method === 'stopInterceptingEvents') | 131 } else if (e.data.method === 'stopInterceptingEvents') { |
132 foregroundNavigation(); | 132 foregroundNavigation(); |
133 else if (e.data.method === 'setPath') | 133 } else if (e.data.method === 'setPath') { |
134 setPath(e.origin, e.data.params.path); | 134 setPath(e.origin, e.data.params.path); |
135 else if (e.data.method === 'setTitle') | 135 } else if (e.data.method === 'setTitle') { |
136 setTitle(e.origin, e.data.params.title); | 136 setTitle(e.origin, e.data.params.title); |
137 else if (e.data.method === 'showPage') | 137 } else if (e.data.method === 'showPage') { |
138 showPage(e.data.params.pageId, HISTORY_STATE_OPTION.PUSH); | 138 showPage(e.data.params.pageId, |
139 else if (e.data.method === 'navigationControlsLoaded') | 139 HISTORY_STATE_OPTION.PUSH, |
| 140 e.data.params.path); |
| 141 } else if (e.data.method === 'navigationControlsLoaded') { |
140 onNavigationControlsLoaded(); | 142 onNavigationControlsLoaded(); |
141 else if (e.data.method === 'adjustToScroll') | 143 } else if (e.data.method === 'adjustToScroll') { |
142 adjustToScroll(e.data.params); | 144 adjustToScroll(e.data.params); |
143 else if (e.data.method === 'mouseWheel') | 145 } else if (e.data.method === 'mouseWheel') { |
144 forwardMouseWheel(e.data.params); | 146 forwardMouseWheel(e.data.params); |
145 else | 147 } else { |
146 console.error('Received unexpected message', e.data); | 148 console.error('Received unexpected message', e.data); |
| 149 } |
147 } | 150 } |
148 | 151 |
149 /** | 152 /** |
150 * Sends the navigation iframe to the background. | 153 * Sends the navigation iframe to the background. |
151 */ | 154 */ |
152 function backgroundNavigation() { | 155 function backgroundNavigation() { |
153 navFrame.classList.add('background'); | 156 navFrame.classList.add('background'); |
154 navFrame.firstChild.tabIndex = -1; | 157 navFrame.firstChild.tabIndex = -1; |
155 navFrame.firstChild.setAttribute('aria-hidden', true); | 158 navFrame.firstChild.setAttribute('aria-hidden', true); |
156 } | 159 } |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 377 } |
375 | 378 |
376 return { | 379 return { |
377 onLoad: onLoad, | 380 onLoad: onLoad, |
378 onPopHistoryState: onPopHistoryState | 381 onPopHistoryState: onPopHistoryState |
379 }; | 382 }; |
380 }); | 383 }); |
381 | 384 |
382 window.addEventListener('popstate', uber.onPopHistoryState); | 385 window.addEventListener('popstate', uber.onPopHistoryState); |
383 document.addEventListener('DOMContentLoaded', uber.onLoad); | 386 document.addEventListener('DOMContentLoaded', uber.onLoad); |
OLD | NEW |