| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // This file adheres to closure-compiler conventions in order to enable | 5 // This file adheres to closure-compiler conventions in order to enable |
| 6 // compilation with ADVANCED_OPTIMIZATIONS. In particular, members that are to | 6 // compilation with ADVANCED_OPTIMIZATIONS. In particular, members that are to |
| 7 // be accessed externally should be specified in this['style'] as opposed to | 7 // be accessed externally should be specified in this['style'] as opposed to |
| 8 // this.style because member identifiers are minified by default. | 8 // this.style because member identifiers are minified by default. |
| 9 // See http://goo.gl/FwOgy | 9 // See http://goo.gl/FwOgy |
| 10 | 10 |
| 11 goog.provide('__crWeb.core'); | 11 goog.provide('__crWeb.core'); |
| 12 | 12 |
| 13 goog.require('__crWeb.common'); | 13 goog.require('__crWeb.common'); |
| 14 goog.require('__crWeb.message'); | 14 goog.require('__crWeb.message'); |
| 15 | 15 |
| 16 /* Beginning of anonymous object. */ | 16 /* Beginning of anonymous object. */ |
| 17 (function() { | 17 (function() { |
| 18 __gCrWeb['core'] = {}; | 18 __gCrWeb['core'] = {}; |
| 19 | 19 |
| 20 /** | |
| 21 * Handles document load completion tasks. Invoked from | |
| 22 * [WKNavigationDelegate webView:didFinishNavigation:], when document load is | |
| 23 * complete. | |
| 24 */ | |
| 25 __gCrWeb.didFinishNavigation = function() { | |
| 26 // Send the favicons to the browser. | |
| 27 __gCrWeb.sendFaviconsToHost(); | |
| 28 // Add placeholders for plugin content. | |
| 29 if (__gCrWeb.common.updatePluginPlaceholders()) | |
| 30 __gCrWeb.message.invokeOnHost({'command': 'addPluginPlaceholders'}); | |
| 31 } | |
| 32 | |
| 33 // JavaScript errors are logged on the main application side. The handler is | 20 // JavaScript errors are logged on the main application side. The handler is |
| 34 // added ASAP to catch any errors in startup. Note this does not appear to | 21 // added ASAP to catch any errors in startup. Note this does not appear to |
| 35 // work in iOS < 5. | 22 // work in iOS < 5. |
| 36 window.addEventListener('error', function(event) { | 23 window.addEventListener('error', function(event) { |
| 37 // Sadly, event.filename and event.lineno are always 'undefined' and '0' | 24 // Sadly, event.filename and event.lineno are always 'undefined' and '0' |
| 38 // with UIWebView. | 25 // with UIWebView. |
| 39 __gCrWeb.message.invokeOnHost( | 26 __gCrWeb.message.invokeOnHost( |
| 40 {'command': 'window.error', 'message': event.message.toString()}); | 27 {'command': 'window.error', 'message': event.message.toString()}); |
| 41 }); | 28 }); |
| 42 | 29 |
| 43 __gCrWeb['sendFaviconsToHost'] = function() { | |
| 44 __gCrWeb.message.invokeOnHost({'command': 'document.favicons', | |
| 45 'favicons': __gCrWeb.common.getFavicons()}); | |
| 46 } | |
| 47 | |
| 48 // Flush the message queue. | 30 // Flush the message queue. |
| 49 if (__gCrWeb.message) { | 31 if (__gCrWeb.message) { |
| 50 __gCrWeb.message.invokeQueues(); | 32 __gCrWeb.message.invokeQueues(); |
| 51 } | 33 } |
| 52 | 34 |
| 53 }()); // End of anonymous object | 35 }()); // End of anonymous object |
| OLD | NEW |