OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_CHROME_PLUGIN_SERVICE_HELPER_H_ | |
6 #define CHROME_BROWSER_CHROME_PLUGIN_SERVICE_HELPER_H_ | |
7 #pragma once | |
8 | |
9 #include <vector> | |
10 | |
11 #include "base/hash_tables.h" | |
12 #include "base/file_path.h" | |
13 #include "base/memory/singleton.h" | |
14 #include "base/synchronization/lock.h" | |
15 #include "content/browser/plugin_service.h" | |
16 #include "content/common/notification_observer.h" | |
17 #include "content/common/notification_registrar.h" | |
18 #include "googleurl/src/gurl.h" | |
19 #include "webkit/plugins/npapi/webplugininfo.h" | |
20 | |
21 // This class must be created (by calling the |GetInstance| method) on the UI | |
22 // thread, but is safe to use on any thread after that. | |
23 class ChromePluginServiceHelper : public NotificationObserver { | |
jam
2011/08/01 03:25:44
we can make this also implement the filter interfa
| |
24 public: | |
25 struct OverriddenPlugin { | |
jam
2011/08/01 03:25:44
while you're cleaning this up, what do you think o
Bernhard Bauer
2011/08/01 16:06:12
Sounds good. Done.
| |
26 int render_process_id; | |
27 int render_view_id; | |
28 GURL url; | |
29 webkit::npapi::WebPluginInfo plugin; | |
30 }; | |
31 | |
32 static ChromePluginServiceHelper* GetInstance(); | |
33 | |
34 // Overrides the plugin lookup mechanism for a given tab and object URL to use | |
35 // a specifc plugin. | |
36 void OverridePluginForTab(const OverriddenPlugin& plugin); | |
37 | |
38 // Finds the overridden plugin for a given tab and object URL and returns a | |
39 // copy, or NULL if no overridden plugin was found. | |
40 // Caller takes ownership. | |
41 webkit::npapi::WebPluginInfo* FindOverriddenPluginForTab( | |
42 int render_process_id, | |
43 int render_view_id, | |
44 const GURL& url); | |
45 | |
46 // Restricts the given plugin to the the scheme and host of the given url. | |
47 // Call with an empty url to reset this. | |
48 void RestrictPluginToUrl(const FilePath& plugin_path, const GURL& url); | |
49 | |
50 // Returns the URL a given plugin is restricted to, or an empty URL if it can | |
51 // be used on all URLs. | |
52 GURL FindRestrictedURLForPlugin(const FilePath& plugin_path); | |
53 | |
54 // Creates a new plugin filter. Caller takes ownership. | |
55 // This method should only be called from the IO thread. | |
56 PluginService::Filter* CreatePluginFilter( | |
57 int render_process_id, | |
58 int render_view_id, | |
59 const content::ResourceContext& resource_context, | |
60 const GURL& url, | |
61 const GURL& policy_url); | |
62 | |
63 private: | |
64 friend struct DefaultSingletonTraits<ChromePluginServiceHelper>; | |
65 | |
66 ChromePluginServiceHelper(); | |
67 virtual ~ChromePluginServiceHelper(); | |
68 | |
69 // NotificationObserver implementation: | |
70 virtual void Observe(int type, | |
71 const NotificationSource& source, | |
72 const NotificationDetails& details); | |
73 | |
74 NotificationRegistrar registrar_; | |
75 | |
76 base::Lock lock_; // Guards access to member variables. | |
77 // Map of plugin paths to the origin they are restricted to. | |
78 typedef base::hash_map<FilePath, GURL> RestrictedPluginMap; | |
79 RestrictedPluginMap restricted_plugins_; | |
80 | |
81 std::vector<OverriddenPlugin> overridden_plugins_; | |
82 }; | |
83 | |
84 #endif // CHROME_BROWSER_CHROME_PLUGIN_SERVICE_HELPER_H_ | |
OLD | NEW |