| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 !iter.Done(); ++iter) { | 109 !iter.Done(); ++iter) { |
| 110 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); | 110 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); |
| 111 if (plugin->info().path == plugin_path) | 111 if (plugin->info().path == plugin_path) |
| 112 return plugin; | 112 return plugin; |
| 113 } | 113 } |
| 114 | 114 |
| 115 return NULL; | 115 return NULL; |
| 116 } | 116 } |
| 117 | 117 |
| 118 PluginProcessHost* PluginService::FindOrStartPluginProcess( | 118 PluginProcessHost* PluginService::FindOrStartPluginProcess( |
| 119 const FilePath& plugin_path, | 119 const FilePath& plugin_path) { |
| 120 const std::string& clsid) { | |
| 121 DCHECK(MessageLoop::current() == | 120 DCHECK(MessageLoop::current() == |
| 122 ChromeThread::GetMessageLoop(ChromeThread::IO)); | 121 ChromeThread::GetMessageLoop(ChromeThread::IO)); |
| 123 | 122 |
| 124 PluginProcessHost *plugin_host = FindPluginProcess(plugin_path); | 123 PluginProcessHost *plugin_host = FindPluginProcess(plugin_path); |
| 125 if (plugin_host) | 124 if (plugin_host) |
| 126 return plugin_host; | 125 return plugin_host; |
| 127 | 126 |
| 128 WebPluginInfo info; | 127 WebPluginInfo info; |
| 129 if (!NPAPI::PluginList::Singleton()->GetPluginInfoByPath( | 128 if (!NPAPI::PluginList::Singleton()->GetPluginInfoByPath( |
| 130 plugin_path, &info)) { | 129 plugin_path, &info)) { |
| 131 DCHECK(false); | 130 DCHECK(false); |
| 132 return NULL; | 131 return NULL; |
| 133 } | 132 } |
| 134 | 133 |
| 135 // This plugin isn't loaded by any plugin process, so create a new process. | 134 // This plugin isn't loaded by any plugin process, so create a new process. |
| 136 plugin_host = new PluginProcessHost(); | 135 plugin_host = new PluginProcessHost(); |
| 137 if (!plugin_host->Init(info, clsid, ui_locale_)) { | 136 if (!plugin_host->Init(info, ui_locale_)) { |
| 138 DCHECK(false); // Init is not expected to fail | 137 DCHECK(false); // Init is not expected to fail |
| 139 delete plugin_host; | 138 delete plugin_host; |
| 140 return NULL; | 139 return NULL; |
| 141 } | 140 } |
| 142 | 141 |
| 143 return plugin_host; | 142 return plugin_host; |
| 144 } | 143 } |
| 145 | 144 |
| 146 void PluginService::OpenChannelToPlugin( | 145 void PluginService::OpenChannelToPlugin( |
| 147 ResourceMessageFilter* renderer_msg_filter, const GURL& url, | 146 ResourceMessageFilter* renderer_msg_filter, |
| 148 const std::string& mime_type, const std::string& clsid, | 147 const GURL& url, |
| 149 const std::wstring& locale, IPC::Message* reply_msg) { | 148 const std::string& mime_type, |
| 149 const std::wstring& locale, |
| 150 IPC::Message* reply_msg) { |
| 150 DCHECK(MessageLoop::current() == | 151 DCHECK(MessageLoop::current() == |
| 151 ChromeThread::GetMessageLoop(ChromeThread::IO)); | 152 ChromeThread::GetMessageLoop(ChromeThread::IO)); |
| 152 // We don't need a policy URL here because that was already checked by a | 153 // We don't need a policy URL here because that was already checked by a |
| 153 // previous call to GetPluginPath. | 154 // previous call to GetPluginPath. |
| 154 GURL policy_url; | 155 GURL policy_url; |
| 155 FilePath plugin_path = GetPluginPath(url, policy_url, mime_type, clsid, NULL); | 156 FilePath plugin_path = GetPluginPath(url, policy_url, mime_type, NULL); |
| 156 PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path, clsid); | 157 PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path); |
| 157 if (plugin_host) { | 158 if (plugin_host) { |
| 158 plugin_host->OpenChannelToPlugin(renderer_msg_filter, mime_type, reply_msg); | 159 plugin_host->OpenChannelToPlugin(renderer_msg_filter, mime_type, reply_msg); |
| 159 } else { | 160 } else { |
| 160 PluginProcessHost::ReplyToRenderer(renderer_msg_filter, | 161 PluginProcessHost::ReplyToRenderer( |
| 161 IPC::ChannelHandle(), | 162 renderer_msg_filter, IPC::ChannelHandle(), WebPluginInfo(), reply_msg); |
| 162 WebPluginInfo(), | |
| 163 reply_msg); | |
| 164 } | 163 } |
| 165 } | 164 } |
| 166 | 165 |
| 167 FilePath PluginService::GetPluginPath(const GURL& url, | 166 FilePath PluginService::GetPluginPath(const GURL& url, |
| 168 const GURL& policy_url, | 167 const GURL& policy_url, |
| 169 const std::string& mime_type, | 168 const std::string& mime_type, |
| 170 const std::string& clsid, | |
| 171 std::string* actual_mime_type) { | 169 std::string* actual_mime_type) { |
| 172 bool allow_wildcard = true; | 170 bool allow_wildcard = true; |
| 173 WebPluginInfo info; | 171 WebPluginInfo info; |
| 174 if (NPAPI::PluginList::Singleton()->GetPluginInfo(url, mime_type, clsid, | 172 if (NPAPI::PluginList::Singleton()->GetPluginInfo( |
| 175 allow_wildcard, &info, | 173 url, mime_type, allow_wildcard, &info, actual_mime_type) && |
| 176 actual_mime_type) && | |
| 177 PluginAllowedForURL(info.path, policy_url)) { | 174 PluginAllowedForURL(info.path, policy_url)) { |
| 178 return info.path; | 175 return info.path; |
| 179 } | 176 } |
| 180 | 177 |
| 181 return FilePath(); | 178 return FilePath(); |
| 182 } | 179 } |
| 183 | 180 |
| 184 void PluginService::OnWaitableEventSignaled( | 181 void PluginService::OnWaitableEventSignaled( |
| 185 base::WaitableEvent* waitable_event) { | 182 base::WaitableEvent* waitable_event) { |
| 186 #if defined(OS_WIN) | 183 #if defined(OS_WIN) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); | 236 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); |
| 240 if (it == private_plugins_.end()) | 237 if (it == private_plugins_.end()) |
| 241 return true; // This plugin is not private, so it's allowed everywhere. | 238 return true; // This plugin is not private, so it's allowed everywhere. |
| 242 | 239 |
| 243 // We do a dumb compare of scheme and host, rather than using the domain | 240 // We do a dumb compare of scheme and host, rather than using the domain |
| 244 // service, since we only care about this for extensions. | 241 // service, since we only care about this for extensions. |
| 245 const GURL& required_url = it->second; | 242 const GURL& required_url = it->second; |
| 246 return (url.scheme() == required_url.scheme() && | 243 return (url.scheme() == required_url.scheme() && |
| 247 url.host() == required_url.host()); | 244 url.host() == required_url.host()); |
| 248 } | 245 } |
| OLD | NEW |