| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/plugin_service.h" | 7 #include "chrome/browser/plugin_service.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 134 |
| 135 // This plugin isn't loaded by any plugin process, so create a new process. | 135 // This plugin isn't loaded by any plugin process, so create a new process. |
| 136 plugin_host = new PluginProcessHost(); | 136 plugin_host = new PluginProcessHost(); |
| 137 if (!plugin_host->Init(info, clsid, ui_locale_)) { | 137 if (!plugin_host->Init(info, clsid, ui_locale_)) { |
| 138 DCHECK(false); // Init is not expected to fail | 138 DCHECK(false); // Init is not expected to fail |
| 139 delete plugin_host; | 139 delete plugin_host; |
| 140 return NULL; | 140 return NULL; |
| 141 } | 141 } |
| 142 | 142 |
| 143 return plugin_host; | 143 return plugin_host; |
| 144 | |
| 145 // TODO(jabdelmalek): adding a new channel means we can have one less | |
| 146 // renderer process (since each child process uses one handle in the | |
| 147 // IPC thread and main thread's WaitForMultipleObjects call). Limit the | |
| 148 // number of plugin processes. | |
| 149 } | 144 } |
| 150 | 145 |
| 151 void PluginService::OpenChannelToPlugin( | 146 void PluginService::OpenChannelToPlugin( |
| 152 ResourceMessageFilter* renderer_msg_filter, const GURL& url, | 147 ResourceMessageFilter* renderer_msg_filter, const GURL& url, |
| 153 const std::string& mime_type, const std::string& clsid, | 148 const std::string& mime_type, const std::string& clsid, |
| 154 const std::wstring& locale, IPC::Message* reply_msg) { | 149 const std::wstring& locale, IPC::Message* reply_msg) { |
| 155 DCHECK(MessageLoop::current() == | 150 DCHECK(MessageLoop::current() == |
| 156 ChromeThread::GetMessageLoop(ChromeThread::IO)); | 151 ChromeThread::GetMessageLoop(ChromeThread::IO)); |
| 157 // We don't need a policy URL here because that was already checked by a | 152 // We don't need a policy URL here because that was already checked by a |
| 158 // previous call to GetPluginPath. | 153 // previous call to GetPluginPath. |
| 159 GURL policy_url; | 154 GURL policy_url; |
| 160 FilePath plugin_path = GetPluginPath(url, policy_url, mime_type, clsid, NULL); | 155 FilePath plugin_path = GetPluginPath(url, policy_url, mime_type, clsid, NULL); |
| 161 PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path, clsid); | 156 PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path, clsid); |
| 162 if (plugin_host) { | 157 if (plugin_host) { |
| 163 plugin_host->OpenChannelToPlugin(renderer_msg_filter, mime_type, reply_msg); | 158 plugin_host->OpenChannelToPlugin(renderer_msg_filter, mime_type, reply_msg); |
| 164 } else { | 159 } else { |
| 165 PluginProcessHost::ReplyToRenderer(renderer_msg_filter, | 160 PluginProcessHost::ReplyToRenderer(renderer_msg_filter, |
| 166 IPC::ChannelHandle(), | 161 IPC::ChannelHandle(), |
| 167 FilePath(), | 162 WebPluginInfo(), |
| 168 reply_msg); | 163 reply_msg); |
| 169 } | 164 } |
| 170 } | 165 } |
| 171 | 166 |
| 172 FilePath PluginService::GetPluginPath(const GURL& url, | 167 FilePath PluginService::GetPluginPath(const GURL& url, |
| 173 const GURL& policy_url, | 168 const GURL& policy_url, |
| 174 const std::string& mime_type, | 169 const std::string& mime_type, |
| 175 const std::string& clsid, | 170 const std::string& clsid, |
| 176 std::string* actual_mime_type) { | 171 std::string* actual_mime_type) { |
| 177 bool allow_wildcard = true; | 172 bool allow_wildcard = true; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); | 239 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); |
| 245 if (it == private_plugins_.end()) | 240 if (it == private_plugins_.end()) |
| 246 return true; // This plugin is not private, so it's allowed everywhere. | 241 return true; // This plugin is not private, so it's allowed everywhere. |
| 247 | 242 |
| 248 // We do a dumb compare of scheme and host, rather than using the domain | 243 // We do a dumb compare of scheme and host, rather than using the domain |
| 249 // service, since we only care about this for extensions. | 244 // service, since we only care about this for extensions. |
| 250 const GURL& required_url = it->second; | 245 const GURL& required_url = it->second; |
| 251 return (url.scheme() == required_url.scheme() && | 246 return (url.scheme() == required_url.scheme() && |
| 252 url.host() == required_url.host()); | 247 url.host() == required_url.host()); |
| 253 } | 248 } |
| OLD | NEW |