| Index: chrome/browser/resources/local_ntp/local_ntp.js
|
| diff --git a/chrome/browser/resources/local_ntp/local_ntp.js b/chrome/browser/resources/local_ntp/local_ntp.js
|
| index 8ba21d32b5aa53b73d264073f5ff1db0fe49d19c..637b99d7ff92a247c79fbd70d93f94f3f689dbe8 100644
|
| --- a/chrome/browser/resources/local_ntp/local_ntp.js
|
| +++ b/chrome/browser/resources/local_ntp/local_ntp.js
|
| @@ -627,6 +627,17 @@ function init() {
|
|
|
| // Update the fakebox style to match the current key capturing state.
|
| setFakeboxFocus(searchboxApiHandle.isKeyCaptureEnabled);
|
| +
|
| + // Inject the OneGoogleBar loader script. It'll create a global variable
|
| + // named "og" with the following fields:
|
| + // .html - the main bar HTML.
|
| + // .end_of_body_html - HTML to be inserted at the end of the body.
|
| + var ogScript = document.createElement('script');
|
| + ogScript.src = 'chrome-search://local-ntp/one-google.js';
|
| + document.body.appendChild(ogScript);
|
| + ogScript.onload = function() {
|
| + injectOneGoogleBar(og.html, og.end_of_body_html);
|
| + }
|
| } else {
|
| document.body.classList.add(CLASSES.NON_GOOGLE_PAGE);
|
| }
|
| @@ -673,6 +684,44 @@ function listen() {
|
| document.addEventListener('DOMContentLoaded', init);
|
| }
|
|
|
| +
|
| +/**
|
| + * Injects the One Google Bar into the page. Called asynchronously, so that it
|
| + * doesn't block the main page load.
|
| + */
|
| +function injectOneGoogleBar(barHtml, endOfBodyHtml) {
|
| + var inHeadStyle = document.createElement('link');
|
| + inHeadStyle.rel = "stylesheet";
|
| + inHeadStyle.href = 'chrome-search://local-ntp/one-google/in-head.css';
|
| + document.head.appendChild(inHeadStyle);
|
| +
|
| + inHeadStyle.onload = function() {
|
| + var inHeadScript = document.createElement('script');
|
| + inHeadScript.src = 'chrome-search://local-ntp/one-google/in-head.js';
|
| + document.head.appendChild(inHeadScript);
|
| +
|
| + inHeadScript.onload = function() {
|
| + var ogElem = $('one-google');
|
| + ogElem.innerHTML = barHtml;
|
| +
|
| + var afterBarScript = document.createElement('script');
|
| + afterBarScript.src =
|
| + 'chrome-search://local-ntp/one-google/after-bar.js';
|
| + ogElem.parentNode.insertBefore(afterBarScript, ogElem.nextSibling);
|
| +
|
| + afterBarScript.onload = function() {
|
| + $('one-google-end-of-body').innerHTML = endOfBodyHtml;
|
| +
|
| + var endOfBodyScript = document.createElement('script');
|
| + endOfBodyScript.src =
|
| + 'chrome-search://local-ntp/one-google/end-of-body.js';
|
| + document.body.appendChild(endOfBodyScript);
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| +
|
| return {
|
| init: init, // Exposed for testing.
|
| listen: listen
|
|
|