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/browser/plugin_process_host.h" | 5 #include "content/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 18 matching lines...) Expand all Loading... |
29 #include "content/common/child_process_host_impl.h" | 29 #include "content/common/child_process_host_impl.h" |
30 #include "content/common/plugin_process_messages.h" | 30 #include "content/common/plugin_process_messages.h" |
31 #include "content/common/resource_messages.h" | 31 #include "content/common/resource_messages.h" |
32 #include "content/public/browser/browser_thread.h" | 32 #include "content/public/browser/browser_thread.h" |
33 #include "content/public/browser/content_browser_client.h" | 33 #include "content/public/browser/content_browser_client.h" |
34 #include "content/public/browser/notification_types.h" | 34 #include "content/public/browser/notification_types.h" |
35 #include "content/public/browser/plugin_service.h" | 35 #include "content/public/browser/plugin_service.h" |
36 #include "content/public/browser/resource_context.h" | 36 #include "content/public/browser/resource_context.h" |
37 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
38 #include "content/public/common/process_type.h" | 38 #include "content/public/common/process_type.h" |
| 39 #include "content/public/common/sandboxed_process_launcher_delegate.h" |
39 #include "ipc/ipc_switches.h" | 40 #include "ipc/ipc_switches.h" |
40 #include "net/url_request/url_request_context_getter.h" | 41 #include "net/url_request/url_request_context_getter.h" |
41 #include "ui/base/ui_base_switches.h" | 42 #include "ui/base/ui_base_switches.h" |
42 #include "ui/gfx/native_widget_types.h" | 43 #include "ui/gfx/native_widget_types.h" |
43 #include "ui/gl/gl_switches.h" | 44 #include "ui/gl/gl_switches.h" |
44 | 45 |
45 #if defined(USE_X11) | 46 #if defined(USE_X11) |
46 #include "ui/gfx/gtk_native_view_id_manager.h" | 47 #include "ui/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/mac_util.h" | 51 #include "base/mac/mac_util.h" |
51 #include "content/common/plugin_carbon_interpose_constants_mac.h" | 52 #include "content/common/plugin_carbon_interpose_constants_mac.h" |
52 #include "ui/gfx/rect.h" | 53 #include "ui/gfx/rect.h" |
53 #endif | 54 #endif |
54 | 55 |
55 #if defined(OS_WIN) | 56 #if defined(OS_WIN) |
56 #include "base/win/windows_version.h" | 57 #include "base/win/windows_version.h" |
57 #include "content/common/plugin_constants_win.h" | 58 #include "content/common/plugin_constants_win.h" |
58 #include "content/public/common/sandboxed_process_launcher_delegate.h" | |
59 #include "ui/gfx/switches.h" | 59 #include "ui/gfx/switches.h" |
60 #endif | 60 #endif |
61 | 61 |
62 namespace content { | 62 namespace content { |
63 | 63 |
64 #if defined(OS_WIN) | 64 #if defined(OS_WIN) |
65 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { | 65 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { |
66 // The window is destroyed at this point, we just care about its parent, which | 66 // The window is destroyed at this point, we just care about its parent, which |
67 // is the intermediate window we created. | 67 // is the intermediate window we created. |
68 std::set<HWND>::iterator window_index = | 68 std::set<HWND>::iterator window_index = |
69 plugin_parent_windows_set_.find(parent); | 69 plugin_parent_windows_set_.find(parent); |
70 if (window_index == plugin_parent_windows_set_.end()) | 70 if (window_index == plugin_parent_windows_set_.end()) |
71 return; | 71 return; |
72 | 72 |
73 plugin_parent_windows_set_.erase(window_index); | 73 plugin_parent_windows_set_.erase(window_index); |
74 PostMessage(parent, WM_CLOSE, 0, 0); | 74 PostMessage(parent, WM_CLOSE, 0, 0); |
75 } | 75 } |
76 | 76 |
77 void PluginProcessHost::AddWindow(HWND window) { | 77 void PluginProcessHost::AddWindow(HWND window) { |
78 plugin_parent_windows_set_.insert(window); | 78 plugin_parent_windows_set_.insert(window); |
79 } | 79 } |
| 80 #endif // defined(OS_WIN) |
80 | 81 |
81 // NOTE: changes to this class need to be reviewed by the security team. | 82 // NOTE: changes to this class need to be reviewed by the security team. |
82 class PluginSandboxedProcessLauncherDelegate | 83 class PluginSandboxedProcessLauncherDelegate |
83 : public SandboxedProcessLauncherDelegate { | 84 : public SandboxedProcessLauncherDelegate { |
84 public: | 85 public: |
85 PluginSandboxedProcessLauncherDelegate() {} | 86 explicit PluginSandboxedProcessLauncherDelegate(ChildProcessHost* host) |
| 87 #if defined(OS_POSIX) |
| 88 : ipc_fd_(host->TakeClientFileDescriptor()) |
| 89 #endif // OS_POSIX |
| 90 {} |
| 91 |
86 virtual ~PluginSandboxedProcessLauncherDelegate() {} | 92 virtual ~PluginSandboxedProcessLauncherDelegate() {} |
87 | 93 |
88 virtual void ShouldSandbox(bool* in_sandbox) OVERRIDE { | 94 #if defined(OS_WIN) |
89 *in_sandbox = false; | 95 virtual bool ShouldSandbox() OVERRIDE { |
| 96 return false; |
90 } | 97 } |
91 | 98 |
| 99 #elif defined(OS_POSIX) |
| 100 virtual int GetIpcFd() OVERRIDE { |
| 101 return ipc_fd_; |
| 102 } |
| 103 #endif // OS_WIN |
| 104 |
92 private: | 105 private: |
| 106 #if defined(OS_POSIX) |
| 107 int ipc_fd_; |
| 108 #endif // OS_POSIX |
| 109 |
93 DISALLOW_COPY_AND_ASSIGN(PluginSandboxedProcessLauncherDelegate); | 110 DISALLOW_COPY_AND_ASSIGN(PluginSandboxedProcessLauncherDelegate); |
94 }; | 111 }; |
95 | 112 |
96 #endif // defined(OS_WIN) | |
97 | |
98 #if defined(TOOLKIT_GTK) | 113 #if defined(TOOLKIT_GTK) |
99 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, | 114 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, |
100 gfx::PluginWindowHandle* output) { | 115 gfx::PluginWindowHandle* output) { |
101 *output = 0; | 116 *output = 0; |
102 #if !defined(USE_AURA) | 117 #if !defined(USE_AURA) |
103 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); | 118 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); |
104 #endif | 119 #endif |
105 } | 120 } |
106 #endif // defined(TOOLKIT_GTK) | 121 #endif // defined(TOOLKIT_GTK) |
107 | 122 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 interpose_list.insert(0, ":"); | 254 interpose_list.insert(0, ":"); |
240 interpose_list.insert(0, existing_list); | 255 interpose_list.insert(0, existing_list); |
241 } | 256 } |
242 } | 257 } |
243 env[kDYLDInsertLibrariesKey] = interpose_list; | 258 env[kDYLDInsertLibrariesKey] = interpose_list; |
244 } | 259 } |
245 #endif | 260 #endif |
246 #endif | 261 #endif |
247 | 262 |
248 process_->Launch( | 263 process_->Launch( |
249 #if defined(OS_WIN) | 264 new PluginSandboxedProcessLauncherDelegate(process_->GetHost()), |
250 new PluginSandboxedProcessLauncherDelegate, | |
251 false, | |
252 #elif defined(OS_POSIX) | |
253 false, | |
254 env, | |
255 #endif | |
256 cmd_line); | 265 cmd_line); |
257 | 266 |
258 // The plugin needs to be shutdown gracefully, i.e. NP_Shutdown needs to be | 267 // The plugin needs to be shutdown gracefully, i.e. NP_Shutdown needs to be |
259 // called on the plugin. The plugin process exits when it receives the | 268 // called on the plugin. The plugin process exits when it receives the |
260 // OnChannelError notification indicating that the browser plugin channel has | 269 // OnChannelError notification indicating that the browser plugin channel has |
261 // been destroyed. | 270 // been destroyed. |
262 process_->SetTerminateChildOnShutdown(false); | 271 process_->SetTerminateChildOnShutdown(false); |
263 | 272 |
264 ResourceMessageFilter::GetContextsCallback get_contexts_callback( | 273 ResourceMessageFilter::GetContextsCallback get_contexts_callback( |
265 base::Bind(&PluginProcessHost::GetContexts, | 274 base::Bind(&PluginProcessHost::GetContexts, |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 438 |
430 void PluginProcessHost::GetContexts(const ResourceHostMsg_Request& request, | 439 void PluginProcessHost::GetContexts(const ResourceHostMsg_Request& request, |
431 ResourceContext** resource_context, | 440 ResourceContext** resource_context, |
432 net::URLRequestContext** request_context) { | 441 net::URLRequestContext** request_context) { |
433 *resource_context = | 442 *resource_context = |
434 resource_context_map_[request.origin_pid].resource_context; | 443 resource_context_map_[request.origin_pid].resource_context; |
435 *request_context = (*resource_context)->GetRequestContext(); | 444 *request_context = (*resource_context)->GetRequestContext(); |
436 } | 445 } |
437 | 446 |
438 } // namespace content | 447 } // namespace content |
OLD | NEW |