| 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 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 // JavaScript errors are logged on the main application side. The handler is | 33 // 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 | 34 // added ASAP to catch any errors in startup. Note this does not appear to |
| 35 // work in iOS < 5. | 35 // work in iOS < 5. |
| 36 window.addEventListener('error', function(event) { | 36 window.addEventListener('error', function(event) { |
| 37 // Sadly, event.filename and event.lineno are always 'undefined' and '0' | 37 // Sadly, event.filename and event.lineno are always 'undefined' and '0' |
| 38 // with UIWebView. | 38 // with UIWebView. |
| 39 __gCrWeb.message.invokeOnHost( | 39 __gCrWeb.message.invokeOnHost( |
| 40 {'command': 'window.error', 'message': event.message.toString()}); | 40 {'command': 'window.error', 'message': event.message.toString()}); |
| 41 }); | 41 }); |
| 42 | 42 |
| 43 | |
| 44 // Returns true if the top window or any frames inside contain an input | |
| 45 // field of type 'password'. | |
| 46 __gCrWeb['hasPasswordField'] = function() { | |
| 47 return hasPasswordField_(window); | |
| 48 }; | |
| 49 | |
| 50 | |
| 51 // Returns true if the supplied window or any frames inside contain an input | |
| 52 // field of type 'password'. | |
| 53 // @private | |
| 54 var hasPasswordField_ = function(win) { | |
| 55 var doc = win.document; | |
| 56 | |
| 57 // We may will not be allowed to read the 'document' property from a frame | |
| 58 // that is in a different domain. | |
| 59 if (!doc) { | |
| 60 return false; | |
| 61 } | |
| 62 | |
| 63 if (doc.querySelector('input[type=password]')) { | |
| 64 return true; | |
| 65 } | |
| 66 | |
| 67 var frames = win.frames; | |
| 68 for (var i = 0; i < frames.length; i++) { | |
| 69 if (hasPasswordField_(frames[i])) { | |
| 70 return true; | |
| 71 } | |
| 72 } | |
| 73 | |
| 74 return false; | |
| 75 }; | |
| 76 | |
| 77 __gCrWeb['sendFaviconsToHost'] = function() { | 43 __gCrWeb['sendFaviconsToHost'] = function() { |
| 78 __gCrWeb.message.invokeOnHost({'command': 'document.favicons', | 44 __gCrWeb.message.invokeOnHost({'command': 'document.favicons', |
| 79 'favicons': __gCrWeb.common.getFavicons()}); | 45 'favicons': __gCrWeb.common.getFavicons()}); |
| 80 } | 46 } |
| 81 | 47 |
| 82 // Flush the message queue. | 48 // Flush the message queue. |
| 83 if (__gCrWeb.message) { | 49 if (__gCrWeb.message) { |
| 84 __gCrWeb.message.invokeQueues(); | 50 __gCrWeb.message.invokeQueues(); |
| 85 } | 51 } |
| 86 | 52 |
| 87 }()); // End of anonymous object | 53 }()); // End of anonymous object |
| OLD | NEW |