Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Side by Side Diff: content/browser/plugin_service.cc

Issue 7006006: Replace OS_LINUX ifdefs with OS_POSIX & !OS_MACOSX, TOOLKIT_USES_GTK, or (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 13 matching lines...) Expand all
24 #include "content/browser/resource_context.h" 24 #include "content/browser/resource_context.h"
25 #include "content/common/notification_service.h" 25 #include "content/common/notification_service.h"
26 #include "content/common/notification_type.h" 26 #include "content/common/notification_type.h"
27 #include "content/common/pepper_plugin_registry.h" 27 #include "content/common/pepper_plugin_registry.h"
28 #include "content/common/plugin_messages.h" 28 #include "content/common/plugin_messages.h"
29 #include "content/common/view_messages.h" 29 #include "content/common/view_messages.h"
30 #include "webkit/plugins/npapi/plugin_constants_win.h" 30 #include "webkit/plugins/npapi/plugin_constants_win.h"
31 #include "webkit/plugins/npapi/plugin_list.h" 31 #include "webkit/plugins/npapi/plugin_list.h"
32 #include "webkit/plugins/npapi/webplugininfo.h" 32 #include "webkit/plugins/npapi/webplugininfo.h"
33 33
34 #if defined(OS_LINUX) 34 #if defined(OS_POSIX) && !defined(OS_MACOSX)
35 using ::base::files::FilePathWatcher; 35 using ::base::files::FilePathWatcher;
36 #endif 36 #endif
37 37
38 #if defined(OS_MACOSX) 38 #if defined(OS_MACOSX)
39 static void NotifyPluginsOfActivation() { 39 static void NotifyPluginsOfActivation() {
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
41 41
42 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS); 42 for (BrowserChildProcessHost::Iterator iter(ChildProcessInfo::PLUGIN_PROCESS);
43 !iter.Done(); ++iter) { 43 !iter.Done(); ++iter) {
44 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter); 44 PluginProcessHost* plugin = static_cast<PluginProcessHost*>(*iter);
45 plugin->OnAppActivation(); 45 plugin->OnAppActivation();
46 } 46 }
47 } 47 }
48 #endif 48 #elif defined(OS_POSIX)
49
50 #if defined(OS_LINUX)
51 // Delegate class for monitoring directories. 49 // Delegate class for monitoring directories.
52 class PluginDirWatcherDelegate : public FilePathWatcher::Delegate { 50 class PluginDirWatcherDelegate : public FilePathWatcher::Delegate {
53 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE { 51 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE {
54 VLOG(1) << "Watched path changed: " << path.value(); 52 VLOG(1) << "Watched path changed: " << path.value();
55 // Make the plugin list update itself 53 // Make the plugin list update itself
56 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); 54 webkit::npapi::PluginList::Singleton()->RefreshPlugins();
57 } 55 }
58 virtual void OnFilePathError(const FilePath& path) OVERRIDE { 56 virtual void OnFilePathError(const FilePath& path) OVERRIDE {
59 // TODO(pastarmovj): Add some sensible error handling. Maybe silently 57 // TODO(pastarmovj): Add some sensible error handling. Maybe silently
60 // stopping the watcher would be enough. Or possibly restart it. 58 // stopping the watcher would be enough. Or possibly restart it.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 93 }
96 } 94 }
97 if (hklm_key_.Create(HKEY_LOCAL_MACHINE, 95 if (hklm_key_.Create(HKEY_LOCAL_MACHINE,
98 webkit::npapi::kRegistryMozillaPlugins, 96 webkit::npapi::kRegistryMozillaPlugins,
99 KEY_NOTIFY) == ERROR_SUCCESS) { 97 KEY_NOTIFY) == ERROR_SUCCESS) {
100 if (hklm_key_.StartWatching() == ERROR_SUCCESS) { 98 if (hklm_key_.StartWatching() == ERROR_SUCCESS) {
101 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); 99 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event()));
102 hklm_watcher_.StartWatching(hklm_event_.get(), this); 100 hklm_watcher_.StartWatching(hklm_event_.get(), this);
103 } 101 }
104 } 102 }
105 #elif defined(OS_POSIX) && !defined(OS_MACOSX) 103 #elif defined(OS_MACOSX)
104 // We need to know when the browser comes forward so we can bring modal plugin
105 // windows forward too.
106 registrar_.Add(this, NotificationType::APP_ACTIVATED,
107 NotificationService::AllSources());
108 #elif defined(OS_POSIX)
106 // Also find plugins in a user-specific plugins dir, 109 // Also find plugins in a user-specific plugins dir,
107 // e.g. ~/.config/chromium/Plugins. 110 // e.g. ~/.config/chromium/Plugins.
108 FilePath user_data_dir; 111 FilePath user_data_dir;
109 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { 112 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) {
110 webkit::npapi::PluginList::Singleton()->AddExtraPluginDir( 113 webkit::npapi::PluginList::Singleton()->AddExtraPluginDir(
111 user_data_dir.Append("Plugins")); 114 user_data_dir.Append("Plugins"));
112 } 115 }
113 #endif 116
114 // The FilePathWatcher produces too many false positives on MacOS (access time 117 // The FilePathWatcher produces too many false positives on MacOS (access time
115 // updates?) which will lead to enforcing updates of the plugins way too often. 118 // updates?) which will lead to enforcing updates of the plugins way too often.
116 // On ChromeOS the user can't install plugins anyway and on Windows all 119 // On ChromeOS the user can't install plugins anyway and on Windows all
117 // important plugins register themselves in the registry so no need to do that. 120 // important plugins register themselves in the registry so no need to do that.
118 #if defined(OS_LINUX)
119 file_watcher_delegate_ = new PluginDirWatcherDelegate(); 121 file_watcher_delegate_ = new PluginDirWatcherDelegate();
120 // Get the list of all paths for registering the FilePathWatchers 122 // Get the list of all paths for registering the FilePathWatchers
121 // that will track and if needed reload the list of plugins on runtime. 123 // that will track and if needed reload the list of plugins on runtime.
122 std::vector<FilePath> plugin_dirs; 124 std::vector<FilePath> plugin_dirs;
123 webkit::npapi::PluginList::Singleton()->GetPluginDirectories( 125 webkit::npapi::PluginList::Singleton()->GetPluginDirectories(
124 &plugin_dirs); 126 &plugin_dirs);
125 127
126 for (size_t i = 0; i < plugin_dirs.size(); ++i) { 128 for (size_t i = 0; i < plugin_dirs.size(); ++i) {
127 // FilePathWatcher can not handle non-absolute paths under windows. 129 // FilePathWatcher can not handle non-absolute paths under windows.
128 // We don't watch for file changes in windows now but if this should ever 130 // We don't watch for file changes in windows now but if this should ever
129 // be extended to Windows these lines might save some time of debugging. 131 // be extended to Windows these lines might save some time of debugging.
130 #if defined(OS_WIN) 132 #if defined(OS_WIN)
131 if (!plugin_dirs[i].IsAbsolute()) 133 if (!plugin_dirs[i].IsAbsolute())
132 continue; 134 continue;
133 #endif 135 #endif
134 FilePathWatcher* watcher = new FilePathWatcher(); 136 FilePathWatcher* watcher = new FilePathWatcher();
135 VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value(); 137 VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value();
136 BrowserThread::PostTask( 138 BrowserThread::PostTask(
137 BrowserThread::FILE, FROM_HERE, 139 BrowserThread::FILE, FROM_HERE,
138 NewRunnableFunction( 140 NewRunnableFunction(
139 &PluginService::RegisterFilePathWatcher, 141 &PluginService::RegisterFilePathWatcher,
140 watcher, plugin_dirs[i], file_watcher_delegate_)); 142 watcher, plugin_dirs[i], file_watcher_delegate_));
141 file_watchers_.push_back(watcher); 143 file_watchers_.push_back(watcher);
142 } 144 }
143 #endif 145 #endif
144 #if defined(OS_MACOSX)
145 // We need to know when the browser comes forward so we can bring modal plugin
146 // windows forward too.
147 registrar_.Add(this, NotificationType::APP_ACTIVATED,
148 NotificationService::AllSources());
149 #endif
150 registrar_.Add(this, NotificationType::PLUGIN_ENABLE_STATUS_CHANGED, 146 registrar_.Add(this, NotificationType::PLUGIN_ENABLE_STATUS_CHANGED,
151 NotificationService::AllSources()); 147 NotificationService::AllSources());
152 registrar_.Add(this, 148 registrar_.Add(this,
153 NotificationType::RENDERER_PROCESS_CLOSED, 149 NotificationType::RENDERER_PROCESS_CLOSED,
154 NotificationService::AllSources()); 150 NotificationService::AllSources());
155 } 151 }
156 152
157 PluginService::~PluginService() { 153 PluginService::~PluginService() {
158 #if defined(OS_WIN) 154 #if defined(OS_WIN)
159 // Release the events since they're owned by RegKey, not WaitableEvent. 155 // Release the events since they're owned by RegKey, not WaitableEvent.
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 PepperPluginInfo* info = NULL; 486 PepperPluginInfo* info = NULL;
491 for (size_t i = 0; i < ppapi_plugins_.size(); i++) { 487 for (size_t i = 0; i < ppapi_plugins_.size(); i++) {
492 if (ppapi_plugins_[i].path == plugin_path) { 488 if (ppapi_plugins_[i].path == plugin_path) {
493 info = &ppapi_plugins_[i]; 489 info = &ppapi_plugins_[i];
494 break; 490 break;
495 } 491 }
496 } 492 }
497 return info; 493 return info;
498 } 494 }
499 495
500 #if defined(OS_LINUX) 496 #if defined(OS_POSIX) && !defined(OS_MACOSX)
501 // static 497 // static
502 void PluginService::RegisterFilePathWatcher( 498 void PluginService::RegisterFilePathWatcher(
503 FilePathWatcher *watcher, 499 FilePathWatcher *watcher,
504 const FilePath& path, 500 const FilePath& path,
505 FilePathWatcher::Delegate* delegate) { 501 FilePathWatcher::Delegate* delegate) {
506 bool result = watcher->Watch(path, delegate); 502 bool result = watcher->Watch(path, delegate);
507 DCHECK(result); 503 DCHECK(result);
508 } 504 }
509 #endif 505 #endif
OLDNEW
« no previous file with comments | « content/browser/plugin_service.h ('k') | content/browser/renderer_host/render_sandbox_host_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698