Chromium Code Reviews| 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 | 80 |
| 81 // NOTE: changes to this class need to be reviewed by the security team. | 81 // NOTE: changes to this class need to be reviewed by the security team. |
| 82 class PluginSandboxedProcessLauncherDelegate | 82 class PluginSandboxedProcessLauncherDelegate |
| 83 : public SandboxedProcessLauncherDelegate { | 83 : public SandboxedProcessLauncherDelegate { |
| 84 public: | 84 public: |
| 85 PluginSandboxedProcessLauncherDelegate() {} | 85 explicit PluginSandboxedProcessLauncherDelegate(ChildProcessHost* /*host*/) {} |
| 86 virtual ~PluginSandboxedProcessLauncherDelegate() {} | 86 virtual ~PluginSandboxedProcessLauncherDelegate() {} |
| 87 | 87 |
| 88 virtual void ShouldSandbox(bool* in_sandbox) OVERRIDE { | 88 virtual void ShouldSandbox(bool* in_sandbox) OVERRIDE { |
| 89 *in_sandbox = false; | 89 *in_sandbox = false; |
| 90 } | 90 } |
| 91 | |
| 92 private: | 91 private: |
| 93 DISALLOW_COPY_AND_ASSIGN(PluginSandboxedProcessLauncherDelegate); | 92 DISALLOW_COPY_AND_ASSIGN(PluginSandboxedProcessLauncherDelegate); |
| 94 }; | 93 }; |
| 95 | 94 |
| 95 #elif defined(OS_POSIX) | |
| 96 | |
| 97 // NOTE: changes to this class need to be reviewed by the security team. | |
| 98 class PluginSandboxedProcessLauncherDelegate | |
|
jam
2014/02/26 19:47:52
ditto
aberent
2014/02/28 08:51:06
Done.
| |
| 99 : public SandboxedProcessLauncherDelegate { | |
| 100 public: | |
| 101 explicit PluginSandboxedProcessLauncherDelegate(ChildProcessHost* host) | |
| 102 : ipc_fd_(host->TakeClientFileDescriptor()) {} | |
| 103 | |
| 104 virtual ~PluginSandboxedProcessLauncherDelegate() {} | |
| 105 | |
| 106 virtual int IpcFd() OVERRIDE { | |
| 107 return ipc_fd_; | |
| 108 } | |
| 109 private: | |
| 110 int ipc_fd_; | |
| 111 DISALLOW_COPY_AND_ASSIGN(PluginSandboxedProcessLauncherDelegate); | |
| 112 }; | |
| 96 #endif // defined(OS_WIN) | 113 #endif // defined(OS_WIN) |
| 97 | 114 |
| 98 #if defined(TOOLKIT_GTK) | 115 #if defined(TOOLKIT_GTK) |
| 99 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, | 116 void PluginProcessHost::OnMapNativeViewId(gfx::NativeViewId id, |
| 100 gfx::PluginWindowHandle* output) { | 117 gfx::PluginWindowHandle* output) { |
| 101 *output = 0; | 118 *output = 0; |
| 102 #if !defined(USE_AURA) | 119 #if !defined(USE_AURA) |
| 103 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); | 120 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); |
| 104 #endif | 121 #endif |
| 105 } | 122 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 interpose_list.insert(0, ":"); | 257 interpose_list.insert(0, ":"); |
| 241 interpose_list.insert(0, existing_list); | 258 interpose_list.insert(0, existing_list); |
| 242 } | 259 } |
| 243 } | 260 } |
| 244 env[kDYLDInsertLibrariesKey] = interpose_list; | 261 env[kDYLDInsertLibrariesKey] = interpose_list; |
| 245 } | 262 } |
| 246 #endif | 263 #endif |
| 247 #endif | 264 #endif |
| 248 | 265 |
| 249 process_->Launch( | 266 process_->Launch( |
| 250 #if defined(OS_WIN) | 267 new PluginSandboxedProcessLauncherDelegate(process_->GetHost()), |
| 251 new PluginSandboxedProcessLauncherDelegate, | |
| 252 false, | |
| 253 #elif defined(OS_POSIX) | |
| 254 false, | |
| 255 env, | |
| 256 #endif | |
| 257 cmd_line); | 268 cmd_line); |
| 258 | 269 |
| 259 // The plugin needs to be shutdown gracefully, i.e. NP_Shutdown needs to be | 270 // The plugin needs to be shutdown gracefully, i.e. NP_Shutdown needs to be |
| 260 // called on the plugin. The plugin process exits when it receives the | 271 // called on the plugin. The plugin process exits when it receives the |
| 261 // OnChannelError notification indicating that the browser plugin channel has | 272 // OnChannelError notification indicating that the browser plugin channel has |
| 262 // been destroyed. | 273 // been destroyed. |
| 263 process_->SetTerminateChildOnShutdown(false); | 274 process_->SetTerminateChildOnShutdown(false); |
| 264 | 275 |
| 265 ResourceMessageFilter::GetContextsCallback get_contexts_callback( | 276 ResourceMessageFilter::GetContextsCallback get_contexts_callback( |
| 266 base::Bind(&PluginProcessHost::GetContexts, | 277 base::Bind(&PluginProcessHost::GetContexts, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 430 | 441 |
| 431 void PluginProcessHost::GetContexts(const ResourceHostMsg_Request& request, | 442 void PluginProcessHost::GetContexts(const ResourceHostMsg_Request& request, |
| 432 ResourceContext** resource_context, | 443 ResourceContext** resource_context, |
| 433 net::URLRequestContext** request_context) { | 444 net::URLRequestContext** request_context) { |
| 434 *resource_context = | 445 *resource_context = |
| 435 resource_context_map_[request.origin_pid].resource_context; | 446 resource_context_map_[request.origin_pid].resource_context; |
| 436 *request_context = (*resource_context)->GetRequestContext(); | 447 *request_context = (*resource_context)->GetRequestContext(); |
| 437 } | 448 } |
| 438 | 449 |
| 439 } // namespace content | 450 } // namespace content |
| OLD | NEW |