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 var localStrings = new LocalStrings(); | 6 var localStrings = new LocalStrings(); |
7 | 7 |
8 /** | 8 /** |
9 * Options for how web history should be handled. | 9 * Options for how web history should be handled. |
10 */ | 10 */ |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, HISTORY_STATE_OPTION.PUSH); |
139 else if (e.data.method === 'navigationControlsLoaded') | 139 else if (e.data.method === 'navigationControlsLoaded') |
140 onNavigationControlsLoaded(); | 140 onNavigationControlsLoaded(); |
| 141 else if (e.data.method === 'enableNavigationItemTabbing') |
| 142 setNavigationItemTabbing(true); |
| 143 else if (e.data.method === 'disableNavigationItemTabbing') |
| 144 setNavigationItemTabbing(false); |
141 else if (e.data.method === 'adjustToScroll') | 145 else if (e.data.method === 'adjustToScroll') |
142 adjustToScroll(e.data.params); | 146 adjustToScroll(e.data.params); |
143 else if (e.data.method === 'mouseWheel') | 147 else if (e.data.method === 'mouseWheel') |
144 forwardMouseWheel(e.data.params); | 148 forwardMouseWheel(e.data.params); |
145 else | 149 else |
146 console.error('Received unexpected message', e.data); | 150 console.error('Received unexpected message', e.data); |
147 } | 151 } |
148 | 152 |
149 /** | 153 /** |
150 * Sends the navigation iframe to the background. | 154 * Sends the navigation iframe to the background. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 327 |
324 /** | 328 /** |
325 * Forward scroll wheel events to subpages. | 329 * Forward scroll wheel events to subpages. |
326 * @param {Object} params Relevant parameters of wheel event. | 330 * @param {Object} params Relevant parameters of wheel event. |
327 */ | 331 */ |
328 function forwardMouseWheel(params) { | 332 function forwardMouseWheel(params) { |
329 var iframe = getSelectedIframe().querySelector('iframe'); | 333 var iframe = getSelectedIframe().querySelector('iframe'); |
330 uber.invokeMethodOnWindow(iframe.contentWindow, 'mouseWheel', params); | 334 uber.invokeMethodOnWindow(iframe.contentWindow, 'mouseWheel', params); |
331 } | 335 } |
332 | 336 |
| 337 /** |
| 338 * Enables or disables the ability to tab to the navigation items. |
| 339 * @param {boolean} enabled If true, enables tabbing; if false, disables it. |
| 340 */ |
| 341 function setNavigationItemTabbing(enabled) { |
| 342 navFrame.firstChild.tabIndex = enabled ? 0 : -1; |
| 343 if (enabled) |
| 344 navFrame.firstChild.removeAttribute('aria-hidden'); |
| 345 else |
| 346 navFrame.firstChild.setAttribute('aria-hidden', true); |
| 347 } |
| 348 |
333 return { | 349 return { |
334 onLoad: onLoad, | 350 onLoad: onLoad, |
335 onPopHistoryState: onPopHistoryState | 351 onPopHistoryState: onPopHistoryState |
336 }; | 352 }; |
337 }); | 353 }); |
338 | 354 |
339 window.addEventListener('popstate', uber.onPopHistoryState); | 355 window.addEventListener('popstate', uber.onPopHistoryState); |
340 document.addEventListener('DOMContentLoaded', uber.onLoad); | 356 document.addEventListener('DOMContentLoaded', uber.onLoad); |
OLD | NEW |