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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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( |
59 PluginModule* plugin_module, | 59 PluginModule* plugin_module, |
60 const WebPluginParams& params, | 60 const WebPluginParams& params, |
61 RenderFrameImpl* render_frame, | 61 RenderFrameImpl* render_frame, |
62 RenderFrame::PluginPowerSaverMode power_saver_mode) | 62 scoped_ptr<PluginInstanceThrottler> throttler) |
63 : init_data_(new InitData()), | 63 : init_data_(new InitData()), |
64 full_frame_(params.loadManually), | 64 full_frame_(params.loadManually), |
65 power_saver_mode_(power_saver_mode), | 65 throttler_(throttler.Pass()), |
66 instance_object_(PP_MakeUndefined()), | 66 instance_object_(PP_MakeUndefined()), |
67 container_(NULL) { | 67 container_(NULL) { |
68 DCHECK(plugin_module); | 68 DCHECK(plugin_module); |
69 init_data_->module = plugin_module; | 69 init_data_->module = plugin_module; |
70 init_data_->render_frame = render_frame; | 70 init_data_->render_frame = render_frame; |
71 for (size_t i = 0; i < params.attributeNames.size(); ++i) { | 71 for (size_t i = 0; i < params.attributeNames.size(); ++i) { |
72 init_data_->arg_names.push_back(params.attributeNames[i].utf8()); | 72 init_data_->arg_names.push_back(params.attributeNames[i].utf8()); |
73 init_data_->arg_values.push_back(params.attributeValues[i].utf8()); | 73 init_data_->arg_values.push_back(params.attributeValues[i].utf8()); |
74 } | 74 } |
75 init_data_->url = params.url; | 75 init_data_->url = params.url; |
(...skipping 13 matching lines...) Expand all Loading... |
89 instance_ = init_data_->module->CreateInstance( | 89 instance_ = init_data_->module->CreateInstance( |
90 init_data_->render_frame, container, init_data_->url); | 90 init_data_->render_frame, container, init_data_->url); |
91 if (!instance_.get()) | 91 if (!instance_.get()) |
92 return false; | 92 return false; |
93 | 93 |
94 // Enable script objects for this plugin. | 94 // Enable script objects for this plugin. |
95 container->allowScriptObjects(); | 95 container->allowScriptObjects(); |
96 | 96 |
97 bool success = | 97 bool success = |
98 instance_->Initialize(init_data_->arg_names, init_data_->arg_values, | 98 instance_->Initialize(init_data_->arg_names, init_data_->arg_values, |
99 full_frame_, power_saver_mode_); | 99 full_frame_, throttler_.Pass()); |
100 if (!success) { | 100 if (!success) { |
101 instance_->Delete(); | 101 instance_->Delete(); |
102 instance_ = NULL; | 102 instance_ = NULL; |
103 | 103 |
104 blink::WebPlugin* replacement_plugin = | 104 blink::WebPlugin* replacement_plugin = |
105 GetContentClient()->renderer()->CreatePluginReplacement( | 105 GetContentClient()->renderer()->CreatePluginReplacement( |
106 init_data_->render_frame, init_data_->module->path()); | 106 init_data_->render_frame, init_data_->module->path()); |
107 if (!replacement_plugin || !replacement_plugin->initialize(container)) | 107 if (!replacement_plugin || !replacement_plugin->initialize(container)) |
108 return false; | 108 return false; |
109 | 109 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 | 282 |
283 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } | 283 bool PepperWebPluginImpl::canRotateView() { return instance_->CanRotateView(); } |
284 | 284 |
285 void PepperWebPluginImpl::rotateView(RotationType type) { | 285 void PepperWebPluginImpl::rotateView(RotationType type) { |
286 instance_->RotateView(type); | 286 instance_->RotateView(type); |
287 } | 287 } |
288 | 288 |
289 bool PepperWebPluginImpl::isPlaceholder() { return false; } | 289 bool PepperWebPluginImpl::isPlaceholder() { return false; } |
290 | 290 |
291 } // namespace content | 291 } // namespace content |
OLD | NEW |