| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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) && !defined(USE_AURA) | 7 #if defined(OS_WIN) && !defined(USE_AURA) |
| 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<> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/base_switches.h" | 15 #include "base/base_switches.h" |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/file_path.h" | 18 #include "base/file_path.h" |
| 19 #include "base/file_util.h" | 19 #include "base/file_util.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
| 24 #include "content/browser/plugin_service.h" | 24 #include "content/browser/plugin_service.h" |
| 25 #include "content/common/child_process_host.h" | 25 #include "content/common/child_process_host_impl.h" |
| 26 #include "content/common/plugin_messages.h" | 26 #include "content/common/plugin_messages.h" |
| 27 #include "content/common/resource_messages.h" | 27 #include "content/common/resource_messages.h" |
| 28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/content_browser_client.h" | 29 #include "content/public/browser/content_browser_client.h" |
| 30 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
| 31 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 32 #include "content/public/common/process_type.h" | 32 #include "content/public/common/process_type.h" |
| 33 #include "ipc/ipc_switches.h" | 33 #include "ipc/ipc_switches.h" |
| 34 #include "ui/base/ui_base_switches.h" | 34 #include "ui/base/ui_base_switches.h" |
| 35 #include "ui/gfx/gl/gl_switches.h" | 35 #include "ui/gfx/gl/gl_switches.h" |
| 36 #include "ui/gfx/native_widget_types.h" | 36 #include "ui/gfx/native_widget_types.h" |
| 37 | 37 |
| 38 using content::BrowserThread; | 38 using content::BrowserThread; |
| 39 using content::ChildProcessHost; |
| 39 | 40 |
| 40 #if defined(USE_X11) | 41 #if defined(USE_X11) |
| 41 #include "ui/gfx/gtk_native_view_id_manager.h" | 42 #include "ui/gfx/gtk_native_view_id_manager.h" |
| 42 #endif | 43 #endif |
| 43 | 44 |
| 44 #if defined(OS_MACOSX) | 45 #if defined(OS_MACOSX) |
| 45 #include "base/mac/mac_util.h" | 46 #include "base/mac/mac_util.h" |
| 46 #include "content/common/plugin_carbon_interpose_constants_mac.h" | 47 #include "content/common/plugin_carbon_interpose_constants_mac.h" |
| 47 #include "ui/gfx/rect.h" | 48 #include "ui/gfx/rect.h" |
| 48 #endif | 49 #endif |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 #endif | 162 #endif |
| 162 // Cancel all pending and sent requests. | 163 // Cancel all pending and sent requests. |
| 163 CancelRequests(); | 164 CancelRequests(); |
| 164 } | 165 } |
| 165 | 166 |
| 166 bool PluginProcessHost::Init(const webkit::WebPluginInfo& info, | 167 bool PluginProcessHost::Init(const webkit::WebPluginInfo& info, |
| 167 const std::string& locale) { | 168 const std::string& locale) { |
| 168 info_ = info; | 169 info_ = info; |
| 169 set_name(info_.name); | 170 set_name(info_.name); |
| 170 | 171 |
| 171 if (!child_process_host()->CreateChannel()) | 172 std::string channel_id = child_process_host()->CreateChannel(); |
| 173 if (channel_id.empty()) |
| 172 return false; | 174 return false; |
| 173 | 175 |
| 174 // Build command line for plugin. When we have a plugin launcher, we can't | 176 // Build command line for plugin. When we have a plugin launcher, we can't |
| 175 // allow "self" on linux and we need the real file path. | 177 // allow "self" on linux and we need the real file path. |
| 176 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 178 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 177 CommandLine::StringType plugin_launcher = | 179 CommandLine::StringType plugin_launcher = |
| 178 browser_command_line.GetSwitchValueNative(switches::kPluginLauncher); | 180 browser_command_line.GetSwitchValueNative(switches::kPluginLauncher); |
| 179 | 181 |
| 180 #if defined(OS_MACOSX) | 182 #if defined(OS_MACOSX) |
| 181 // Run the plug-in process in a mode tolerant of heap execution without | 183 // Run the plug-in process in a mode tolerant of heap execution without |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 // If specified, prepend a launcher program to the command line. | 230 // If specified, prepend a launcher program to the command line. |
| 229 if (!plugin_launcher.empty()) | 231 if (!plugin_launcher.empty()) |
| 230 cmd_line->PrependWrapper(plugin_launcher); | 232 cmd_line->PrependWrapper(plugin_launcher); |
| 231 | 233 |
| 232 if (!locale.empty()) { | 234 if (!locale.empty()) { |
| 233 // Pass on the locale so the null plugin will use the right language in the | 235 // Pass on the locale so the null plugin will use the right language in the |
| 234 // prompt to install the desired plugin. | 236 // prompt to install the desired plugin. |
| 235 cmd_line->AppendSwitchASCII(switches::kLang, locale); | 237 cmd_line->AppendSwitchASCII(switches::kLang, locale); |
| 236 } | 238 } |
| 237 | 239 |
| 238 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, | 240 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| 239 child_process_host()->channel_id()); | |
| 240 | 241 |
| 241 #if defined(OS_POSIX) | 242 #if defined(OS_POSIX) |
| 242 base::environment_vector env; | 243 base::environment_vector env; |
| 243 #if defined(OS_MACOSX) && !defined(__LP64__) | 244 #if defined(OS_MACOSX) && !defined(__LP64__) |
| 244 // Add our interposing library for Carbon. This is stripped back out in | 245 // Add our interposing library for Carbon. This is stripped back out in |
| 245 // plugin_main.cc, so changes here should be reflected there. | 246 // plugin_main.cc, so changes here should be reflected there. |
| 246 std::string interpose_list(plugin_interpose_strings::kInterposeLibraryPath); | 247 std::string interpose_list(plugin_interpose_strings::kInterposeLibraryPath); |
| 247 const char* existing_list = | 248 const char* existing_list = |
| 248 getenv(plugin_interpose_strings::kDYLDInsertLibrariesKey); | 249 getenv(plugin_interpose_strings::kDYLDInsertLibrariesKey); |
| 249 if (existing_list) { | 250 if (existing_list) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 host->pending_requests_.erase(host->pending_requests_.begin() + i); | 360 host->pending_requests_.erase(host->pending_requests_.begin() + i); |
| 360 --i; | 361 --i; |
| 361 } | 362 } |
| 362 } | 363 } |
| 363 } | 364 } |
| 364 } | 365 } |
| 365 | 366 |
| 366 void PluginProcessHost::OpenChannelToPlugin(Client* client) { | 367 void PluginProcessHost::OpenChannelToPlugin(Client* client) { |
| 367 Notify(content::NOTIFICATION_CHILD_INSTANCE_CREATED); | 368 Notify(content::NOTIFICATION_CHILD_INSTANCE_CREATED); |
| 368 client->SetPluginInfo(info_); | 369 client->SetPluginInfo(info_); |
| 369 if (child_process_host()->opening_channel()) { | 370 if (child_process_host()->IsChannelOpening()) { |
| 370 // The channel is already in the process of being opened. Put | 371 // The channel is already in the process of being opened. Put |
| 371 // this "open channel" request into a queue of requests that will | 372 // this "open channel" request into a queue of requests that will |
| 372 // be run once the channel is open. | 373 // be run once the channel is open. |
| 373 pending_requests_.push_back(client); | 374 pending_requests_.push_back(client); |
| 374 return; | 375 return; |
| 375 } | 376 } |
| 376 | 377 |
| 377 // We already have an open channel, send a request right away to plugin. | 378 // We already have an open channel, send a request right away to plugin. |
| 378 RequestPluginChannel(client); | 379 RequestPluginChannel(client); |
| 379 } | 380 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 } | 423 } |
| 423 | 424 |
| 424 void PluginProcessHost::OnChannelCreated( | 425 void PluginProcessHost::OnChannelCreated( |
| 425 const IPC::ChannelHandle& channel_handle) { | 426 const IPC::ChannelHandle& channel_handle) { |
| 426 Client* client = sent_requests_.front(); | 427 Client* client = sent_requests_.front(); |
| 427 | 428 |
| 428 if (client) | 429 if (client) |
| 429 client->OnChannelOpened(channel_handle); | 430 client->OnChannelOpened(channel_handle); |
| 430 sent_requests_.pop_front(); | 431 sent_requests_.pop_front(); |
| 431 } | 432 } |
| OLD | NEW |