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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 16 #include "base/values.h"
17 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
18 #include "content/browser/content_browser_client.h" 18 #include "content/browser/content_browser_client.h"
19 #include "content/browser/ppapi_plugin_process_host.h" 19 #include "content/browser/ppapi_plugin_process_host.h"
20 #include "content/browser/renderer_host/render_process_host.h" 20 #include "content/browser/renderer_host/render_process_host.h"
21 #include "content/browser/renderer_host/render_view_host.h" 21 #include "content/browser/renderer_host/render_view_host.h"
22 #include "content/browser/resource_context.h" 22 #include "content/browser/resource_context.h"
23 #include "content/common/content_notification_types.h"
23 #include "content/common/content_switches.h" 24 #include "content/common/content_switches.h"
24 #include "content/common/notification_service.h" 25 #include "content/common/notification_service.h"
25 #include "content/common/notification_type.h"
26 #include "content/common/pepper_plugin_registry.h" 26 #include "content/common/pepper_plugin_registry.h"
27 #include "content/common/plugin_messages.h" 27 #include "content/common/plugin_messages.h"
28 #include "content/common/view_messages.h" 28 #include "content/common/view_messages.h"
29 #include "webkit/plugins/npapi/plugin_constants_win.h" 29 #include "webkit/plugins/npapi/plugin_constants_win.h"
30 #include "webkit/plugins/npapi/plugin_list.h" 30 #include "webkit/plugins/npapi/plugin_list.h"
31 #include "webkit/plugins/npapi/webplugininfo.h" 31 #include "webkit/plugins/npapi/webplugininfo.h"
32 32
33 #if defined(OS_POSIX) && !defined(OS_MACOSX) 33 #if defined(OS_POSIX) && !defined(OS_MACOSX)
34 using ::base::files::FilePathWatcher; 34 using ::base::files::FilePathWatcher;
35 #endif 35 #endif
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 webkit::npapi::kRegistryMozillaPlugins, 95 webkit::npapi::kRegistryMozillaPlugins,
96 KEY_NOTIFY) == ERROR_SUCCESS) { 96 KEY_NOTIFY) == ERROR_SUCCESS) {
97 if (hklm_key_.StartWatching() == ERROR_SUCCESS) { 97 if (hklm_key_.StartWatching() == ERROR_SUCCESS) {
98 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event())); 98 hklm_event_.reset(new base::WaitableEvent(hklm_key_.watch_event()));
99 hklm_watcher_.StartWatching(hklm_event_.get(), this); 99 hklm_watcher_.StartWatching(hklm_event_.get(), this);
100 } 100 }
101 } 101 }
102 #elif defined(OS_MACOSX) 102 #elif defined(OS_MACOSX)
103 // We need to know when the browser comes forward so we can bring modal plugin 103 // We need to know when the browser comes forward so we can bring modal plugin
104 // windows forward too. 104 // windows forward too.
105 registrar_.Add(this, NotificationType::APP_ACTIVATED, 105 registrar_.Add(this, content::NOTIFICATION_APP_ACTIVATED,
106 NotificationService::AllSources()); 106 NotificationService::AllSources());
107 #elif defined(OS_POSIX) 107 #elif defined(OS_POSIX)
108 // The FilePathWatcher produces too many false positives on MacOS (access time 108 // The FilePathWatcher produces too many false positives on MacOS (access time
109 // updates?) which will lead to enforcing updates of the plugins way too often. 109 // updates?) which will lead to enforcing updates of the plugins way too often.
110 // On ChromeOS the user can't install plugins anyway and on Windows all 110 // On ChromeOS the user can't install plugins anyway and on Windows all
111 // important plugins register themselves in the registry so no need to do that. 111 // important plugins register themselves in the registry so no need to do that.
112 file_watcher_delegate_ = new PluginDirWatcherDelegate(); 112 file_watcher_delegate_ = new PluginDirWatcherDelegate();
113 // Get the list of all paths for registering the FilePathWatchers 113 // Get the list of all paths for registering the FilePathWatchers
114 // that will track and if needed reload the list of plugins on runtime. 114 // that will track and if needed reload the list of plugins on runtime.
115 std::vector<FilePath> plugin_dirs; 115 std::vector<FilePath> plugin_dirs;
(...skipping 11 matching lines...) Expand all
127 FilePathWatcher* watcher = new FilePathWatcher(); 127 FilePathWatcher* watcher = new FilePathWatcher();
128 VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value(); 128 VLOG(1) << "Watching for changes in: " << plugin_dirs[i].value();
129 BrowserThread::PostTask( 129 BrowserThread::PostTask(
130 BrowserThread::FILE, FROM_HERE, 130 BrowserThread::FILE, FROM_HERE,
131 NewRunnableFunction( 131 NewRunnableFunction(
132 &PluginService::RegisterFilePathWatcher, 132 &PluginService::RegisterFilePathWatcher,
133 watcher, plugin_dirs[i], file_watcher_delegate_)); 133 watcher, plugin_dirs[i], file_watcher_delegate_));
134 file_watchers_.push_back(watcher); 134 file_watchers_.push_back(watcher);
135 } 135 }
136 #endif 136 #endif
137 registrar_.Add(this, NotificationType::PLUGIN_ENABLE_STATUS_CHANGED, 137 registrar_.Add(this, content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
138 NotificationService::AllSources()); 138 NotificationService::AllSources());
139 registrar_.Add(this, 139 registrar_.Add(this,
140 NotificationType::RENDERER_PROCESS_CLOSED, 140 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
141 NotificationService::AllSources()); 141 NotificationService::AllSources());
142 } 142 }
143 143
144 PluginService::~PluginService() { 144 PluginService::~PluginService() {
145 #if defined(OS_WIN) 145 #if defined(OS_WIN)
146 // Release the events since they're owned by RegKey, not WaitableEvent. 146 // Release the events since they're owned by RegKey, not WaitableEvent.
147 hkcu_watcher_.StopWatching(); 147 hkcu_watcher_.StopWatching();
148 hklm_watcher_.StopWatching(); 148 hklm_watcher_.StopWatching();
149 if (hkcu_event_.get()) 149 if (hkcu_event_.get())
150 hkcu_event_->Release(); 150 hkcu_event_->Release();
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 } 383 }
384 384
385 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); 385 webkit::npapi::PluginList::Singleton()->RefreshPlugins();
386 PurgePluginListCache(true); 386 PurgePluginListCache(true);
387 #else 387 #else
388 // This event should only get signaled on a Windows machine. 388 // This event should only get signaled on a Windows machine.
389 NOTREACHED(); 389 NOTREACHED();
390 #endif // defined(OS_WIN) 390 #endif // defined(OS_WIN)
391 } 391 }
392 392
393 void PluginService::Observe(NotificationType type, 393 void PluginService::Observe(int type,
394 const NotificationSource& source, 394 const NotificationSource& source,
395 const NotificationDetails& details) { 395 const NotificationDetails& details) {
396 switch (type.value) { 396 switch (type) {
397 #if defined(OS_MACOSX) 397 #if defined(OS_MACOSX)
398 case NotificationType::APP_ACTIVATED: { 398 case content::NOTIFICATION_APP_ACTIVATED: {
399 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, 399 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
400 NewRunnableFunction(&NotifyPluginsOfActivation)); 400 NewRunnableFunction(&NotifyPluginsOfActivation));
401 break; 401 break;
402 } 402 }
403 #endif 403 #endif
404 404
405 case NotificationType::PLUGIN_ENABLE_STATUS_CHANGED: { 405 case content::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED: {
406 webkit::npapi::PluginList::Singleton()->RefreshPlugins(); 406 webkit::npapi::PluginList::Singleton()->RefreshPlugins();
407 PurgePluginListCache(false); 407 PurgePluginListCache(false);
408 break; 408 break;
409 } 409 }
410 case NotificationType::RENDERER_PROCESS_CLOSED: { 410 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
411 int render_process_id = Source<RenderProcessHost>(source).ptr()->id(); 411 int render_process_id = Source<RenderProcessHost>(source).ptr()->id();
412 412
413 base::AutoLock auto_lock(overridden_plugins_lock_); 413 base::AutoLock auto_lock(overridden_plugins_lock_);
414 for (size_t i = 0; i < overridden_plugins_.size(); ++i) { 414 for (size_t i = 0; i < overridden_plugins_.size(); ++i) {
415 if (overridden_plugins_[i].render_process_id == render_process_id) { 415 if (overridden_plugins_[i].render_process_id == render_process_id) {
416 overridden_plugins_.erase(overridden_plugins_.begin() + i); 416 overridden_plugins_.erase(overridden_plugins_.begin() + i);
417 break; 417 break;
418 } 418 }
419 } 419 }
420 break; 420 break;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 #if defined(OS_POSIX) && !defined(OS_MACOSX) 487 #if defined(OS_POSIX) && !defined(OS_MACOSX)
488 // static 488 // static
489 void PluginService::RegisterFilePathWatcher( 489 void PluginService::RegisterFilePathWatcher(
490 FilePathWatcher *watcher, 490 FilePathWatcher *watcher,
491 const FilePath& path, 491 const FilePath& path,
492 FilePathWatcher::Delegate* delegate) { 492 FilePathWatcher::Delegate* delegate) {
493 bool result = watcher->Watch(path, delegate); 493 bool result = watcher->Watch(path, delegate);
494 DCHECK(result); 494 DCHECK(result);
495 } 495 }
496 #endif 496 #endif
OLDNEW
« no previous file with comments | « content/browser/plugin_service.h ('k') | content/browser/renderer_host/browser_render_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698