| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 interpose_list.insert(0, ":"); | 255 interpose_list.insert(0, ":"); |
| 241 interpose_list.insert(0, existing_list); | 256 interpose_list.insert(0, existing_list); |
| 242 } | 257 } |
| 243 } | 258 } |
| 244 env[kDYLDInsertLibrariesKey] = interpose_list; | 259 env[kDYLDInsertLibrariesKey] = interpose_list; |
| 245 } | 260 } |
| 246 #endif | 261 #endif |
| 247 #endif | 262 #endif |
| 248 | 263 |
| 249 process_->Launch( | 264 process_->Launch( |
| 250 #if defined(OS_WIN) | 265 new PluginSandboxedProcessLauncherDelegate(process_->GetHost()), |
| 251 new PluginSandboxedProcessLauncherDelegate, | |
| 252 false, | |
| 253 #elif defined(OS_POSIX) | |
| 254 false, | |
| 255 env, | |
| 256 #endif | |
| 257 cmd_line); | 266 cmd_line); |
| 258 | 267 |
| 259 // The plugin needs to be shutdown gracefully, i.e. NP_Shutdown needs to be | 268 // 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 | 269 // called on the plugin. The plugin process exits when it receives the |
| 261 // OnChannelError notification indicating that the browser plugin channel has | 270 // OnChannelError notification indicating that the browser plugin channel has |
| 262 // been destroyed. | 271 // been destroyed. |
| 263 process_->SetTerminateChildOnShutdown(false); | 272 process_->SetTerminateChildOnShutdown(false); |
| 264 | 273 |
| 265 ResourceMessageFilter::GetContextsCallback get_contexts_callback( | 274 ResourceMessageFilter::GetContextsCallback get_contexts_callback( |
| 266 base::Bind(&PluginProcessHost::GetContexts, | 275 base::Bind(&PluginProcessHost::GetContexts, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 | 439 |
| 431 void PluginProcessHost::GetContexts(const ResourceHostMsg_Request& request, | 440 void PluginProcessHost::GetContexts(const ResourceHostMsg_Request& request, |
| 432 ResourceContext** resource_context, | 441 ResourceContext** resource_context, |
| 433 net::URLRequestContext** request_context) { | 442 net::URLRequestContext** request_context) { |
| 434 *resource_context = | 443 *resource_context = |
| 435 resource_context_map_[request.origin_pid].resource_context; | 444 resource_context_map_[request.origin_pid].resource_context; |
| 436 *request_context = (*resource_context)->GetRequestContext(); | 445 *request_context = (*resource_context)->GetRequestContext(); |
| 437 } | 446 } |
| 438 | 447 |
| 439 } // namespace content | 448 } // namespace content |
| OLD | NEW |