Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // NOTE: If you modify this file, you also have to change its hash in | 6 // NOTE: If you modify this file, you also have to change its hash in |
| 7 // local_ntp.html and in LocalNtpSource::GetContentSecurityPolicyScriptSrc. | 7 // local_ntp.html and in LocalNtpSource::GetContentSecurityPolicyScriptSrc. |
| 8 // To calculate the sum execute the following command | |
| 9 // sha256sum local_ntp.js | cut -d " " -f 1 | xxd -r -p | base64 | |
|
dpapad
2017/05/25 21:28:43
It is unfortunate that modifying this file is now
Marc Treib
2017/06/07 08:49:33
If there's a mismatch, you should get an error mes
| |
| 8 | 10 |
| 9 | 11 |
| 10 /** | 12 /** |
| 11 * @fileoverview The local InstantExtended NTP. | 13 * @fileoverview The local InstantExtended NTP. |
| 12 */ | 14 */ |
| 13 | 15 |
| 14 | 16 |
| 15 /** | 17 /** |
| 16 * Controls rendering the new tab page for InstantExtended. | 18 * Controls rendering the new tab page for InstantExtended. |
| 17 * @return {Object} A limited interface for testing the local NTP. | 19 * @return {Object} A limited interface for testing the local NTP. |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 630 | 632 |
| 631 // Inject the OneGoogleBar loader script. It'll create a global variable | 633 // Inject the OneGoogleBar loader script. It'll create a global variable |
| 632 // named "og" with the following fields: | 634 // named "og" with the following fields: |
| 633 // .html - the main bar HTML. | 635 // .html - the main bar HTML. |
| 634 // .end_of_body_html - HTML to be inserted at the end of the body. | 636 // .end_of_body_html - HTML to be inserted at the end of the body. |
| 635 var ogScript = document.createElement('script'); | 637 var ogScript = document.createElement('script'); |
| 636 ogScript.src = 'chrome-search://local-ntp/one-google.js'; | 638 ogScript.src = 'chrome-search://local-ntp/one-google.js'; |
| 637 document.body.appendChild(ogScript); | 639 document.body.appendChild(ogScript); |
| 638 ogScript.onload = function() { | 640 ogScript.onload = function() { |
| 639 injectOneGoogleBar(og.html, og.end_of_body_html); | 641 injectOneGoogleBar(og.html, og.end_of_body_html); |
| 640 } | 642 }; |
| 641 } else { | 643 } else { |
| 642 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE); | 644 document.body.classList.add(CLASSES.NON_GOOGLE_PAGE); |
| 643 } | 645 } |
| 644 | 646 |
| 645 if (searchboxApiHandle.rtl) { | 647 if (searchboxApiHandle.rtl) { |
| 646 $(IDS.NOTIFICATION).dir = 'rtl'; | 648 $(IDS.NOTIFICATION).dir = 'rtl'; |
| 647 // Grabbing the root HTML element. | 649 // Grabbing the root HTML element. |
| 648 document.documentElement.setAttribute('dir', 'rtl'); | 650 document.documentElement.setAttribute('dir', 'rtl'); |
| 649 // Add class for setting alignments based on language directionality. | 651 // Add class for setting alignments based on language directionality. |
| 650 document.documentElement.classList.add(CLASSES.RTL); | 652 document.documentElement.classList.add(CLASSES.RTL); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 'chrome-search://local-ntp/one-google/after-bar.js'; | 712 'chrome-search://local-ntp/one-google/after-bar.js'; |
| 711 ogElem.parentNode.insertBefore(afterBarScript, ogElem.nextSibling); | 713 ogElem.parentNode.insertBefore(afterBarScript, ogElem.nextSibling); |
| 712 | 714 |
| 713 afterBarScript.onload = function() { | 715 afterBarScript.onload = function() { |
| 714 $('one-google-end-of-body').innerHTML = endOfBodyHtml; | 716 $('one-google-end-of-body').innerHTML = endOfBodyHtml; |
| 715 | 717 |
| 716 var endOfBodyScript = document.createElement('script'); | 718 var endOfBodyScript = document.createElement('script'); |
| 717 endOfBodyScript.src = | 719 endOfBodyScript.src = |
| 718 'chrome-search://local-ntp/one-google/end-of-body.js'; | 720 'chrome-search://local-ntp/one-google/end-of-body.js'; |
| 719 document.body.appendChild(endOfBodyScript); | 721 document.body.appendChild(endOfBodyScript); |
| 720 } | 722 }; |
| 721 } | 723 }; |
| 722 } | 724 }; |
| 723 } | 725 } |
| 724 | 726 |
| 725 | 727 |
| 726 return { | 728 return { |
| 727 init: init, // Exposed for testing. | 729 init: init, // Exposed for testing. |
| 728 listen: listen | 730 listen: listen |
| 729 }; | 731 }; |
| 730 | 732 |
| 731 } | 733 } |
| 732 | 734 |
| 733 if (!window.localNTPUnitTest) { | 735 if (!window.localNTPUnitTest) { |
| 734 LocalNTP().listen(); | 736 LocalNTP().listen(); |
| 735 } | 737 } |
| OLD | NEW |