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

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

Issue 10993016: Override plug-ins by path instead of name. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 2 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 | « no previous file | chrome/browser/chrome_plugin_service_filter.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROME_PLUGIN_SERVICE_FILTER_H_ 5 #ifndef CHROME_BROWSER_CHROME_PLUGIN_SERVICE_FILTER_H_
6 #define CHROME_BROWSER_CHROME_PLUGIN_SERVICE_FILTER_H_ 6 #define CHROME_BROWSER_CHROME_PLUGIN_SERVICE_FILTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/browser/plugin_service_filter.h" 18 #include "content/public/browser/plugin_service_filter.h"
19 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
20 #include "webkit/plugins/webplugininfo.h"
20 21
21 class PluginPrefs; 22 class PluginPrefs;
22 class Profile; 23 class Profile;
23 24
24 // This class must be created (by calling the |GetInstance| method) on the UI 25 // This class must be created (by calling the |GetInstance| method) on the UI
25 // thread, but is safe to use on any thread after that. 26 // thread, but is safe to use on any thread after that.
26 class ChromePluginServiceFilter : public content::PluginServiceFilter, 27 class ChromePluginServiceFilter : public content::PluginServiceFilter,
27 public content::NotificationObserver { 28 public content::NotificationObserver {
28 public: 29 public:
29 static ChromePluginServiceFilter* GetInstance(); 30 static ChromePluginServiceFilter* GetInstance();
30 31
31 // This method should be called on the UI thread. 32 // This method should be called on the UI thread.
32 void RegisterResourceContext(PluginPrefs* plugin_prefs, const void* context); 33 void RegisterResourceContext(PluginPrefs* plugin_prefs, const void* context);
33 34
34 void UnregisterResourceContext(const void* context); 35 void UnregisterResourceContext(const void* context);
35 36
36 // Overrides the plugin lookup mechanism for a given tab and object URL to use 37 // Overrides the plugin lookup mechanism for a given tab and object URL to use
37 // a specifc plugin. 38 // a specifc plugin.
38 void OverridePluginForTab(int render_process_id, 39 void OverridePluginForTab(int render_process_id,
39 int render_view_id, 40 int render_view_id,
40 const GURL& url, 41 const GURL& url,
41 const string16& plugin_name); 42 const webkit::WebPluginInfo& plugin);
42 43
43 // Restricts the given plugin to the given profile and origin of the given 44 // Restricts the given plugin to the given profile and origin of the given
44 // URL. 45 // URL.
45 void RestrictPluginToProfileAndOrigin(const FilePath& plugin_path, 46 void RestrictPluginToProfileAndOrigin(const FilePath& plugin_path,
46 Profile* profile, 47 Profile* profile,
47 const GURL& url); 48 const GURL& url);
48 49
49 // Lifts a restriction on a plug-in. 50 // Lifts a restriction on a plug-in.
50 void UnrestrictPlugin(const FilePath& plugin_path); 51 void UnrestrictPlugin(const FilePath& plugin_path);
51 52
52 // PluginServiceFilter implementation: 53 // PluginServiceFilter implementation:
53 virtual bool ShouldUsePlugin( 54 virtual bool ShouldUsePlugin(
54 int render_process_id, 55 int render_process_id,
55 int render_view_id, 56 int render_view_id,
56 const void* context, 57 const void* context,
57 const GURL& url, 58 const GURL& url,
58 const GURL& policy_url, 59 const GURL& policy_url,
59 webkit::WebPluginInfo* plugin) OVERRIDE; 60 webkit::WebPluginInfo* plugin) OVERRIDE;
60 61
61 private: 62 private:
62 friend struct DefaultSingletonTraits<ChromePluginServiceFilter>; 63 friend struct DefaultSingletonTraits<ChromePluginServiceFilter>;
63 64
64 struct OverriddenPlugin { 65 struct OverriddenPlugin {
65 int render_process_id; 66 int render_process_id;
66 int render_view_id; 67 int render_view_id;
67 GURL url; // If empty, the override applies to all urls in render_view. 68 GURL url; // If empty, the override applies to all urls in render_view.
68 string16 plugin_name; 69 webkit::WebPluginInfo plugin;
69 }; 70 };
70 71
71 ChromePluginServiceFilter(); 72 ChromePluginServiceFilter();
72 virtual ~ChromePluginServiceFilter(); 73 virtual ~ChromePluginServiceFilter();
73 74
74 // content::NotificationObserver implementation: 75 // content::NotificationObserver implementation:
75 virtual void Observe(int type, 76 virtual void Observe(int type,
76 const content::NotificationSource& source, 77 const content::NotificationSource& source,
77 const content::NotificationDetails& details) OVERRIDE; 78 const content::NotificationDetails& details) OVERRIDE;
78 79
79 content::NotificationRegistrar registrar_; 80 content::NotificationRegistrar registrar_;
80 81
81 base::Lock lock_; // Guards access to member variables. 82 base::Lock lock_; // Guards access to member variables.
82 // Map of plugin paths to the origin they are restricted to. 83 // Map of plugin paths to the origin they are restricted to.
83 typedef std::pair<const void*, GURL> RestrictedPluginPair; 84 typedef std::pair<const void*, GURL> RestrictedPluginPair;
84 typedef base::hash_map<FilePath, RestrictedPluginPair> RestrictedPluginMap; 85 typedef base::hash_map<FilePath, RestrictedPluginPair> RestrictedPluginMap;
85 RestrictedPluginMap restricted_plugins_; 86 RestrictedPluginMap restricted_plugins_;
86 typedef std::map<const void*, scoped_refptr<PluginPrefs> > ResourceContextMap; 87 typedef std::map<const void*, scoped_refptr<PluginPrefs> > ResourceContextMap;
87 ResourceContextMap resource_context_map_; 88 ResourceContextMap resource_context_map_;
88 89
89 std::vector<OverriddenPlugin> overridden_plugins_; 90 std::vector<OverriddenPlugin> overridden_plugins_;
90 }; 91 };
91 92
92 #endif // CHROME_BROWSER_CHROME_PLUGIN_SERVICE_FILTER_H_ 93 #endif // CHROME_BROWSER_CHROME_PLUGIN_SERVICE_FILTER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chrome_plugin_service_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698