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/ppapi_plugin_process_host.h" | 5 #include "content/browser/ppapi_plugin_process_host.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 namespace content { | 54 namespace content { |
55 | 55 |
56 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 56 #if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
57 ZygoteHandle g_ppapi_zygote; | 57 ZygoteHandle g_ppapi_zygote; |
58 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) | 58 #endif // defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX) |
59 | 59 |
60 // NOTE: changes to this class need to be reviewed by the security team. | 60 // NOTE: changes to this class need to be reviewed by the security team. |
61 class PpapiPluginSandboxedProcessLauncherDelegate | 61 class PpapiPluginSandboxedProcessLauncherDelegate |
62 : public content::SandboxedProcessLauncherDelegate { | 62 : public content::SandboxedProcessLauncherDelegate { |
63 public: | 63 public: |
64 PpapiPluginSandboxedProcessLauncherDelegate(bool is_broker, | 64 explicit PpapiPluginSandboxedProcessLauncherDelegate(bool is_broker) |
65 ChildProcessHost* host) | 65 #if (defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)) || \ |
66 #if defined(OS_WIN) | 66 defined(OS_WIN) |
67 : is_broker_(is_broker) { | 67 : is_broker_(is_broker) |
68 #elif defined(OS_MACOSX) || defined(OS_ANDROID) | 68 #endif |
69 : ipc_fd_(host->TakeClientFileDescriptor()) { | |
70 #elif defined(OS_POSIX) | |
71 : ipc_fd_(host->TakeClientFileDescriptor()), is_broker_(is_broker) { | |
72 #else | |
73 { | 69 { |
74 #endif | |
75 } | 70 } |
76 | 71 |
77 ~PpapiPluginSandboxedProcessLauncherDelegate() override {} | 72 ~PpapiPluginSandboxedProcessLauncherDelegate() override {} |
78 | 73 |
79 #if defined(OS_WIN) | 74 #if defined(OS_WIN) |
80 bool ShouldSandbox() override { | 75 bool ShouldSandbox() override { |
81 return !is_broker_; | 76 return !is_broker_; |
82 } | 77 } |
83 | 78 |
84 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { | 79 bool PreSpawnTarget(sandbox::TargetPolicy* policy) override { |
(...skipping 22 matching lines...) Expand all Loading... |
107 } | 102 } |
108 #endif | 103 #endif |
109 const base::string16& sid = | 104 const base::string16& sid = |
110 browser_client->GetAppContainerSidForSandboxType(GetSandboxType()); | 105 browser_client->GetAppContainerSidForSandboxType(GetSandboxType()); |
111 if (!sid.empty()) | 106 if (!sid.empty()) |
112 AddAppContainerPolicy(policy, sid.c_str()); | 107 AddAppContainerPolicy(policy, sid.c_str()); |
113 | 108 |
114 return true; | 109 return true; |
115 } | 110 } |
116 | 111 |
117 #elif defined(OS_POSIX) | 112 #elif defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
118 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) | |
119 ZygoteHandle* GetZygote() override { | 113 ZygoteHandle* GetZygote() override { |
120 const base::CommandLine& browser_command_line = | 114 const base::CommandLine& browser_command_line = |
121 *base::CommandLine::ForCurrentProcess(); | 115 *base::CommandLine::ForCurrentProcess(); |
122 base::CommandLine::StringType plugin_launcher = browser_command_line | 116 base::CommandLine::StringType plugin_launcher = browser_command_line |
123 .GetSwitchValueNative(switches::kPpapiPluginLauncher); | 117 .GetSwitchValueNative(switches::kPpapiPluginLauncher); |
124 if (is_broker_ || !plugin_launcher.empty()) | 118 if (is_broker_ || !plugin_launcher.empty()) |
125 return nullptr; | 119 return nullptr; |
126 return GetGenericZygote(); | 120 return GetGenericZygote(); |
127 } | 121 } |
128 #endif // !defined(OS_MACOSX) && !defined(OS_ANDROID) | |
129 | |
130 base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } | |
131 #endif // OS_WIN | 122 #endif // OS_WIN |
132 | 123 |
133 SandboxType GetSandboxType() override { | 124 SandboxType GetSandboxType() override { |
134 return SANDBOX_TYPE_PPAPI; | 125 return SANDBOX_TYPE_PPAPI; |
135 } | 126 } |
136 | 127 |
137 private: | 128 private: |
138 #if defined(OS_POSIX) | |
139 base::ScopedFD ipc_fd_; | |
140 #endif // OS_POSIX | |
141 #if (defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)) || \ | 129 #if (defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)) || \ |
142 defined(OS_WIN) | 130 defined(OS_WIN) |
143 bool is_broker_; | 131 bool is_broker_; |
144 #endif | 132 #endif |
145 | 133 |
146 DISALLOW_COPY_AND_ASSIGN(PpapiPluginSandboxedProcessLauncherDelegate); | 134 DISALLOW_COPY_AND_ASSIGN(PpapiPluginSandboxedProcessLauncherDelegate); |
147 }; | 135 }; |
148 | 136 |
149 class PpapiPluginProcessHost::PluginNetworkObserver | 137 class PpapiPluginProcessHost::PluginNetworkObserver |
150 : public net::NetworkChangeNotifier::IPAddressObserver, | 138 : public net::NetworkChangeNotifier::IPAddressObserver, |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 switches::kPpapiSubpixelRenderingSetting, | 428 switches::kPpapiSubpixelRenderingSetting, |
441 base::IntToString(font_params.subpixel_rendering)); | 429 base::IntToString(font_params.subpixel_rendering)); |
442 #endif | 430 #endif |
443 | 431 |
444 if (!plugin_launcher.empty()) | 432 if (!plugin_launcher.empty()) |
445 cmd_line->PrependWrapper(plugin_launcher); | 433 cmd_line->PrependWrapper(plugin_launcher); |
446 | 434 |
447 // On posix, never use the zygote for the broker. Also, only use the zygote if | 435 // On posix, never use the zygote for the broker. Also, only use the zygote if |
448 // we are not using a plugin launcher - having a plugin launcher means we need | 436 // we are not using a plugin launcher - having a plugin launcher means we need |
449 // to use another process instead of just forking the zygote. | 437 // to use another process instead of just forking the zygote. |
450 process_->Launch(new PpapiPluginSandboxedProcessLauncherDelegate( | 438 process_->Launch(new PpapiPluginSandboxedProcessLauncherDelegate(is_broker_), |
451 is_broker_, process_->GetHost()), | |
452 cmd_line, true); | 439 cmd_line, true); |
453 return true; | 440 return true; |
454 } | 441 } |
455 | 442 |
456 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { | 443 void PpapiPluginProcessHost::RequestPluginChannel(Client* client) { |
457 base::ProcessHandle process_handle; | 444 base::ProcessHandle process_handle; |
458 int renderer_child_id; | 445 int renderer_child_id; |
459 client->GetPpapiChannelInfo(&process_handle, &renderer_child_id); | 446 client->GetPpapiChannelInfo(&process_handle, &renderer_child_id); |
460 | 447 |
461 base::ProcessId process_id = base::kNullProcessId; | 448 base::ProcessId process_id = base::kNullProcessId; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 // sent_requests_ queue should be the one that the plugin just created. | 536 // sent_requests_ queue should be the one that the plugin just created. |
550 Client* client = sent_requests_.front(); | 537 Client* client = sent_requests_.front(); |
551 sent_requests_.pop(); | 538 sent_requests_.pop(); |
552 | 539 |
553 const ChildProcessData& data = process_->GetData(); | 540 const ChildProcessData& data = process_->GetData(); |
554 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), | 541 client->OnPpapiChannelOpened(channel_handle, base::GetProcId(data.handle), |
555 data.id); | 542 data.id); |
556 } | 543 } |
557 | 544 |
558 } // namespace content | 545 } // namespace content |
OLD | NEW |