| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // static | 55 // static |
| 56 bool PluginService::enable_chrome_plugins_ = true; | 56 bool PluginService::enable_chrome_plugins_ = true; |
| 57 | 57 |
| 58 // static | 58 // static |
| 59 void PluginService::InitGlobalInstance(Profile* profile) { | 59 void PluginService::InitGlobalInstance(Profile* profile) { |
| 60 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 60 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
| 61 | 61 |
| 62 // We first group the plugins and then figure out which groups to disable. | 62 // We first group the plugins and then figure out which groups to disable. |
| 63 plugin_updater::DisablePluginGroupsFromPrefs(profile); | 63 plugin_updater::DisablePluginGroupsFromPrefs(profile); |
| 64 | 64 |
| 65 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 66 switches::kDisableOutdatedPlugins)) { |
| 67 plugin_updater::DisableOutdatedPluginGroups(); |
| 68 } |
| 69 |
| 65 // Have Chrome plugins write their data to the profile directory. | 70 // Have Chrome plugins write their data to the profile directory. |
| 66 GetInstance()->SetChromePluginDataDir(profile->GetPath()); | 71 GetInstance()->SetChromePluginDataDir(profile->GetPath()); |
| 67 } | 72 } |
| 68 | 73 |
| 69 // static | 74 // static |
| 70 PluginService* PluginService::GetInstance() { | 75 PluginService* PluginService::GetInstance() { |
| 71 return Singleton<PluginService>::get(); | 76 return Singleton<PluginService>::get(); |
| 72 } | 77 } |
| 73 | 78 |
| 74 // static | 79 // static |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 return plugin_host; | 227 return plugin_host; |
| 223 } | 228 } |
| 224 | 229 |
| 225 void PluginService::OpenChannelToPlugin( | 230 void PluginService::OpenChannelToPlugin( |
| 226 ResourceMessageFilter* renderer_msg_filter, | 231 ResourceMessageFilter* renderer_msg_filter, |
| 227 const GURL& url, | 232 const GURL& url, |
| 228 const std::string& mime_type, | 233 const std::string& mime_type, |
| 229 const std::wstring& locale, | 234 const std::wstring& locale, |
| 230 IPC::Message* reply_msg) { | 235 IPC::Message* reply_msg) { |
| 231 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 236 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 232 // We don't need a policy URL here because that was already checked by a | 237 bool allow_wildcard = true; |
| 233 // previous call to GetPluginPath. | 238 WebPluginInfo info; |
| 234 GURL policy_url; | 239 FilePath plugin_path; |
| 235 FilePath plugin_path = GetPluginPath(url, policy_url, mime_type, NULL); | 240 if (NPAPI::PluginList::Singleton()->GetPluginInfo( |
| 241 url, mime_type, allow_wildcard, &info, NULL) && info.enabled) { |
| 242 plugin_path = info.path; |
| 243 } |
| 236 PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path); | 244 PluginProcessHost* plugin_host = FindOrStartPluginProcess(plugin_path); |
| 237 if (plugin_host) { | 245 if (plugin_host) { |
| 238 plugin_host->OpenChannelToPlugin(renderer_msg_filter, mime_type, reply_msg); | 246 plugin_host->OpenChannelToPlugin(renderer_msg_filter, mime_type, reply_msg); |
| 239 } else { | 247 } else { |
| 240 PluginProcessHost::ReplyToRenderer( | 248 PluginProcessHost::ReplyToRenderer( |
| 241 renderer_msg_filter, IPC::ChannelHandle(), WebPluginInfo(), reply_msg); | 249 renderer_msg_filter, IPC::ChannelHandle(), WebPluginInfo(), reply_msg); |
| 242 } | 250 } |
| 243 } | 251 } |
| 244 | 252 |
| 245 FilePath PluginService::GetPluginPath(const GURL& url, | |
| 246 const GURL& policy_url, | |
| 247 const std::string& mime_type, | |
| 248 std::string* actual_mime_type) { | |
| 249 bool allow_wildcard = true; | |
| 250 WebPluginInfo info; | |
| 251 if (NPAPI::PluginList::Singleton()->GetPluginInfo( | |
| 252 url, mime_type, allow_wildcard, &info, actual_mime_type) && | |
| 253 info.enabled && PluginAllowedForURL(info.path, policy_url)) { | |
| 254 return info.path; | |
| 255 } | |
| 256 | |
| 257 return FilePath(); | |
| 258 } | |
| 259 | |
| 260 static void PurgePluginListCache(bool reload_pages) { | 253 static void PurgePluginListCache(bool reload_pages) { |
| 261 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); | 254 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); |
| 262 !it.IsAtEnd(); it.Advance()) { | 255 !it.IsAtEnd(); it.Advance()) { |
| 263 it.GetCurrentValue()->Send(new ViewMsg_PurgePluginListCache(reload_pages)); | 256 it.GetCurrentValue()->Send(new ViewMsg_PurgePluginListCache(reload_pages)); |
| 264 } | 257 } |
| 265 } | 258 } |
| 266 | 259 |
| 267 void PluginService::OnWaitableEventSignaled( | 260 void PluginService::OnWaitableEventSignaled( |
| 268 base::WaitableEvent* waitable_event) { | 261 base::WaitableEvent* waitable_event) { |
| 269 #if defined(OS_WIN) | 262 #if defined(OS_WIN) |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 NewRunnableFunction(&NotifyPluginsOfActivation)); | 323 NewRunnableFunction(&NotifyPluginsOfActivation)); |
| 331 break; | 324 break; |
| 332 } | 325 } |
| 333 #endif | 326 #endif |
| 334 | 327 |
| 335 default: | 328 default: |
| 336 DCHECK(false); | 329 DCHECK(false); |
| 337 } | 330 } |
| 338 } | 331 } |
| 339 | 332 |
| 340 bool PluginService::PluginAllowedForURL(const FilePath& plugin_path, | 333 bool PluginService::PrivatePluginAllowedForURL(const FilePath& plugin_path, |
| 341 const GURL& url) { | 334 const GURL& url) { |
| 342 if (url.is_empty()) | 335 if (url.is_empty()) |
| 343 return true; // Caller wants all plugins. | 336 return true; // Caller wants all plugins. |
| 344 | 337 |
| 345 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); | 338 PrivatePluginMap::iterator it = private_plugins_.find(plugin_path); |
| 346 if (it == private_plugins_.end()) | 339 if (it == private_plugins_.end()) |
| 347 return true; // This plugin is not private, so it's allowed everywhere. | 340 return true; // This plugin is not private, so it's allowed everywhere. |
| 348 | 341 |
| 349 // We do a dumb compare of scheme and host, rather than using the domain | 342 // We do a dumb compare of scheme and host, rather than using the domain |
| 350 // service, since we only care about this for extensions. | 343 // service, since we only care about this for extensions. |
| 351 const GURL& required_url = it->second; | 344 const GURL& required_url = it->second; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 368 info.mime_types = ASCIIToWide(JoinString(plugins[i].mime_types, '|')); | 361 info.mime_types = ASCIIToWide(JoinString(plugins[i].mime_types, '|')); |
| 369 | 362 |
| 370 // These NPAPI entry points will never be called. TODO(darin): Come up | 363 // These NPAPI entry points will never be called. TODO(darin): Come up |
| 371 // with a cleaner way to register pepper plugins with the NPAPI PluginList, | 364 // with a cleaner way to register pepper plugins with the NPAPI PluginList, |
| 372 // or perhaps refactor the PluginList to be less specific to NPAPI. | 365 // or perhaps refactor the PluginList to be less specific to NPAPI. |
| 373 memset(&info.entry_points, 0, sizeof(info.entry_points)); | 366 memset(&info.entry_points, 0, sizeof(info.entry_points)); |
| 374 | 367 |
| 375 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); | 368 NPAPI::PluginList::Singleton()->RegisterInternalPlugin(info); |
| 376 } | 369 } |
| 377 } | 370 } |
| OLD | NEW |