OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 return plugin_host; | 221 return plugin_host; |
222 } | 222 } |
223 | 223 |
224 void PluginService::OpenChannelToPlugin( | 224 void PluginService::OpenChannelToPlugin( |
225 ResourceMessageFilter* renderer_msg_filter, | 225 ResourceMessageFilter* renderer_msg_filter, |
226 const GURL& url, | 226 const GURL& url, |
227 const std::string& mime_type, | 227 const std::string& mime_type, |
228 const std::wstring& locale, | 228 const std::wstring& locale, |
229 IPC::Message* reply_msg) { | 229 IPC::Message* reply_msg) { |
230 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 230 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
231 // We don't need a policy URL here because that was already checked by a | 231 bool allow_wildcard = true; |
232 // previous call to GetPluginPath. | 232 WebPluginInfo info; |
233 GURL policy_url; | 233 FilePath plugin_path; |
234 FilePath plugin_path = GetPluginPath(url, policy_url, mime_type, NULL); | 234 if (NPAPI::PluginList::Singleton()->GetPluginInfo( |
| 235 url, mime_type, allow_wildcard, &info, NULL) && info.enabled) { |
| 236 plugin_path = info.path; |
| 237 } |
235 PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path); | 238 PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path); |
236 if (plugin_host) { | 239 if (plugin_host) { |
237 plugin_host->OpenChannelToPlugin(renderer_msg_filter, mime_type, reply_msg); | 240 plugin_host->OpenChannelToPlugin(renderer_msg_filter, mime_type, reply_msg); |
238 } else { | 241 } else { |
239 PluginProcessHost::ReplyToRenderer( | 242 PluginProcessHost::ReplyToRenderer( |
240 renderer_msg_filter, IPC::ChannelHandle(), WebPluginInfo(), reply_msg); | 243 renderer_msg_filter, IPC::ChannelHandle(), WebPluginInfo(), reply_msg); |
241 } | 244 } |
242 } | 245 } |
243 | 246 |
244 FilePath PluginService::GetPluginPath(const GURL& url, | |
245 const GURL& policy_url, | |
246 const std::string& mime_type, | |
247 std::string* actual_mime_type) { | |
248 bool allow_wildcard = true; | |
249 WebPluginInfo info; | |
250 if (NPAPI::PluginList::Singleton()->GetPluginInfo( | |
251 url, mime_type, allow_wildcard, &info, actual_mime_type) && | |
252 info.enabled && PluginAllowedForURL(info.path, policy_url)) { | |
253 return info.path; | |
254 } | |
255 | |
256 return FilePath(); | |
257 } | |
258 | |
259 static void PurgePluginListCache(bool reload_pages) { | 247 static void PurgePluginListCache(bool reload_pages) { |
260 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); | 248 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); |
261 !it.IsAtEnd(); it.Advance()) { | 249 !it.IsAtEnd(); it.Advance()) { |
262 it.GetCurrentValue()->Send(new ViewMsg_PurgePluginListCache(reload_pages)); | 250 it.GetCurrentValue()->Send(new ViewMsg_PurgePluginListCache(reload_pages)); |
263 } | 251 } |
264 } | 252 } |
265 | 253 |
266 void PluginService::OnWaitableEventSignaled( | 254 void PluginService::OnWaitableEventSignaled( |
267 base::WaitableEvent* waitable_event) { | 255 base::WaitableEvent* waitable_event) { |
268 #if defined(OS_WIN) | 256 #if defined(OS_WIN) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 NewRunnableFunction(&NotifyPluginsOfActivation)); | 317 NewRunnableFunction(&NotifyPluginsOfActivation)); |
330 break; | 318 break; |
331 } | 319 } |
332 #endif | 320 #endif |
333 | 321 |
334 default: | 322 default: |
335 DCHECK(false); | 323 DCHECK(false); |
336 } | 324 } |
337 } | 325 } |
338 | 326 |
339 bool PluginService::PluginAllowedForURL(const FilePath& plugin_path, | 327 bool PluginService::PrivatePluginAllowedForURL(const FilePath& plugin_path, |
340 const GURL& url) { | 328 const GURL& url) { |
341 if (url.is_empty()) | 329 if (url.is_empty()) |
342 return true; // Caller wants all plugins. | 330 return true; // Caller wants all plugins. |
343 | 331 |
344 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); | 332 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); |
345 if (it == private_plugins_.end()) | 333 if (it == private_plugins_.end()) |
346 return true; // This plugin is not private, so it's allowed everywhere. | 334 return true; // This plugin is not private, so it's allowed everywhere. |
347 | 335 |
348 // We do a dumb compare of scheme and host, rather than using the domain | 336 // We do a dumb compare of scheme and host, rather than using the domain |
349 // service, since we only care about this for extensions. | 337 // service, since we only care about this for extensions. |
350 const GURL& required_url = it->second; | 338 const GURL& required_url = it->second; |
(...skipping 16 matching lines...) Expand all Loading... |
367 info.mime_types = ASCIIToWide(JoinString(plugins[i].mime_types, '|')); | 355 info.mime_types = ASCIIToWide(JoinString(plugins[i].mime_types, '|')); |
368 | 356 |
369 // These NPAPI entry points will never be called. TODO(darin): Come up | 357 // These NPAPI entry points will never be called. TODO(darin): Come up |
370 // with a cleaner way to register pepper plugins with the NPAPI PluginList, | 358 // with a cleaner way to register pepper plugins with the NPAPI PluginList, |
371 // or perhaps refactor the PluginList to be less specific to NPAPI. | 359 // or perhaps refactor the PluginList to be less specific to NPAPI. |
372 memset(&info.entry_points, 0, sizeof(info.entry_points)); | 360 memset(&info.entry_points, 0, sizeof(info.entry_points)); |
373 | 361 |
374 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); | 362 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); |
375 } | 363 } |
376 } | 364 } |
OLD | NEW |