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

Side by Side Diff: chrome/browser/plugin_service.h

Issue 164305: Ensure we don't load plugins on the IO thread (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/browser/plugin_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_PLUGIN_SERVICE_H_ 8 #ifndef CHROME_BROWSER_PLUGIN_SERVICE_H_
9 #define CHROME_BROWSER_PLUGIN_SERVICE_H_ 9 #define CHROME_BROWSER_PLUGIN_SERVICE_H_
10 10
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/hash_tables.h" 14 #include "base/hash_tables.h"
15 #include "base/lock.h"
16 #include "base/ref_counted.h" 15 #include "base/ref_counted.h"
17 #include "base/singleton.h" 16 #include "base/singleton.h"
18 #include "base/waitable_event_watcher.h" 17 #include "base/waitable_event_watcher.h"
19 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
20 #include "chrome/common/notification_observer.h" 19 #include "chrome/common/notification_observer.h"
21 #include "chrome/common/notification_registrar.h" 20 #include "chrome/common/notification_registrar.h"
22 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
23 #include "webkit/glue/webplugininfo.h" 22 #include "webkit/glue/webplugininfo.h"
24 23
25 #if defined(OS_WIN) 24 #if defined(OS_WIN)
26 #include "base/registry.h" 25 #include "base/registry.h"
27 #endif 26 #endif
28 27
29 namespace IPC { 28 namespace IPC {
30 class Message; 29 class Message;
31 } 30 }
32 31
33 class MessageLoop; 32 class MessageLoop;
34 class PluginProcessHost; 33 class PluginProcessHost;
35 class URLRequestContext; 34 class URLRequestContext;
36 class ResourceDispatcherHost; 35 class ResourceDispatcherHost;
37 class ResourceMessageFilter; 36 class ResourceMessageFilter;
38 37
39 // This can be called on the main thread and IO thread. However it must 38 // This must be created on the main thread but it's only called on the IO/file
40 // be created on the main thread. 39 // thread.
41 class PluginService 40 class PluginService
42 : public base::WaitableEventWatcher::Delegate, 41 : public base::WaitableEventWatcher::Delegate,
43 public NotificationObserver { 42 public NotificationObserver {
44 public: 43 public:
45 // Returns the PluginService singleton. 44 // Returns the PluginService singleton.
46 static PluginService* GetInstance(); 45 static PluginService* GetInstance();
47 46
48 // Gets the list of available plugins.
49 void GetPlugins(bool refresh, std::vector<WebPluginInfo>* plugins);
50
51 // Load all the plugins that should be loaded for the lifetime of the browser 47 // Load all the plugins that should be loaded for the lifetime of the browser
52 // (ie, with the LoadOnStartup flag set). 48 // (ie, with the LoadOnStartup flag set).
53 void LoadChromePlugins(ResourceDispatcherHost* resource_dispatcher_host); 49 void LoadChromePlugins(ResourceDispatcherHost* resource_dispatcher_host);
54 50
55 // Sets/gets the data directory that Chrome plugins should use to store 51 // Sets/gets the data directory that Chrome plugins should use to store
56 // persistent data. 52 // persistent data.
57 void SetChromePluginDataDir(const FilePath& data_dir); 53 void SetChromePluginDataDir(const FilePath& data_dir);
58 const FilePath& GetChromePluginDataDir(); 54 const FilePath& GetChromePluginDataDir();
59 55
60 // Gets the browser's UI locale. 56 // Gets the browser's UI locale.
(...skipping 14 matching lines...) Expand all
75 // Opens a channel to a plugin process for the given mime type, starting 71 // Opens a channel to a plugin process for the given mime type, starting
76 // a new plugin process if necessary. This must be called on the IO thread 72 // a new plugin process if necessary. This must be called on the IO thread
77 // or else a deadlock can occur. 73 // or else a deadlock can occur.
78 void OpenChannelToPlugin(ResourceMessageFilter* renderer_msg_filter, 74 void OpenChannelToPlugin(ResourceMessageFilter* renderer_msg_filter,
79 const GURL& url, 75 const GURL& url,
80 const std::string& mime_type, 76 const std::string& mime_type,
81 const std::string& clsid, 77 const std::string& clsid,
82 const std::wstring& locale, 78 const std::wstring& locale,
83 IPC::Message* reply_msg); 79 IPC::Message* reply_msg);
84 80
85 bool HavePluginFor(const std::string& mime_type, bool allow_wildcard);
86
87 // Get the path to the plugin specified. policy_url is the URL of the page 81 // Get the path to the plugin specified. policy_url is the URL of the page
88 // requesting the plugin, so we can verify whether the plugin is allowed 82 // requesting the plugin, so we can verify whether the plugin is allowed
89 // on that page. 83 // on that page.
90 FilePath GetPluginPath(const GURL& url, 84 FilePath GetPluginPath(const GURL& url,
91 const GURL& policy_url, 85 const GURL& policy_url,
92 const std::string& mime_type, 86 const std::string& mime_type,
93 const std::string& clsid, 87 const std::string& clsid,
94 std::string* actual_mime_type); 88 std::string* actual_mime_type);
95 89
96 // The UI thread's message loop 90 // The UI thread's message loop
(...skipping 11 matching lines...) Expand all
108 PluginService(); 102 PluginService();
109 ~PluginService(); 103 ~PluginService();
110 104
111 // base::WaitableEventWatcher::Delegate implementation. 105 // base::WaitableEventWatcher::Delegate implementation.
112 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event); 106 virtual void OnWaitableEventSignaled(base::WaitableEvent* waitable_event);
113 107
114 // NotificationObserver implementation 108 // NotificationObserver implementation
115 virtual void Observe(NotificationType type, const NotificationSource& source, 109 virtual void Observe(NotificationType type, const NotificationSource& source,
116 const NotificationDetails& details); 110 const NotificationDetails& details);
117 111
118 // Get plugin info by matching full path.
119 bool GetPluginInfoByPath(const FilePath& plugin_path, WebPluginInfo* info);
120
121 // Returns true if the given plugin is allowed to be used by a page with 112 // Returns true if the given plugin is allowed to be used by a page with
122 // the given URL. 113 // the given URL.
123 bool PluginAllowedForURL(const FilePath& plugin_path, const GURL& url); 114 bool PluginAllowedForURL(const FilePath& plugin_path, const GURL& url);
124 115
125 // mapping between plugin path and PluginProcessHost 116 // mapping between plugin path and PluginProcessHost
126 typedef base::hash_map<FilePath, PluginProcessHost*> PluginMap; 117 typedef base::hash_map<FilePath, PluginProcessHost*> PluginMap;
127 PluginMap plugin_hosts_; 118 PluginMap plugin_hosts_;
128 119
129 // The main thread's message loop. 120 // The main thread's message loop.
130 MessageLoop* main_message_loop_; 121 MessageLoop* main_message_loop_;
131 122
132 // The IO thread's resource dispatcher host. 123 // The IO thread's resource dispatcher host.
133 ResourceDispatcherHost* resource_dispatcher_host_; 124 ResourceDispatcherHost* resource_dispatcher_host_;
134 125
135 // The data directory that Chrome plugins should use to store persistent data. 126 // The data directory that Chrome plugins should use to store persistent data.
136 FilePath chrome_plugin_data_dir_; 127 FilePath chrome_plugin_data_dir_;
137 128
138 // The browser's UI locale. 129 // The browser's UI locale.
139 const std::wstring ui_locale_; 130 const std::wstring ui_locale_;
140 131
141 // Map of plugin paths to the origin they are restricted to. Used for 132 // Map of plugin paths to the origin they are restricted to. Used for
142 // extension-only plugins. 133 // extension-only plugins.
143 typedef base::hash_map<FilePath, GURL> PrivatePluginMap; 134 typedef base::hash_map<FilePath, GURL> PrivatePluginMap;
144 PrivatePluginMap private_plugins_; 135 PrivatePluginMap private_plugins_;
145 136
146 // Need synchronization whenever we access the plugin_list singelton through
147 // webkit_glue since this class is called on the main and IO thread.
148 Lock lock_;
149
150 NotificationRegistrar registrar_; 137 NotificationRegistrar registrar_;
151 138
152 #if defined(OS_WIN) 139 #if defined(OS_WIN)
153 // Registry keys for getting notifications when new plugins are installed. 140 // Registry keys for getting notifications when new plugins are installed.
154 RegKey hkcu_key_; 141 RegKey hkcu_key_;
155 RegKey hklm_key_; 142 RegKey hklm_key_;
156 scoped_ptr<base::WaitableEvent> hkcu_event_; 143 scoped_ptr<base::WaitableEvent> hkcu_event_;
157 scoped_ptr<base::WaitableEvent> hklm_event_; 144 scoped_ptr<base::WaitableEvent> hklm_event_;
158 base::WaitableEventWatcher hkcu_watcher_; 145 base::WaitableEventWatcher hkcu_watcher_;
159 base::WaitableEventWatcher hklm_watcher_; 146 base::WaitableEventWatcher hklm_watcher_;
160 #endif 147 #endif
161 148
162 DISALLOW_COPY_AND_ASSIGN(PluginService); 149 DISALLOW_COPY_AND_ASSIGN(PluginService);
163 }; 150 };
164 151
165 #endif // CHROME_BROWSER_PLUGIN_SERVICE_H_ 152 #endif // CHROME_BROWSER_PLUGIN_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_service.cc ('k') | chrome/browser/plugin_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698