| 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 21 matching lines...) Expand all Loading... |
| 32 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.h" |
| 33 #include "content/public/browser/notification_types.h" | 33 #include "content/public/browser/notification_types.h" |
| 34 #include "content/public/browser/plugin_service.h" | 34 #include "content/public/browser/plugin_service.h" |
| 35 #include "content/public/common/content_switches.h" | 35 #include "content/public/common/content_switches.h" |
| 36 #include "content/public/common/process_type.h" | 36 #include "content/public/common/process_type.h" |
| 37 #include "ipc/ipc_switches.h" | 37 #include "ipc/ipc_switches.h" |
| 38 #include "ui/base/ui_base_switches.h" | 38 #include "ui/base/ui_base_switches.h" |
| 39 #include "ui/gfx/native_widget_types.h" | 39 #include "ui/gfx/native_widget_types.h" |
| 40 #include "ui/gl/gl_switches.h" | 40 #include "ui/gl/gl_switches.h" |
| 41 | 41 |
| 42 using content::BrowserThread; | |
| 43 using content::ChildProcessData; | |
| 44 using content::ChildProcessHost; | |
| 45 | |
| 46 #if defined(USE_X11) | 42 #if defined(USE_X11) |
| 47 #include "ui/gfx/gtk_native_view_id_manager.h" | 43 #include "ui/gfx/gtk_native_view_id_manager.h" |
| 48 #endif | 44 #endif |
| 49 | 45 |
| 50 #if defined(OS_MACOSX) | 46 #if defined(OS_MACOSX) |
| 51 #include "base/mac/mac_util.h" | 47 #include "base/mac/mac_util.h" |
| 52 #include "content/common/plugin_carbon_interpose_constants_mac.h" | 48 #include "content/common/plugin_carbon_interpose_constants_mac.h" |
| 53 #include "ui/gfx/rect.h" | 49 #include "ui/gfx/rect.h" |
| 54 #endif | 50 #endif |
| 55 | 51 |
| 56 #if defined(OS_WIN) | 52 #if defined(OS_WIN) |
| 57 #include "base/win/windows_version.h" | 53 #include "base/win/windows_version.h" |
| 58 #include "webkit/plugins/npapi/plugin_constants_win.h" | 54 #include "webkit/plugins/npapi/plugin_constants_win.h" |
| 59 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 55 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 56 #endif |
| 60 | 57 |
| 58 namespace content { |
| 59 |
| 60 #if defined(OS_WIN) |
| 61 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { | 61 void PluginProcessHost::OnPluginWindowDestroyed(HWND window, HWND parent) { |
| 62 // The window is destroyed at this point, we just care about its parent, which | 62 // The window is destroyed at this point, we just care about its parent, which |
| 63 // is the intermediate window we created. | 63 // is the intermediate window we created. |
| 64 std::set<HWND>::iterator window_index = | 64 std::set<HWND>::iterator window_index = |
| 65 plugin_parent_windows_set_.find(parent); | 65 plugin_parent_windows_set_.find(parent); |
| 66 if (window_index == plugin_parent_windows_set_.end()) | 66 if (window_index == plugin_parent_windows_set_.end()) |
| 67 return; | 67 return; |
| 68 | 68 |
| 69 plugin_parent_windows_set_.erase(window_index); | 69 plugin_parent_windows_set_.erase(window_index); |
| 70 PostMessage(parent, WM_CLOSE, 0, 0); | 70 PostMessage(parent, WM_CLOSE, 0, 0); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 84 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); | 84 GtkNativeViewManager::GetInstance()->GetXIDForId(output, id); |
| 85 #endif | 85 #endif |
| 86 } | 86 } |
| 87 #endif // defined(TOOLKIT_GTK) | 87 #endif // defined(TOOLKIT_GTK) |
| 88 | 88 |
| 89 PluginProcessHost::PluginProcessHost() | 89 PluginProcessHost::PluginProcessHost() |
| 90 #if defined(OS_MACOSX) | 90 #if defined(OS_MACOSX) |
| 91 : plugin_cursor_visible_(true) | 91 : plugin_cursor_visible_(true) |
| 92 #endif | 92 #endif |
| 93 { | 93 { |
| 94 process_.reset( | 94 process_.reset(new BrowserChildProcessHostImpl(PROCESS_TYPE_PLUGIN, this)); |
| 95 new BrowserChildProcessHostImpl(content::PROCESS_TYPE_PLUGIN, this)); | |
| 96 } | 95 } |
| 97 | 96 |
| 98 PluginProcessHost::~PluginProcessHost() { | 97 PluginProcessHost::~PluginProcessHost() { |
| 99 #if defined(OS_WIN) | 98 #if defined(OS_WIN) |
| 100 // We erase HWNDs from the plugin_parent_windows_set_ when we receive a | 99 // We erase HWNDs from the plugin_parent_windows_set_ when we receive a |
| 101 // notification that the window is being destroyed. If we don't receive this | 100 // notification that the window is being destroyed. If we don't receive this |
| 102 // notification and the PluginProcessHost instance is being destroyed, it | 101 // notification and the PluginProcessHost instance is being destroyed, it |
| 103 // means that the plugin process crashed. We paint a sad face in this case in | 102 // means that the plugin process crashed. We paint a sad face in this case in |
| 104 // the renderer process. To ensure that the sad face shows up, and we don't | 103 // the renderer process. To ensure that the sad face shows up, and we don't |
| 105 // leak HWNDs, we should destroy existing plugin parent windows. | 104 // leak HWNDs, we should destroy existing plugin parent windows. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 | 200 |
| 202 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, | 201 cmd_line->CopySwitchesFrom(browser_command_line, kSwitchNames, |
| 203 arraysize(kSwitchNames)); | 202 arraysize(kSwitchNames)); |
| 204 | 203 |
| 205 GpuDataManagerImpl::GetInstance()->AppendPluginCommandLine(cmd_line); | 204 GpuDataManagerImpl::GetInstance()->AppendPluginCommandLine(cmd_line); |
| 206 | 205 |
| 207 // If specified, prepend a launcher program to the command line. | 206 // If specified, prepend a launcher program to the command line. |
| 208 if (!plugin_launcher.empty()) | 207 if (!plugin_launcher.empty()) |
| 209 cmd_line->PrependWrapper(plugin_launcher); | 208 cmd_line->PrependWrapper(plugin_launcher); |
| 210 | 209 |
| 211 std::string locale = | 210 std::string locale = GetContentClient()->browser()->GetApplicationLocale(); |
| 212 content::GetContentClient()->browser()->GetApplicationLocale(); | |
| 213 if (!locale.empty()) { | 211 if (!locale.empty()) { |
| 214 // Pass on the locale so the null plugin will use the right language in the | 212 // Pass on the locale so the null plugin will use the right language in the |
| 215 // prompt to install the desired plugin. | 213 // prompt to install the desired plugin. |
| 216 cmd_line->AppendSwitchASCII(switches::kLang, locale); | 214 cmd_line->AppendSwitchASCII(switches::kLang, locale); |
| 217 } | 215 } |
| 218 | 216 |
| 219 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); | 217 cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| 220 | 218 |
| 221 #if defined(OS_POSIX) | 219 #if defined(OS_POSIX) |
| 222 base::EnvironmentVector env; | 220 base::EnvironmentVector env; |
| 223 #if defined(OS_MACOSX) && !defined(__LP64__) | 221 #if defined(OS_MACOSX) && !defined(__LP64__) |
| 224 if (!browser_command_line.HasSwitch(switches::kDisableCarbonInterposing)) { | 222 if (!browser_command_line.HasSwitch(switches::kDisableCarbonInterposing)) { |
| 225 std::string interpose_list = | 223 std::string interpose_list = GetContentClient()->GetCarbonInterposePath(); |
| 226 content::GetContentClient()->GetCarbonInterposePath(); | |
| 227 if (!interpose_list.empty()) { | 224 if (!interpose_list.empty()) { |
| 228 // Add our interposing library for Carbon. This is stripped back out in | 225 // Add our interposing library for Carbon. This is stripped back out in |
| 229 // plugin_main.cc, so changes here should be reflected there. | 226 // plugin_main.cc, so changes here should be reflected there. |
| 230 const char* existing_list = | 227 const char* existing_list = getenv(kDYLDInsertLibrariesKey); |
| 231 getenv(plugin_interpose_strings::kDYLDInsertLibrariesKey); | |
| 232 if (existing_list) { | 228 if (existing_list) { |
| 233 interpose_list.insert(0, ":"); | 229 interpose_list.insert(0, ":"); |
| 234 interpose_list.insert(0, existing_list); | 230 interpose_list.insert(0, existing_list); |
| 235 } | 231 } |
| 236 } | 232 } |
| 237 env.push_back(std::pair<std::string, std::string>( | 233 env.push_back(std::pair<std::string, std::string>( |
| 238 plugin_interpose_strings::kDYLDInsertLibrariesKey, | 234 kDYLDInsertLibrariesKey, interpose_list)); |
| 239 interpose_list)); | |
| 240 } | 235 } |
| 241 #endif | 236 #endif |
| 242 #endif | 237 #endif |
| 243 | 238 |
| 244 process_->Launch( | 239 process_->Launch( |
| 245 #if defined(OS_WIN) | 240 #if defined(OS_WIN) |
| 246 FilePath(), | 241 FilePath(), |
| 247 #elif defined(OS_POSIX) | 242 #elif defined(OS_POSIX) |
| 248 false, | 243 false, |
| 249 env, | 244 env, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 while (!sent_requests_.empty()) { | 321 while (!sent_requests_.empty()) { |
| 327 Client* client = sent_requests_.front(); | 322 Client* client = sent_requests_.front(); |
| 328 if (client) | 323 if (client) |
| 329 client->OnError(); | 324 client->OnError(); |
| 330 sent_requests_.pop_front(); | 325 sent_requests_.pop_front(); |
| 331 } | 326 } |
| 332 } | 327 } |
| 333 | 328 |
| 334 // static | 329 // static |
| 335 void PluginProcessHost::CancelPendingRequestsForResourceContext( | 330 void PluginProcessHost::CancelPendingRequestsForResourceContext( |
| 336 content::ResourceContext* context) { | 331 ResourceContext* context) { |
| 337 for (PluginProcessHostIterator host_it; !host_it.Done(); ++host_it) { | 332 for (PluginProcessHostIterator host_it; !host_it.Done(); ++host_it) { |
| 338 PluginProcessHost* host = *host_it; | 333 PluginProcessHost* host = *host_it; |
| 339 for (size_t i = 0; i < host->pending_requests_.size(); ++i) { | 334 for (size_t i = 0; i < host->pending_requests_.size(); ++i) { |
| 340 if (host->pending_requests_[i]->GetResourceContext() == context) { | 335 if (host->pending_requests_[i]->GetResourceContext() == context) { |
| 341 host->pending_requests_[i]->OnError(); | 336 host->pending_requests_[i]->OnError(); |
| 342 host->pending_requests_.erase(host->pending_requests_.begin() + i); | 337 host->pending_requests_.erase(host->pending_requests_.begin() + i); |
| 343 --i; | 338 --i; |
| 344 } | 339 } |
| 345 } | 340 } |
| 346 } | 341 } |
| 347 } | 342 } |
| 348 | 343 |
| 349 void PluginProcessHost::OpenChannelToPlugin(Client* client) { | 344 void PluginProcessHost::OpenChannelToPlugin(Client* client) { |
| 350 process_->Notify(content::NOTIFICATION_CHILD_INSTANCE_CREATED); | 345 process_->Notify(NOTIFICATION_CHILD_INSTANCE_CREATED); |
| 351 client->SetPluginInfo(info_); | 346 client->SetPluginInfo(info_); |
| 352 if (process_->GetHost()->IsChannelOpening()) { | 347 if (process_->GetHost()->IsChannelOpening()) { |
| 353 // The channel is already in the process of being opened. Put | 348 // The channel is already in the process of being opened. Put |
| 354 // this "open channel" request into a queue of requests that will | 349 // this "open channel" request into a queue of requests that will |
| 355 // be run once the channel is open. | 350 // be run once the channel is open. |
| 356 pending_requests_.push_back(client); | 351 pending_requests_.push_back(client); |
| 357 return; | 352 return; |
| 358 } | 353 } |
| 359 | 354 |
| 360 // We already have an open channel, send a request right away to plugin. | 355 // We already have an open channel, send a request right away to plugin. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 400 } |
| 406 | 401 |
| 407 void PluginProcessHost::OnChannelCreated( | 402 void PluginProcessHost::OnChannelCreated( |
| 408 const IPC::ChannelHandle& channel_handle) { | 403 const IPC::ChannelHandle& channel_handle) { |
| 409 Client* client = sent_requests_.front(); | 404 Client* client = sent_requests_.front(); |
| 410 | 405 |
| 411 if (client) | 406 if (client) |
| 412 client->OnChannelOpened(channel_handle); | 407 client->OnChannelOpened(channel_handle); |
| 413 sent_requests_.pop_front(); | 408 sent_requests_.pop_front(); |
| 414 } | 409 } |
| 410 |
| 411 } // namespace content |
| OLD | NEW |