| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 /** | 5 /** |
| 6 * @fileoverview Navigation related APIs. | 6 * @fileoverview Navigation related APIs. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 goog.provide('__crWeb.navigation'); | 9 goog.provide('__crWeb.navigation'); |
| 10 | 10 |
| 11 goog.require('__crWeb.common'); |
| 11 goog.require('__crWeb.message'); | 12 goog.require('__crWeb.message'); |
| 12 | 13 |
| 13 /** Beginning of anonymouse object */ | 14 /** Beginning of anonymouse object */ |
| 14 (function() { | 15 (function() { |
| 15 | 16 |
| 16 /** | 17 /** |
| 17 * A popstate event needs to be fired anytime the active history entry | 18 * A popstate event needs to be fired anytime the active history entry |
| 18 * changes without an associated document change. Either via back, forward, go | 19 * changes without an associated document change. Either via back, forward, go |
| 19 * navigation or by loading the URL, clicking on a link, etc. | 20 * navigation or by loading the URL, clicking on a link, etc. |
| 20 */ | 21 */ |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 originalWindowHistoryReplaceState.call(history, stateObject, | 111 originalWindowHistoryReplaceState.call(history, stateObject, |
| 111 pageTitle, pageUrl); | 112 pageTitle, pageUrl); |
| 112 __gCrWeb.message.invokeOnHost( | 113 __gCrWeb.message.invokeOnHost( |
| 113 {'command': 'window.history.didReplaceState', | 114 {'command': 'window.history.didReplaceState', |
| 114 'stateObject': serializedState, | 115 'stateObject': serializedState, |
| 115 'baseUrl': document.baseURI, | 116 'baseUrl': document.baseURI, |
| 116 'pageUrl': pageUrl.toString()}); | 117 'pageUrl': pageUrl.toString()}); |
| 117 }; | 118 }; |
| 118 | 119 |
| 119 window.addEventListener('hashchange', function(evt) { | 120 window.addEventListener('hashchange', function(evt) { |
| 121 // Because hash changes don't trigger __gCrWeb.didFinishNavigation, so fetch |
| 122 // favicons for the new page manually. |
| 123 __gCrWeb.message.invokeOnHost({'command': 'document.favicons', |
| 124 'favicons': __gCrWeb.common.getFavicons()}); |
| 125 |
| 120 __gCrWeb.message.invokeOnHost({'command': 'window.hashchange'}); | 126 __gCrWeb.message.invokeOnHost({'command': 'window.hashchange'}); |
| 121 }); | 127 }); |
| 122 | 128 |
| 123 /** Flush the message queue. */ | 129 /** Flush the message queue. */ |
| 124 if (__gCrWeb.message) { | 130 if (__gCrWeb.message) { |
| 125 __gCrWeb.message.invokeQueues(); | 131 __gCrWeb.message.invokeQueues(); |
| 126 } | 132 } |
| 127 | 133 |
| 128 }()); // End of anonymouse object | 134 }()); // End of anonymouse object |
| OLD | NEW |