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/webplugin_delegate_proxy.h" | 5 #include "content/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #elif defined(USE_X11) | 9 #elif defined(USE_X11) |
10 #include <cairo/cairo.h> | 10 #include <cairo/cairo.h> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 #include "content/public/common/sandbox_init.h" | 66 #include "content/public/common/sandbox_init.h" |
67 #endif | 67 #endif |
68 | 68 |
69 using WebKit::WebBindings; | 69 using WebKit::WebBindings; |
70 using WebKit::WebCursorInfo; | 70 using WebKit::WebCursorInfo; |
71 using WebKit::WebDragData; | 71 using WebKit::WebDragData; |
72 using WebKit::WebInputEvent; | 72 using WebKit::WebInputEvent; |
73 using WebKit::WebString; | 73 using WebKit::WebString; |
74 using WebKit::WebView; | 74 using WebKit::WebView; |
75 | 75 |
| 76 namespace { |
| 77 |
| 78 class ScopedLogLevel { |
| 79 public: |
| 80 ScopedLogLevel(int level); |
| 81 ~ScopedLogLevel(); |
| 82 |
| 83 private: |
| 84 int old_level_; |
| 85 |
| 86 DISALLOW_COPY_AND_ASSIGN(ScopedLogLevel); |
| 87 }; |
| 88 |
| 89 ScopedLogLevel::ScopedLogLevel(int level) |
| 90 : old_level_(logging::GetMinLogLevel()) { |
| 91 logging::SetMinLogLevel(level); |
| 92 } |
| 93 |
| 94 ScopedLogLevel::~ScopedLogLevel() { |
| 95 logging::SetMinLogLevel(old_level_); |
| 96 } |
| 97 |
76 // Proxy for WebPluginResourceClient. The object owns itself after creation, | 98 // Proxy for WebPluginResourceClient. The object owns itself after creation, |
77 // deleting itself after its callback has been called. | 99 // deleting itself after its callback has been called. |
78 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { | 100 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { |
79 public: | 101 public: |
80 ResourceClientProxy(PluginChannelHost* channel, int instance_id) | 102 ResourceClientProxy(PluginChannelHost* channel, int instance_id) |
81 : channel_(channel), instance_id_(instance_id), resource_id_(0), | 103 : channel_(channel), instance_id_(instance_id), resource_id_(0), |
82 multibyte_response_expected_(false) { | 104 multibyte_response_expected_(false) { |
83 } | 105 } |
84 | 106 |
85 ~ResourceClientProxy() { | 107 ~ResourceClientProxy() { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 184 |
163 private: | 185 private: |
164 scoped_refptr<PluginChannelHost> channel_; | 186 scoped_refptr<PluginChannelHost> channel_; |
165 int instance_id_; | 187 int instance_id_; |
166 unsigned long resource_id_; | 188 unsigned long resource_id_; |
167 // Set to true if the response expected is a multibyte response. | 189 // Set to true if the response expected is a multibyte response. |
168 // For e.g. response for a HTTP byte range request. | 190 // For e.g. response for a HTTP byte range request. |
169 bool multibyte_response_expected_; | 191 bool multibyte_response_expected_; |
170 }; | 192 }; |
171 | 193 |
| 194 } // namespace |
| 195 |
172 WebPluginDelegateProxy::WebPluginDelegateProxy( | 196 WebPluginDelegateProxy::WebPluginDelegateProxy( |
173 const std::string& mime_type, | 197 const std::string& mime_type, |
174 const base::WeakPtr<RenderViewImpl>& render_view) | 198 const base::WeakPtr<RenderViewImpl>& render_view) |
175 : render_view_(render_view), | 199 : render_view_(render_view), |
176 plugin_(NULL), | 200 plugin_(NULL), |
177 uses_shared_bitmaps_(false), | 201 uses_shared_bitmaps_(false), |
178 #if defined(OS_MACOSX) | 202 #if defined(OS_MACOSX) |
179 uses_compositor_(false), | 203 uses_compositor_(false), |
180 #endif | 204 #endif |
181 window_(gfx::kNullPluginWindow), | 205 window_(gfx::kNullPluginWindow), |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 channel_handle, ChildProcess::current()->io_message_loop_proxy())); | 336 channel_handle, ChildProcess::current()->io_message_loop_proxy())); |
313 if (!channel_host.get()) { | 337 if (!channel_host.get()) { |
314 LOG(ERROR) << "Couldn't get PluginChannelHost"; | 338 LOG(ERROR) << "Couldn't get PluginChannelHost"; |
315 return false; | 339 return false; |
316 } | 340 } |
317 #if defined(OS_MACOSX) | 341 #if defined(OS_MACOSX) |
318 track_nested_removes.reset(); | 342 track_nested_removes.reset(); |
319 #endif | 343 #endif |
320 | 344 |
321 int instance_id; | 345 int instance_id; |
322 bool result = channel_host->Send(new PluginMsg_CreateInstance( | 346 { |
323 mime_type_, &instance_id)); | 347 // TODO(bauerb): Debugging for http://crbug.com/141055. |
324 if (!result) { | 348 ScopedLogLevel log_level(-2); // Equivalent to --v=2 |
325 LOG(ERROR) << "Couldn't send PluginMsg_CreateInstance"; | 349 bool result = channel_host->Send(new PluginMsg_CreateInstance( |
326 return false; | 350 mime_type_, &instance_id)); |
| 351 if (!result) { |
| 352 LOG(ERROR) << "Couldn't send PluginMsg_CreateInstance"; |
| 353 return false; |
| 354 } |
327 } | 355 } |
328 | 356 |
329 channel_host_ = channel_host; | 357 channel_host_ = channel_host; |
330 instance_id_ = instance_id; | 358 instance_id_ = instance_id; |
331 | 359 |
332 channel_host_->AddRoute(instance_id_, this, NULL); | 360 channel_host_->AddRoute(instance_id_, this, NULL); |
333 | 361 |
334 // Now tell the PluginInstance in the plugin process to initialize. | 362 // Now tell the PluginInstance in the plugin process to initialize. |
335 PluginMsg_Init_Params params; | 363 PluginMsg_Init_Params params; |
336 params.containing_window = render_view_->host_window(); | 364 params.containing_window = render_view_->host_window(); |
(...skipping 12 matching lines...) Expand all Loading... |
349 LowerCaseEqualsASCII(arg_values[i], "transparent")) || | 377 LowerCaseEqualsASCII(arg_values[i], "transparent")) || |
350 (silverlight && LowerCaseEqualsASCII(arg_names[i], "background") && | 378 (silverlight && LowerCaseEqualsASCII(arg_names[i], "background") && |
351 SilverlightColorIsTransparent(arg_values[i]))) { | 379 SilverlightColorIsTransparent(arg_values[i]))) { |
352 transparent_ = true; | 380 transparent_ = true; |
353 } | 381 } |
354 } | 382 } |
355 params.load_manually = load_manually; | 383 params.load_manually = load_manually; |
356 | 384 |
357 plugin_ = plugin; | 385 plugin_ = plugin; |
358 | 386 |
359 result = false; | 387 bool result = false; |
360 IPC::Message* msg = new PluginMsg_Init(instance_id_, params, &result); | 388 IPC::Message* msg = new PluginMsg_Init(instance_id_, params, &result); |
361 Send(msg); | 389 Send(msg); |
362 | 390 |
363 if (!result) | 391 if (!result) |
364 LOG(ERROR) << "PluginMsg_Init returned false"; | 392 LOG(ERROR) << "PluginMsg_Init returned false"; |
365 | 393 |
366 render_view_->RegisterPluginDelegate(this); | 394 render_view_->RegisterPluginDelegate(this); |
367 | 395 |
368 return result; | 396 return result; |
369 } | 397 } |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1483 } | 1511 } |
1484 #endif | 1512 #endif |
1485 | 1513 |
1486 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1514 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
1487 int resource_id) { | 1515 int resource_id) { |
1488 if (!plugin_) | 1516 if (!plugin_) |
1489 return; | 1517 return; |
1490 | 1518 |
1491 plugin_->URLRedirectResponse(allow, resource_id); | 1519 plugin_->URLRedirectResponse(allow, resource_id); |
1492 } | 1520 } |
OLD | NEW |