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/common/utility_messages.h" | 30 #include "content/common/utility_messages.h" |
31 #include "content/common/view_messages.h" | 31 #include "content/common/view_messages.h" |
32 #include "content/public/browser/content_browser_client.h" | 32 #include "content/public/browser/content_browser_client.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::PluginServiceFilter; | 44 using content::PluginServiceFilter; |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 // Helper function that merely runs the callback with the result. Called on the | 48 // Helper function that merely runs the callback with the result. Called on the |
49 // thread on which the original GetPlugins() call was made. | 49 // thread on which the original GetPlugins() call was made. |
50 static void RunGetPluginsCallback( | 50 static void RunGetPluginsCallback( |
(...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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 166 } |
167 } | 167 } |
168 if (hklm_key_.Create(HKEY_LOCAL_MACHINE, | 168 if (hklm_key_.Create(HKEY_LOCAL_MACHINE, |
169 webkit::npapi::kRegistryMozillaPlugins, | 169 webkit::npapi::kRegistryMozillaPlugins, |
170 KEY_NOTIFY) == ERROR_SUCCESS) { | 170 KEY_NOTIFY) == ERROR_SUCCESS) { |
171 if (hklm_key_.StartWatching() == ERROR_SUCCESS) { | 171 if (hklm_key_.StartWatching() == ERROR_SUCCESS) { |
172 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); | 172 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); |
173 hklm_watcher_.StartWatching(hklm_event_.get(), this); | 173 hklm_watcher_.StartWatching(hklm_event_.get(), this); |
174 } | 174 } |
175 } | 175 } |
176 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | 176 #elif defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) |
177 // The FilePathWatcher produces too many false positives on MacOS (access time | 177 // The FilePathWatcher produces too many false positives on MacOS (access time |
178 // updates?) which will lead to enforcing updates of the plugins way too often. | 178 // updates?) which will lead to enforcing updates of the plugins way too often. |
179 // On ChromeOS the user can't install plugins anyway and on Windows all | 179 // On ChromeOS the user can't install plugins anyway and on Windows all |
180 // important plugins register themselves in the registry so no need to do that. | 180 // important plugins register themselves in the registry so no need to do that. |
181 file_watcher_delegate_ = new PluginDirWatcherDelegate(); | 181 file_watcher_delegate_ = new PluginDirWatcherDelegate(); |
182 // Get the list of all paths for registering the FilePathWatchers | 182 // Get the list of all paths for registering the FilePathWatchers |
183 // that will track and if needed reload the list of plugins on runtime. | 183 // that will track and if needed reload the list of plugins on runtime. |
184 std::vector<FilePath> plugin_dirs; | 184 std::vector<FilePath> plugin_dirs; |
185 webkit::npapi::PluginList::Singleton()->GetPluginDirectories( | 185 webkit::npapi::PluginList::Singleton()->GetPluginDirectories( |
186 &plugin_dirs); | 186 &plugin_dirs); |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 webkit::WebPluginInfo webplugin_info; | 606 webkit::WebPluginInfo webplugin_info; |
607 if (!GetPluginInfoByPath(plugin_path, &webplugin_info)) | 607 if (!GetPluginInfoByPath(plugin_path, &webplugin_info)) |
608 return NULL; | 608 return NULL; |
609 content::PepperPluginInfo new_pepper_info; | 609 content::PepperPluginInfo new_pepper_info; |
610 if (!MakePepperPluginInfo(webplugin_info, &new_pepper_info)) | 610 if (!MakePepperPluginInfo(webplugin_info, &new_pepper_info)) |
611 return NULL; | 611 return NULL; |
612 ppapi_plugins_.push_back(new_pepper_info); | 612 ppapi_plugins_.push_back(new_pepper_info); |
613 return &ppapi_plugins_[ppapi_plugins_.size() - 1]; | 613 return &ppapi_plugins_[ppapi_plugins_.size() - 1]; |
614 } | 614 } |
615 | 615 |
616 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 616 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_OPENBSD) |
617 // static | 617 // static |
618 void PluginService::RegisterFilePathWatcher( | 618 void PluginService::RegisterFilePathWatcher( |
619 FilePathWatcher *watcher, | 619 FilePathWatcher *watcher, |
620 const FilePath& path, | 620 const FilePath& path, |
621 FilePathWatcher::Delegate* delegate) { | 621 FilePathWatcher::Delegate* delegate) { |
622 bool result = watcher->Watch(path, delegate); | 622 bool result = watcher->Watch(path, delegate); |
623 DCHECK(result); | 623 DCHECK(result); |
624 } | 624 } |
625 #endif | 625 #endif |
OLD | NEW |