| 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 // This class responds to requests from renderers for the list of plugins, and | 5 // This class responds to requests from renderers for the list of plugins, and |
| 6 // also a proxy object for plugin instances. | 6 // also a proxy object for plugin instances. |
| 7 | 7 |
| 8 #ifndef CONTENT_BROWSER_PLUGIN_SERVICE_H_ | 8 #ifndef CONTENT_BROWSER_PLUGIN_SERVICE_H_ |
| 9 #define CONTENT_BROWSER_PLUGIN_SERVICE_H_ | 9 #define CONTENT_BROWSER_PLUGIN_SERVICE_H_ |
| 10 #pragma once | 10 #pragma once |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
| 16 #include "base/hash_tables.h" | 16 #include "base/hash_tables.h" |
| 17 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
| 18 #include "base/memory/singleton.h" | 18 #include "base/memory/singleton.h" |
| 19 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
| 20 #include "base/synchronization/waitable_event_watcher.h" | 20 #include "base/synchronization/waitable_event_watcher.h" |
| 21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 22 #include "content/browser/plugin_process_host.h" | 22 #include "content/browser/plugin_process_host.h" |
| 23 #include "content/browser/ppapi_plugin_process_host.h" | 23 #include "content/browser/ppapi_plugin_process_host.h" |
| 24 #include "content/browser/ppapi_broker_process_host.h" | 24 #include "content/browser/ppapi_broker_process_host.h" |
| 25 #include "content/common/notification_observer.h" | 25 #include "content/common/notification_observer.h" |
| 26 #include "content/common/notification_registrar.h" | 26 #include "content/common/notification_registrar.h" |
| 27 #include "googleurl/src/gurl.h" | 27 #include "googleurl/src/gurl.h" |
| 28 #include "ipc/ipc_channel_handle.h" | 28 #include "ipc/ipc_channel_handle.h" |
| 29 #include "webkit/plugins/npapi/webplugininfo.h" | 29 #include "webkit/plugins/webplugininfo.h" |
| 30 | 30 |
| 31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
| 32 #include "base/memory/scoped_ptr.h" | 32 #include "base/memory/scoped_ptr.h" |
| 33 #include "base/win/registry.h" | 33 #include "base/win/registry.h" |
| 34 #endif | 34 #endif |
| 35 | 35 |
| 36 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 36 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 37 #include "base/files/file_path_watcher.h" | 37 #include "base/files/file_path_watcher.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 struct PepperPluginInfo; | 40 struct PepperPluginInfo; |
| 41 class PluginDirWatcherDelegate; | 41 class PluginDirWatcherDelegate; |
| 42 | 42 |
| 43 // This must be created on the main thread but it's only called on the IO/file | 43 // This must be created on the main thread but it's only called on the IO/file |
| 44 // thread. | 44 // thread. |
| 45 class PluginService | 45 class PluginService |
| 46 : public base::WaitableEventWatcher::Delegate, | 46 : public base::WaitableEventWatcher::Delegate, |
| 47 public NotificationObserver { | 47 public NotificationObserver { |
| 48 public: | 48 public: |
| 49 struct OverriddenPlugin { | 49 struct OverriddenPlugin { |
| 50 int render_process_id; | 50 int render_process_id; |
| 51 int render_view_id; | 51 int render_view_id; |
| 52 GURL url; | 52 GURL url; |
| 53 webkit::npapi::WebPluginInfo plugin; | 53 webkit::WebPluginInfo plugin; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // Returns the PluginService singleton. | 56 // Returns the PluginService singleton. |
| 57 static PluginService* GetInstance(); | 57 static PluginService* GetInstance(); |
| 58 | 58 |
| 59 // Gets the browser's UI locale. | 59 // Gets the browser's UI locale. |
| 60 const std::string& GetUILocale(); | 60 const std::string& GetUILocale(); |
| 61 | 61 |
| 62 // Returns the plugin process host corresponding to the plugin process that | 62 // Returns the plugin process host corresponding to the plugin process that |
| 63 // has been started by this service. Returns NULL if no process has been | 63 // has been started by this service. Returns NULL if no process has been |
| (...skipping 26 matching lines...) Expand all Loading... |
| 90 PpapiPluginProcessHost::Client* client); | 90 PpapiPluginProcessHost::Client* client); |
| 91 void OpenChannelToPpapiBroker(const FilePath& path, | 91 void OpenChannelToPpapiBroker(const FilePath& path, |
| 92 PpapiBrokerProcessHost::Client* client); | 92 PpapiBrokerProcessHost::Client* client); |
| 93 | 93 |
| 94 // Gets the plugin in the list of plugins that matches the given url and mime | 94 // Gets the plugin in the list of plugins that matches the given url and mime |
| 95 // type. Must be called on the FILE thread. | 95 // type. Must be called on the FILE thread. |
| 96 bool GetPluginInfo(int render_process_id, | 96 bool GetPluginInfo(int render_process_id, |
| 97 int render_view_id, | 97 int render_view_id, |
| 98 const GURL& url, | 98 const GURL& url, |
| 99 const std::string& mime_type, | 99 const std::string& mime_type, |
| 100 webkit::npapi::WebPluginInfo* info, | 100 webkit::WebPluginInfo* info, |
| 101 std::string* actual_mime_type); | 101 std::string* actual_mime_type); |
| 102 | 102 |
| 103 // Safe to be called from any thread. | 103 // Safe to be called from any thread. |
| 104 void OverridePluginForTab(const OverriddenPlugin& plugin); | 104 void OverridePluginForTab(const OverriddenPlugin& plugin); |
| 105 | 105 |
| 106 // Restricts the given plugin to the the scheme and host of the given url. | 106 // Restricts the given plugin to the the scheme and host of the given url. |
| 107 // Call with an empty url to reset this. | 107 // Call with an empty url to reset this. |
| 108 // Can be called on any thread. | 108 // Can be called on any thread. |
| 109 void RestrictPluginToUrl(const FilePath& plugin_path, const GURL& url); | 109 void RestrictPluginToUrl(const FilePath& plugin_path, const GURL& url); |
| 110 | 110 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 std::vector<OverriddenPlugin> overridden_plugins_; | 189 std::vector<OverriddenPlugin> overridden_plugins_; |
| 190 base::Lock overridden_plugins_lock_; | 190 base::Lock overridden_plugins_lock_; |
| 191 | 191 |
| 192 DISALLOW_COPY_AND_ASSIGN(PluginService); | 192 DISALLOW_COPY_AND_ASSIGN(PluginService); |
| 193 }; | 193 }; |
| 194 | 194 |
| 195 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); | 195 DISABLE_RUNNABLE_METHOD_REFCOUNT(PluginService); |
| 196 | 196 |
| 197 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ | 197 #endif // CONTENT_BROWSER_PLUGIN_SERVICE_H_ |
| OLD | NEW |