OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_service.h" | 5 #include "content/browser/plugin_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
31 #include "content/public/browser/content_browser_client.h" | 31 #include "content/public/browser/content_browser_client.h" |
32 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/notification_types.h" | 33 #include "content/public/browser/notification_types.h" |
34 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
35 #include "webkit/plugins/npapi/plugin_constants_win.h" | 35 #include "webkit/plugins/npapi/plugin_constants_win.h" |
36 #include "webkit/plugins/npapi/plugin_group.h" | 36 #include "webkit/plugins/npapi/plugin_group.h" |
37 #include "webkit/plugins/npapi/plugin_list.h" | 37 #include "webkit/plugins/npapi/plugin_list.h" |
38 #include "webkit/plugins/webplugininfo.h" | 38 #include "webkit/plugins/webplugininfo.h" |
39 | 39 |
40 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 40 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) |
41 using ::base::files::FilePathWatcher; | 41 using ::base::files::FilePathWatcher; |
42 #endif | 42 #endif |
43 | 43 |
44 using content::BrowserThread; | 44 using content::BrowserThread; |
45 using content::PluginServiceFilter; | 45 using content::PluginServiceFilter; |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
49 // Helper function that merely runs the callback with the result. Called on the | 49 // Helper function that merely runs the callback with the result. Called on the |
50 // thread on which the original GetPlugins() call was made. | 50 // thread on which the original GetPlugins() call was made. |
(...skipping 28 matching lines...) Expand all Loading... |
79 #if defined(OS_MACOSX) | 79 #if defined(OS_MACOSX) |
80 static void NotifyPluginsOfActivation() { | 80 static void NotifyPluginsOfActivation() { |
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
82 | 82 |
83 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); | 83 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); |
84 !iter.Done(); ++iter) { | 84 !iter.Done(); ++iter) { |
85 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); | 85 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); |
86 plugin->OnAppActivation(); | 86 plugin->OnAppActivation(); |
87 } | 87 } |
88 } | 88 } |
89 #elif defined(OS_POSIX) | 89 #elif defined(OS_POSIX) && !defined(OS_OPENBSD) |
90 // Delegate class for monitoring directories. | 90 // Delegate class for monitoring directories. |
91 class PluginDirWatcherDelegate : public FilePathWatcher::Delegate { | 91 class PluginDirWatcherDelegate : public FilePathWatcher::Delegate { |
92 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE { | 92 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE { |
93 VLOG(1) << "Watched path changed: " << path.value(); | 93 VLOG(1) << "Watched path changed: " << path.value(); |
94 // Make the plugin list update itself | 94 // Make the plugin list update itself |
95 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); | 95 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
96 BrowserThread::PostTask( | 96 BrowserThread::PostTask( |
97 BrowserThread::UI, FROM_HERE, | 97 BrowserThread::UI, FROM_HERE, |
98 base::Bind(&PluginService::PurgePluginListCache, | 98 base::Bind(&PluginService::PurgePluginListCache, |
99 static_cast<content::BrowserContext*>(NULL), false)); | 99 static_cast<content::BrowserContext*>(NULL), false)); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 168 } |
169 } | 169 } |
170 if (hklm_key_.Create(HKEY_LOCAL_MACHINE, | 170 if (hklm_key_.Create(HKEY_LOCAL_MACHINE, |
171 webkit::npapi::kRegistryMozillaPlugins, | 171 webkit::npapi::kRegistryMozillaPlugins, |
172 KEY_NOTIFY) == ERROR_SUCCESS) { | 172 KEY_NOTIFY) == ERROR_SUCCESS) { |
173 if (hklm_key_.StartWatching() == ERROR_SUCCESS) { | 173 if (hklm_key_.StartWatching() == ERROR_SUCCESS) { |
174 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); | 174 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); |
175 hklm_watcher_.StartWatching(hklm_event_.get(), this); | 175 hklm_watcher_.StartWatching(hklm_event_.get(), this); |
176 } | 176 } |
177 } | 177 } |
178 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | 178 #elif defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) |
179 // The FilePathWatcher produces too many false positives on MacOS (access time | 179 // The FilePathWatcher produces too many false positives on MacOS (access time |
180 // updates?) which will lead to enforcing updates of the plugins way too often. | 180 // updates?) which will lead to enforcing updates of the plugins way too often. |
181 // On ChromeOS the user can't install plugins anyway and on Windows all | 181 // On ChromeOS the user can't install plugins anyway and on Windows all |
182 // important plugins register themselves in the registry so no need to do that. | 182 // important plugins register themselves in the registry so no need to do that. |
183 file_watcher_delegate_ = new PluginDirWatcherDelegate(); | 183 file_watcher_delegate_ = new PluginDirWatcherDelegate(); |
184 // Get the list of all paths for registering the FilePathWatchers | 184 // Get the list of all paths for registering the FilePathWatchers |
185 // that will track and if needed reload the list of plugins on runtime. | 185 // that will track and if needed reload the list of plugins on runtime. |
186 std::vector<FilePath> plugin_dirs; | 186 std::vector<FilePath> plugin_dirs; |
187 plugin_list()->GetPluginDirectories(&plugin_dirs); | 187 plugin_list()->GetPluginDirectories(&plugin_dirs); |
188 | 188 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 webkit::WebPluginInfo webplugin_info; | 602 webkit::WebPluginInfo webplugin_info; |
603 if (!GetPluginInfoByPath(plugin_path, &webplugin_info)) | 603 if (!GetPluginInfoByPath(plugin_path, &webplugin_info)) |
604 return NULL; | 604 return NULL; |
605 content::PepperPluginInfo new_pepper_info; | 605 content::PepperPluginInfo new_pepper_info; |
606 if (!MakePepperPluginInfo(webplugin_info, &new_pepper_info)) | 606 if (!MakePepperPluginInfo(webplugin_info, &new_pepper_info)) |
607 return NULL; | 607 return NULL; |
608 ppapi_plugins_.push_back(new_pepper_info); | 608 ppapi_plugins_.push_back(new_pepper_info); |
609 return &ppapi_plugins_[ppapi_plugins_.size() - 1]; | 609 return &ppapi_plugins_[ppapi_plugins_.size() - 1]; |
610 } | 610 } |
611 | 611 |
612 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 612 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) |
613 // static | 613 // static |
614 void PluginService::RegisterFilePathWatcher( | 614 void PluginService::RegisterFilePathWatcher( |
615 FilePathWatcher *watcher, | 615 FilePathWatcher *watcher, |
616 const FilePath& path, | 616 const FilePath& path, |
617 FilePathWatcher::Delegate* delegate) { | 617 FilePathWatcher::Delegate* delegate) { |
618 bool result = watcher->Watch(path, delegate); | 618 bool result = watcher->Watch(path, delegate); |
619 DCHECK(result); | 619 DCHECK(result); |
620 } | 620 } |
621 #endif | 621 #endif |
622 | 622 |
(...skipping 17 matching lines...) Expand all Loading... |
640 return webkit::npapi::PluginList::Singleton(); | 640 return webkit::npapi::PluginList::Singleton(); |
641 } | 641 } |
642 | 642 |
643 void PluginService::RegisterInternalPlugin(const webkit::WebPluginInfo& info) { | 643 void PluginService::RegisterInternalPlugin(const webkit::WebPluginInfo& info) { |
644 plugin_list()->RegisterInternalPlugin(info); | 644 plugin_list()->RegisterInternalPlugin(info); |
645 } | 645 } |
646 | 646 |
647 string16 PluginService::GetPluginGroupName(const std::string& plugin_name) { | 647 string16 PluginService::GetPluginGroupName(const std::string& plugin_name) { |
648 return plugin_list()->GetPluginGroupName(plugin_name); | 648 return plugin_list()->GetPluginGroupName(plugin_name); |
649 } | 649 } |
OLD | NEW |