Chromium Code Reviews| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 // Find the closest ancester that is a link. | 535 // Find the closest ancester that is a link. |
| 540 while (node) { | 536 while (node) { |
| 541 if (node instanceof HTMLAnchorElement) | 537 if (node instanceof HTMLAnchorElement) |
| 542 break; | 538 break; |
| 543 node = node.parentNode; | 539 node = node.parentNode; |
| 544 } | 540 } |
| 545 return node; | 541 return node; |
| 546 }; | 542 }; |
| 547 | 543 |
| 548 var setExternalRequest_ = function(href, target) { | 544 var setExternalRequest_ = function(href, target) { |
| 545 // If there is no document or body, the request will be silently dropped | |
|
Eugene But (OOO till 7-30)
2016/09/20 22:05:14
Do you even need this comment? It simply repeats t
| |
| 546 // here. | |
| 547 if (!document || !document.body) | |
| 548 return; | |
| 549 if (typeof(target) == 'undefined' || target == '_blank' || target == '') { | 549 if (typeof(target) == 'undefined' || target == '_blank' || target == '') { |
| 550 target = '' + Date.now() + '-' + Math.random(); | 550 target = '' + Date.now() + '-' + Math.random(); |
| 551 } | 551 } |
| 552 if (typeof(href) == 'undefined') { | 552 if (typeof(href) == 'undefined') { |
| 553 // W3C recommended behavior. | 553 // W3C recommended behavior. |
| 554 href = 'about:blank'; | 554 href = 'about:blank'; |
| 555 } | 555 } |
| 556 // ExternalRequest messages need to be handled before the expected | 556 invokeOnHost_({'command': 'externalRequest', |
| 557 // shouldStartLoadWithRequest, as such we cannot wait for the regular | 557 'href': href, |
| 558 // message queue invoke which delays to avoid illegal recursion into | 558 'target': target, |
| 559 // UIWebView. This immediate class of messages is handled ASAP by | 559 'referrerPolicy': getReferrerPolicy_()}); |
| 560 // CRWWebController. | |
| 561 invokeOnHostImmediate_({'command': 'externalRequest', | |
| 562 'href': href, | |
| 563 'target': target, | |
| 564 'referrerPolicy': getReferrerPolicy_()}); | |
| 565 }; | 560 }; |
| 566 | 561 |
| 567 var resetExternalRequest_ = function() { | 562 var resetExternalRequest_ = function() { |
| 568 invokeOnHost_({'command': 'resetExternalRequest'}); | 563 invokeOnHost_({'command': 'resetExternalRequest'}); |
| 569 }; | 564 }; |
| 570 | 565 |
| 571 var clickBubbleListener_ = function(evt) { | 566 var clickBubbleListener_ = function(evt) { |
| 572 if (evt['defaultPrevented']) { | 567 if (evt['defaultPrevented']) { |
| 573 resetExternalRequest_(); | 568 resetExternalRequest_(); |
| 574 } | 569 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 659 }); | 654 }); |
| 660 }, false); | 655 }, false); |
| 661 | 656 |
| 662 addFormEventListeners_(); | 657 addFormEventListeners_(); |
| 663 | 658 |
| 664 return true; | 659 return true; |
| 665 }; | 660 }; |
| 666 | 661 |
| 667 __gCrWeb.core.documentInject(); | 662 __gCrWeb.core.documentInject(); |
| 668 }()); // End of anonymous object | 663 }()); // End of anonymous object |
| OLD | NEW |