Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: chrome/browser/plugin_process_host.cc

Issue 5874002: Create a ResourceMessageFilter to filter resource related IPCs. This gets ri... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/browser/plugin_process_host.h" 5 #include "chrome/browser/plugin_process_host.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <utility> // for pair<> 10 #include <utility> // for pair<>
(...skipping 10 matching lines...) Expand all
21 #include "base/string_util.h" 21 #include "base/string_util.h"
22 #include "base/utf_string_conversions.h" 22 #include "base/utf_string_conversions.h"
23 #include "chrome/browser/browser_thread.h" 23 #include "chrome/browser/browser_thread.h"
24 #include "chrome/browser/child_process_security_policy.h" 24 #include "chrome/browser/child_process_security_policy.h"
25 #include "chrome/browser/chrome_plugin_browsing_context.h" 25 #include "chrome/browser/chrome_plugin_browsing_context.h"
26 #include "chrome/browser/net/url_request_tracking.h" 26 #include "chrome/browser/net/url_request_tracking.h"
27 #include "chrome/browser/plugin_download_helper.h" 27 #include "chrome/browser/plugin_download_helper.h"
28 #include "chrome/browser/plugin_service.h" 28 #include "chrome/browser/plugin_service.h"
29 #include "chrome/browser/profiles/profile.h" 29 #include "chrome/browser/profiles/profile.h"
30 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 30 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
31 #include "chrome/browser/renderer_host/resource_message_filter.h"
31 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
32 #include "chrome/common/chrome_plugin_lib.h" 33 #include "chrome/common/chrome_plugin_lib.h"
33 #include "chrome/common/chrome_switches.h" 34 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/logging_chrome.h" 35 #include "chrome/common/logging_chrome.h"
35 #include "chrome/common/net/url_request_context_getter.h" 36 #include "chrome/common/net/url_request_context_getter.h"
36 #include "chrome/common/plugin_messages.h" 37 #include "chrome/common/plugin_messages.h"
37 #include "chrome/common/render_messages.h" 38 #include "chrome/common/render_messages.h"
38 #include "gfx/native_widget_types.h" 39 #include "gfx/native_widget_types.h"
39 #include "ipc/ipc_switches.h" 40 #include "ipc/ipc_switches.h"
40 #include "net/base/cookie_store.h" 41 #include "net/base/cookie_store.h"
41 #include "net/base/io_buffer.h" 42 #include "net/base/io_buffer.h"
42 #include "net/url_request/url_request.h" 43 #include "net/url_request/url_request.h"
43 #include "net/url_request/url_request_context.h" 44 #include "net/url_request/url_request_context.h"
44 45
45 #if defined(USE_X11) 46 #if defined(USE_X11)
46 #include "gfx/gtk_native_view_id_manager.h" 47 #include "gfx/gtk_native_view_id_manager.h"
47 #endif 48 #endif
48 49
49 #if defined(OS_MACOSX) 50 #if defined(OS_MACOSX)
50 #include "base/mac_util.h" 51 #include "base/mac_util.h"
51 #include "chrome/common/plugin_carbon_interpose_constants_mac.h" 52 #include "chrome/common/plugin_carbon_interpose_constants_mac.h"
52 #include "gfx/rect.h" 53 #include "gfx/rect.h"
53 #endif 54 #endif
54 55
55 static const char kDefaultPluginFinderURL[] = 56 static const char kDefaultPluginFinderURL[] =
56 "https://dl-ssl.google.com/edgedl/chrome/plugins/plugins2.xml"; 57 "https://dl-ssl.google.com/edgedl/chrome/plugins/plugins2.xml";
57 58
59 namespace {
60
61 // Helper class that we pass to ResourceMessageFilter so that it can find the
62 // right URLRequestContext for a request.
63 class PluginURLRequestContextOverride
64 : public ResourceMessageFilter::URLRequestContextOverride {
65 public:
66 PluginURLRequestContextOverride() {
67 }
68
69 virtual URLRequestContext* GetRequestContext(
70 uint32 request_id, ResourceType::Type resource_type) {
71 return CPBrowsingContextManager::GetInstance()->ToURLRequestContext(
72 request_id);
brettw 2010/12/15 21:31:10 Indent 2 more spaces.
jam 2010/12/15 21:41:04 Done.
73 }
74 };
75
76 } // namespace
77
58 #if defined(OS_WIN) 78 #if defined(OS_WIN)
59 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { 79 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) {
60 // The window is destroyed at this point, we just care about its parent, which 80 // The window is destroyed at this point, we just care about its parent, which
61 // is the intermediate window we created. 81 // is the intermediate window we created.
62 std::set<HWND>::iterator window_index = 82 std::set<HWND>::iterator window_index =
63 plugin_parent_windows_set_.find(parent); 83 plugin_parent_windows_set_.find(parent);
64 if (window_index == plugin_parent_windows_set_.end()) 84 if (window_index == plugin_parent_windows_set_.end())
65 return; 85 return;
66 86
67 plugin_parent_windows_set_.erase(window_index); 87 plugin_parent_windows_set_.erase(window_index);
(...skipping 19 matching lines...) Expand all
87 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, 107 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id,
88 gfx::PluginWindowHandle* output) { 108 gfx::PluginWindowHandle* output) {
89 *output = 0; 109 *output = 0;
90 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); 110 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id);
91 } 111 }
92 #endif // defined(TOOLKIT_USES_GTK) 112 #endif // defined(TOOLKIT_USES_GTK)
93 113
94 PluginProcessHost::PluginProcessHost() 114 PluginProcessHost::PluginProcessHost()
95 : BrowserChildProcessHost( 115 : BrowserChildProcessHost(
96 PLUGIN_PROCESS, 116 PLUGIN_PROCESS,
97 PluginService::GetInstance()->resource_dispatcher_host()), 117 PluginService::GetInstance()->resource_dispatcher_host(),
118 new PluginURLRequestContextOverride()),
98 ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL)) 119 ALLOW_THIS_IN_INITIALIZER_LIST(resolve_proxy_msg_helper_(this, NULL))
99 #if defined(OS_MACOSX) 120 #if defined(OS_MACOSX)
100 , plugin_cursor_visible_(true) 121 , plugin_cursor_visible_(true)
101 #endif 122 #endif
102 { 123 {
103 } 124 }
104 125
105 PluginProcessHost::~PluginProcessHost() { 126 PluginProcessHost::~PluginProcessHost() {
106 #if defined(OS_WIN) 127 #if defined(OS_WIN)
107 // We erase HWNDs from the plugin_parent_windows_set_ when we receive a 128 // We erase HWNDs from the plugin_parent_windows_set_ when we receive a
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 } 413 }
393 414
394 void PluginProcessHost::OnResolveProxyCompleted(IPC::Message* reply_msg, 415 void PluginProcessHost::OnResolveProxyCompleted(IPC::Message* reply_msg,
395 int result, 416 int result,
396 const std::string& proxy_list) { 417 const std::string& proxy_list) {
397 PluginProcessHostMsg_ResolveProxy::WriteReplyParams( 418 PluginProcessHostMsg_ResolveProxy::WriteReplyParams(
398 reply_msg, result, proxy_list); 419 reply_msg, result, proxy_list);
399 Send(reply_msg); 420 Send(reply_msg);
400 } 421 }
401 422
402 URLRequestContext* PluginProcessHost::GetRequestContext(
403 uint32 request_id,
404 const ViewHostMsg_Resource_Request& request_data) {
405 return CPBrowsingContextManager::GetInstance()->ToURLRequestContext(
406 request_id);
407 }
408
409 void PluginProcessHost::RequestPluginChannel(Client* client) { 423 void PluginProcessHost::RequestPluginChannel(Client* client) {
410 // We can't send any sync messages from the browser because it might lead to 424 // We can't send any sync messages from the browser because it might lead to
411 // a hang. However this async messages must be answered right away by the 425 // a hang. However this async messages must be answered right away by the
412 // plugin process (i.e. unblocks a Send() call like a sync message) otherwise 426 // plugin process (i.e. unblocks a Send() call like a sync message) otherwise
413 // a deadlock can occur if the plugin creation request from the renderer is 427 // a deadlock can occur if the plugin creation request from the renderer is
414 // a result of a sync message by the plugin process. 428 // a result of a sync message by the plugin process.
415 PluginProcessMsg_CreateChannel* msg = 429 PluginProcessMsg_CreateChannel* msg =
416 new PluginProcessMsg_CreateChannel(client->ID(), 430 new PluginProcessMsg_CreateChannel(client->ID(),
417 client->OffTheRecord()); 431 client->OffTheRecord());
418 msg->set_unblock(true); 432 msg->set_unblock(true);
(...skipping 27 matching lines...) Expand all
446 const std::vector<uint8>& data) { 460 const std::vector<uint8>& data) {
447 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 461 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
448 462
449 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(info_.path); 463 ChromePluginLib *chrome_plugin = ChromePluginLib::Find(info_.path);
450 if (chrome_plugin) { 464 if (chrome_plugin) {
451 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0])); 465 void *data_ptr = const_cast<void*>(reinterpret_cast<const void*>(&data[0]));
452 uint32 data_len = static_cast<uint32>(data.size()); 466 uint32 data_len = static_cast<uint32>(data.size());
453 chrome_plugin->functions().on_message(data_ptr, data_len); 467 chrome_plugin->functions().on_message(data_ptr, data_len);
454 } 468 }
455 } 469 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698