Chromium Code Reviews| 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 <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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 | 53 |
| 54 static void PurgePluginListCache(bool reload_pages) { | 54 static void PurgePluginListCache(bool reload_pages) { |
| 55 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); | 55 for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); |
| 56 !it.IsAtEnd(); it.Advance()) { | 56 !it.IsAtEnd(); it.Advance()) { |
| 57 it.GetCurrentValue()->Send(new ViewMsg_PurgePluginListCache(reload_pages)); | 57 it.GetCurrentValue()->Send(new ViewMsg_PurgePluginListCache(reload_pages)); |
| 58 } | 58 } |
| 59 } | 59 } |
| 60 | 60 |
| 61 #if defined(OS_LINUX) | 61 #if defined(OS_LINUX) |
| 62 // Delegate class for monitoring directories. | 62 // Delegate class for monitoring directories. |
| 63 class PluginDirWatcherDelegate : public FilePathWatcher::Delegate { | 63 class PluginDirWatcherDelegate : public base::files::FilePathWatcher::Delegate { |
| 64 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE { | 64 virtual void OnFilePathChanged(const FilePath& path) OVERRIDE { |
| 65 VLOG(1) << "Watched path changed: " << path.value(); | 65 VLOG(1) << "Watched path changed: " << path.value(); |
| 66 // Make the plugin list update itself | 66 // Make the plugin list update itself |
| 67 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); | 67 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); |
| 68 } | 68 } |
| 69 virtual void OnFilePathError(const FilePath& path) OVERRIDE { | 69 virtual void OnFilePathError(const FilePath& path) OVERRIDE { |
| 70 // TODO(pastarmovj): Add some sensible error handling. Maybe silently | 70 // TODO(pastarmovj): Add some sensible error handling. Maybe silently |
| 71 // stopping the watcher would be enough. Or possibly restart it. | 71 // stopping the watcher would be enough. Or possibly restart it. |
| 72 NOTREACHED(); | 72 NOTREACHED(); |
| 73 } | 73 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 // important plugins register themselves in the registry so no need to do that. | 149 // important plugins register themselves in the registry so no need to do that. |
| 150 #if defined(OS_LINUX) | 150 #if defined(OS_LINUX) |
| 151 file_watcher_delegate_ = new PluginDirWatcherDelegate(); | 151 file_watcher_delegate_ = new PluginDirWatcherDelegate(); |
| 152 // Get the list of all paths for registering the FilePathWatchers | 152 // Get the list of all paths for registering the FilePathWatchers |
| 153 // that will track and if needed reload the list of plugins on runtime. | 153 // that will track and if needed reload the list of plugins on runtime. |
| 154 std::vector<FilePath> plugin_dirs; | 154 std::vector<FilePath> plugin_dirs; |
| 155 webkit::npapi::PluginList::Singleton()->GetPluginDirectories( | 155 webkit::npapi::PluginList::Singleton()->GetPluginDirectories( |
| 156 &plugin_dirs); | 156 &plugin_dirs); |
| 157 | 157 |
| 158 for (size_t i = 0; i < plugin_dirs.size(); ++i) { | 158 for (size_t i = 0; i < plugin_dirs.size(); ++i) { |
| 159 FilePathWatcher* watcher = new FilePathWatcher(); | 159 base::files::FilePathWatcher* watcher = new base::files::FilePathWatcher(); |
|
dmac
2011/04/05 19:55:51
just realized that this should go under the #if de
Craig
2011/04/06 15:27:30
Done.
| |
| 160 // FilePathWatcher can not handle non-absolute paths under windows. | 160 // FilePathWatcher can not handle non-absolute paths under windows. |
| 161 // We don't watch for file changes in windows now but if this should ever | 161 // We don't watch for file changes in windows now but if this should ever |
| 162 // be extended to Windows these lines might save some time of debugging. | 162 // be extended to Windows these lines might save some time of debugging. |
| 163 #if defined(OS_WIN) | 163 #if defined(OS_WIN) |
| 164 if (!plugin_dirs[i].IsAbsolute()) | 164 if (!plugin_dirs[i].IsAbsolute()) |
| 165 continue; | 165 continue; |
| 166 #endif | 166 #endif |
| 167 VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value(); | 167 VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value(); |
| 168 BrowserThread::PostTask( | 168 BrowserThread::PostTask( |
| 169 BrowserThread::FILE, FROM_HERE, | 169 BrowserThread::FILE, FROM_HERE, |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 } | 539 } |
| 540 info.enabled = enabled_state; | 540 info.enabled = enabled_state; |
| 541 | 541 |
| 542 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); | 542 webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(info); |
| 543 } | 543 } |
| 544 } | 544 } |
| 545 | 545 |
| 546 #if defined(OS_LINUX) | 546 #if defined(OS_LINUX) |
| 547 // static | 547 // static |
| 548 void PluginService::RegisterFilePathWatcher( | 548 void PluginService::RegisterFilePathWatcher( |
| 549 FilePathWatcher *watcher, | 549 base::files::FilePathWatcher *watcher, |
| 550 const FilePath& path, | 550 const FilePath& path, |
| 551 FilePathWatcher::Delegate* delegate) { | 551 base::files::FilePathWatcher::Delegate* delegate) { |
| 552 bool result = watcher->Watch(path, delegate); | 552 bool result = watcher->Watch(path, delegate); |
| 553 DCHECK(result); | 553 DCHECK(result); |
| 554 } | 554 } |
| 555 #endif | 555 #endif |
| OLD | NEW |