OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/renderer/plugins/chrome_plugin_placeholder.h" | 5 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" |
6 | 6 |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/common/prerender_messages.h" | 10 #include "chrome/common/prerender_messages.h" |
11 #include "chrome/common/render_messages.h" | 11 #include "chrome/common/render_messages.h" |
12 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
13 #include "chrome/grit/renderer_resources.h" | 13 #include "chrome/grit/renderer_resources.h" |
14 #include "chrome/renderer/chrome_content_renderer_client.h" | 14 #include "chrome/renderer/chrome_content_renderer_client.h" |
15 #include "chrome/renderer/custom_menu_commands.h" | 15 #include "chrome/renderer/custom_menu_commands.h" |
| 16 #include "chrome/renderer/plugins/plugin_preroller.h" |
16 #include "chrome/renderer/plugins/plugin_uma.h" | 17 #include "chrome/renderer/plugins/plugin_uma.h" |
17 #include "components/content_settings/content/common/content_settings_messages.h
" | 18 #include "components/content_settings/content/common/content_settings_messages.h
" |
18 #include "content/app/strings/grit/content_strings.h" | 19 #include "content/app/strings/grit/content_strings.h" |
19 #include "content/public/common/context_menu_params.h" | 20 #include "content/public/common/context_menu_params.h" |
20 #include "content/public/renderer/render_frame.h" | 21 #include "content/public/renderer/render_frame.h" |
21 #include "content/public/renderer/render_thread.h" | 22 #include "content/public/renderer/render_thread.h" |
22 #include "gin/handle.h" | 23 #include "gin/handle.h" |
23 #include "gin/object_template_builder.h" | 24 #include "gin/object_template_builder.h" |
24 #include "third_party/WebKit/public/web/WebDocument.h" | 25 #include "third_party/WebKit/public/web/WebDocument.h" |
25 #include "third_party/WebKit/public/web/WebInputEvent.h" | 26 #include "third_party/WebKit/public/web/WebInputEvent.h" |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 params.custom_items.push_back(hide_item); | 362 params.custom_items.push_back(hide_item); |
362 | 363 |
363 params.x = event.windowX; | 364 params.x = event.windowX; |
364 params.y = event.windowY; | 365 params.y = event.windowY; |
365 | 366 |
366 context_menu_request_id_ = render_frame()->ShowContextMenu(this, params); | 367 context_menu_request_id_ = render_frame()->ShowContextMenu(this, params); |
367 g_last_active_menu = this; | 368 g_last_active_menu = this; |
368 #endif // OS_ANDROID | 369 #endif // OS_ANDROID |
369 } | 370 } |
370 | 371 |
| 372 blink::WebPlugin* ChromePluginPlaceholder::CreatePlugin() { |
| 373 scoped_ptr<content::PluginInstanceThrottler> throttler; |
| 374 #if defined(ENABLE_PLUGINS) |
| 375 // If the plugin has already been marked essential in its placeholder form, |
| 376 // we shouldn't create a new throttler and start the process all over again. |
| 377 if (power_saver_enabled()) { |
| 378 throttler = content::PluginInstanceThrottler::Create(); |
| 379 // PluginPreroller manages its own lifetime. |
| 380 new PluginPreroller(render_frame(), GetFrame(), GetPluginParams(), |
| 381 GetPluginInfo(), GetIdentifier(), title_, |
| 382 l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, title_), |
| 383 throttler.get()); |
| 384 } |
| 385 #endif |
| 386 return render_frame()->CreatePlugin(GetFrame(), GetPluginInfo(), |
| 387 GetPluginParams(), throttler.Pass()); |
| 388 } |
| 389 |
371 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { | 390 void ChromePluginPlaceholder::BindWebFrame(blink::WebFrame* frame) { |
372 v8::Isolate* isolate = blink::mainThreadIsolate(); | 391 v8::Isolate* isolate = blink::mainThreadIsolate(); |
373 v8::HandleScope handle_scope(isolate); | 392 v8::HandleScope handle_scope(isolate); |
374 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); | 393 v8::Handle<v8::Context> context = frame->mainWorldScriptContext(); |
375 DCHECK(!context.IsEmpty()); | 394 DCHECK(!context.IsEmpty()); |
376 | 395 |
377 v8::Context::Scope context_scope(context); | 396 v8::Context::Scope context_scope(context); |
378 v8::Handle<v8::Object> global = context->Global(); | 397 v8::Handle<v8::Object> global = context->Global(); |
379 global->Set(gin::StringToV8(isolate, "plugin"), | 398 global->Set(gin::StringToV8(isolate, "plugin"), |
380 gin::CreateHandle(isolate, this).ToV8()); | 399 gin::CreateHandle(isolate, this).ToV8()); |
381 } | 400 } |
382 | 401 |
383 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( | 402 gin::ObjectTemplateBuilder ChromePluginPlaceholder::GetObjectTemplateBuilder( |
384 v8::Isolate* isolate) { | 403 v8::Isolate* isolate) { |
385 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( | 404 return LoadablePluginPlaceholder::GetObjectTemplateBuilder(isolate).SetMethod( |
386 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); | 405 "openAboutPlugins", &ChromePluginPlaceholder::OpenAboutPluginsCallback); |
387 } | 406 } |
OLD | NEW |