OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 5 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 namespace content { | 48 namespace content { |
49 | 49 |
50 struct PepperWebPluginImpl::InitData { | 50 struct PepperWebPluginImpl::InitData { |
51 scoped_refptr<PluginModule> module; | 51 scoped_refptr<PluginModule> module; |
52 RenderFrameImpl* render_frame; | 52 RenderFrameImpl* render_frame; |
53 std::vector<std::string> arg_names; | 53 std::vector<std::string> arg_names; |
54 std::vector<std::string> arg_values; | 54 std::vector<std::string> arg_values; |
55 GURL url; | 55 GURL url; |
56 }; | 56 }; |
57 | 57 |
58 PepperWebPluginImpl::PepperWebPluginImpl( | 58 PepperWebPluginImpl::PepperWebPluginImpl(PluginModule* plugin_module, |
59 PluginModule* plugin_module, | 59 const WebPluginParams& params, |
60 const WebPluginParams& params, | 60 RenderFrameImpl* render_frame, |
61 RenderFrameImpl* render_frame, | 61 PluginInstanceThrottler* throttler) |
62 RenderFrame::PluginPowerSaverMode power_saver_mode) | |
63 : init_data_(new InitData()), | 62 : init_data_(new InitData()), |
64 full_frame_(params.loadManually), | 63 full_frame_(params.loadManually), |
65 power_saver_mode_(power_saver_mode), | 64 throttler_(throttler), |
66 instance_object_(PP_MakeUndefined()), | 65 instance_object_(PP_MakeUndefined()), |
67 container_(NULL) { | 66 container_(NULL) { |
68 DCHECK(plugin_module); | 67 DCHECK(plugin_module); |
69 init_data_->module = plugin_module; | 68 init_data_->module = plugin_module; |
70 init_data_->render_frame = render_frame; | 69 init_data_->render_frame = render_frame; |
71 for (size_t i = 0; i < params.attributeNames.size(); ++i) { | 70 for (size_t i = 0; i < params.attributeNames.size(); ++i) { |
72 init_data_->arg_names.push_back(params.attributeNames[i].utf8()); | 71 init_data_->arg_names.push_back(params.attributeNames[i].utf8()); |
73 init_data_->arg_values.push_back(params.attributeValues[i].utf8()); | 72 init_data_->arg_values.push_back(params.attributeValues[i].utf8()); |
74 } | 73 } |
75 init_data_->url = params.url; | 74 init_data_->url = params.url; |
(...skipping 11 matching lines...) Expand all Loading... |
87 bool PepperWebPluginImpl::initialize(WebPluginContainer* container) { | 86 bool PepperWebPluginImpl::initialize(WebPluginContainer* container) { |
88 // The plugin delegate may have gone away. | 87 // The plugin delegate may have gone away. |
89 instance_ = init_data_->module->CreateInstance( | 88 instance_ = init_data_->module->CreateInstance( |
90 init_data_->render_frame, container, init_data_->url); | 89 init_data_->render_frame, container, init_data_->url); |
91 if (!instance_.get()) | 90 if (!instance_.get()) |
92 return false; | 91 return false; |
93 | 92 |
94 // Enable script objects for this plugin. | 93 // Enable script objects for this plugin. |
95 container->allowScriptObjects(); | 94 container->allowScriptObjects(); |
96 | 95 |
97 bool success = | 96 bool success = instance_->Initialize( |
98 instance_->Initialize(init_data_->arg_names, init_data_->arg_values, | 97 init_data_->arg_names, init_data_->arg_values, full_frame_, throttler_); |
99 full_frame_, power_saver_mode_); | |
100 if (!success) { | 98 if (!success) { |
101 instance_->Delete(); | 99 instance_->Delete(); |
102 instance_ = NULL; | 100 instance_ = NULL; |
103 | 101 |
104 blink::WebPlugin* replacement_plugin = | 102 blink::WebPlugin* replacement_plugin = |
105 GetContentClient()->renderer()->CreatePluginReplacement( | 103 GetContentClient()->renderer()->CreatePluginReplacement( |
106 init_data_->render_frame, init_data_->module->path()); | 104 init_data_->render_frame, init_data_->module->path()); |
107 if (!replacement_plugin || !replacement_plugin->initialize(container)) | 105 if (!replacement_plugin || !replacement_plugin->initialize(container)) |
108 return false; | 106 return false; |
109 | 107 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 280 |
283 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } | 281 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } |
284 | 282 |
285 void PepperWebPluginImpl::rotateView(RotationType type) { | 283 void PepperWebPluginImpl::rotateView(RotationType type) { |
286 instance_->RotateView(type); | 284 instance_->RotateView(type); |
287 } | 285 } |
288 | 286 |
289 bool PepperWebPluginImpl::isPlaceholder() { return false; } | 287 bool PepperWebPluginImpl::isPlaceholder() { return false; } |
290 | 288 |
291 } // namespace content | 289 } // namespace content |
OLD | NEW |