| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 332 } |
| 333 } | 333 } |
| 334 | 334 |
| 335 return false; | 335 return false; |
| 336 }; | 336 }; |
| 337 | 337 |
| 338 function invokeOnHost_(command) { | 338 function invokeOnHost_(command) { |
| 339 __gCrWeb.message.invokeOnHost(command); | 339 __gCrWeb.message.invokeOnHost(command); |
| 340 }; | 340 }; |
| 341 | 341 |
| 342 function invokeOnHostImmediate_(command) { | |
| 343 __gCrWeb.message.invokeOnHostImmediate(command); | |
| 344 }; | |
| 345 | |
| 346 /** | 342 /** |
| 347 * Gets the referrer policy to use for navigations away from the current page. | 343 * Gets the referrer policy to use for navigations away from the current page. |
| 348 * If a link element is passed, and it includes a rel=noreferrer tag, that | 344 * If a link element is passed, and it includes a rel=noreferrer tag, that |
| 349 * will override the page setting. | 345 * will override the page setting. |
| 350 * @param {HTMLElement=} opt_linkElement The link triggering the navigation. | 346 * @param {HTMLElement=} opt_linkElement The link triggering the navigation. |
| 351 * @return {string} The policy string. | 347 * @return {string} The policy string. |
| 352 * @private | 348 * @private |
| 353 */ | 349 */ |
| 354 var getReferrerPolicy_ = function(opt_linkElement) { | 350 var getReferrerPolicy_ = function(opt_linkElement) { |
| 355 if (opt_linkElement) { | 351 if (opt_linkElement) { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 }; | 542 }; |
| 547 | 543 |
| 548 var setExternalRequest_ = function(href, target) { | 544 var setExternalRequest_ = function(href, target) { |
| 549 if (typeof(target) == 'undefined' || target == '_blank' || target == '') { | 545 if (typeof(target) == 'undefined' || target == '_blank' || target == '') { |
| 550 target = '' + Date.now() + '-' + Math.random(); | 546 target = '' + Date.now() + '-' + Math.random(); |
| 551 } | 547 } |
| 552 if (typeof(href) == 'undefined') { | 548 if (typeof(href) == 'undefined') { |
| 553 // W3C recommended behavior. | 549 // W3C recommended behavior. |
| 554 href = 'about:blank'; | 550 href = 'about:blank'; |
| 555 } | 551 } |
| 556 // ExternalRequest messages need to be handled before the expected | 552 invokeOnHost_({'command': 'externalRequest', |
| 557 // shouldStartLoadWithRequest, as such we cannot wait for the regular | 553 'href': href, |
| 558 // message queue invoke which delays to avoid illegal recursion into | 554 'target': target, |
| 559 // UIWebView. This immediate class of messages is handled ASAP by | 555 'referrerPolicy': getReferrerPolicy_()}); |
| 560 // CRWWebController. | |
| 561 invokeOnHostImmediate_({'command': 'externalRequest', | |
| 562 'href': href, | |
| 563 'target': target, | |
| 564 'referrerPolicy': getReferrerPolicy_()}); | |
| 565 }; | 556 }; |
| 566 | 557 |
| 567 var resetExternalRequest_ = function() { | 558 var resetExternalRequest_ = function() { |
| 568 invokeOnHost_({'command': 'resetExternalRequest'}); | 559 invokeOnHost_({'command': 'resetExternalRequest'}); |
| 569 }; | 560 }; |
| 570 | 561 |
| 571 var clickBubbleListener_ = function(evt) { | 562 var clickBubbleListener_ = function(evt) { |
| 572 if (evt['defaultPrevented']) { | 563 if (evt['defaultPrevented']) { |
| 573 resetExternalRequest_(); | 564 resetExternalRequest_(); |
| 574 } | 565 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 }); | 650 }); |
| 660 }, false); | 651 }, false); |
| 661 | 652 |
| 662 addFormEventListeners_(); | 653 addFormEventListeners_(); |
| 663 | 654 |
| 664 return true; | 655 return true; |
| 665 }; | 656 }; |
| 666 | 657 |
| 667 __gCrWeb.core.documentInject(); | 658 __gCrWeb.core.documentInject(); |
| 668 }()); // End of anonymous object | 659 }()); // End of anonymous object |
| OLD | NEW |