| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chromecast/renderer/cast_content_renderer_client.h" | 5 #include "chromecast/renderer/cast_content_renderer_client.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 141 } |
| 142 | 142 |
| 143 void CastContentRendererClient::RunScriptsAtDocumentStart( | 143 void CastContentRendererClient::RunScriptsAtDocumentStart( |
| 144 content::RenderFrame* render_frame) { | 144 content::RenderFrame* render_frame) { |
| 145 // This method enables Mojo bindings in JavaScript for Chromecast. | 145 // This method enables Mojo bindings in JavaScript for Chromecast. |
| 146 | 146 |
| 147 v8::HandleScope handle_scope(blink::mainThreadIsolate()); | 147 v8::HandleScope handle_scope(blink::mainThreadIsolate()); |
| 148 v8::Local<v8::Context> context = | 148 v8::Local<v8::Context> context = |
| 149 render_frame->GetWebFrame()->mainWorldScriptContext(); | 149 render_frame->GetWebFrame()->mainWorldScriptContext(); |
| 150 | 150 |
| 151 // CastGinRunner manages its own lifetime. | 151 CastGinRunner* runner = CastGinRunner::Get(render_frame); |
| 152 CastGinRunner* runner = new CastGinRunner(render_frame); | |
| 153 gin::Runner::Scope scoper(runner); | 152 gin::Runner::Scope scoper(runner); |
| 154 | 153 |
| 155 // Initialize AMD API for Mojo. | 154 // Initialize AMD API for Mojo. |
| 156 render_frame->EnsureMojoBuiltinsAreAvailable(context->GetIsolate(), context); | 155 render_frame->EnsureMojoBuiltinsAreAvailable(context->GetIsolate(), context); |
| 157 gin::ModuleRegistry::InstallGlobals(context->GetIsolate(), context->Global()); | 156 gin::ModuleRegistry::InstallGlobals(context->GetIsolate(), context->Global()); |
| 158 | 157 |
| 159 // Inject JavaScript files in the correct dependency order. | 158 // Inject JavaScript files in the correct dependency order. |
| 160 static const int mojo_resource_ids[] = { | 159 static const int mojo_resource_ids[] = { |
| 161 IDR_MOJO_UNICODE_JS, | 160 IDR_MOJO_UNICODE_JS, |
| 162 IDR_MOJO_BUFFER_JS, | 161 IDR_MOJO_BUFFER_JS, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 174 | 173 |
| 175 void ExecuteJavaScript(content::RenderFrame* render_frame, int resource_id) { | 174 void ExecuteJavaScript(content::RenderFrame* render_frame, int resource_id) { |
| 176 const std::string& js_string = ui::ResourceBundle::GetSharedInstance() | 175 const std::string& js_string = ui::ResourceBundle::GetSharedInstance() |
| 177 .GetRawDataResource(resource_id) | 176 .GetRawDataResource(resource_id) |
| 178 .as_string(); | 177 .as_string(); |
| 179 render_frame->ExecuteJavaScript(base::UTF8ToUTF16(js_string)); | 178 render_frame->ExecuteJavaScript(base::UTF8ToUTF16(js_string)); |
| 180 } | 179 } |
| 181 | 180 |
| 182 } // namespace shell | 181 } // namespace shell |
| 183 } // namespace chromecast | 182 } // namespace chromecast |
| OLD | NEW |