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

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

Issue 12114045: Broke ContentSettingBubbleModelTest.Plugins on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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) 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_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ 5 #ifndef CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_
6 #define CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ 6 #define CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set>
10 #include <vector> 9 #include <vector>
11 10
12 #include "base/file_path.h" 11 #include "base/file_path.h"
13 #include "base/hash_tables.h" 12 #include "base/hash_tables.h"
14 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
15 #include "base/memory/singleton.h" 14 #include "base/memory/singleton.h"
16 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
17 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/plugin_service_filter.h" 18 #include "content/public/browser/plugin_service_filter.h"
(...skipping 24 matching lines...) Expand all
44 43
45 // 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
46 // URL. 45 // URL.
47 void RestrictPluginToProfileAndOrigin(const FilePath& plugin_path, 46 void RestrictPluginToProfileAndOrigin(const FilePath& plugin_path,
48 Profile* profile, 47 Profile* profile,
49 const GURL& url); 48 const GURL& url);
50 49
51 // Lifts a restriction on a plug-in. 50 // Lifts a restriction on a plug-in.
52 void UnrestrictPlugin(const FilePath& plugin_path); 51 void UnrestrictPlugin(const FilePath& plugin_path);
53 52
54 // Authorizes a given plug-in for a given process.
55 void AuthorizePlugin(int render_process_id, const FilePath& plugin_path);
56
57 // Authorizes all plug-ins for a given process.
58 void AuthorizeAllPlugins(int render_process_id);
59
60 // PluginServiceFilter implementation: 53 // PluginServiceFilter implementation:
61 virtual bool IsPluginEnabled( 54 virtual bool ShouldUsePlugin(
62 int render_process_id, 55 int render_process_id,
63 int render_view_id, 56 int render_view_id,
64 const void* context, 57 const void* context,
65 const GURL& url, 58 const GURL& url,
66 const GURL& policy_url, 59 const GURL& policy_url,
67 webkit::WebPluginInfo* plugin) OVERRIDE; 60 webkit::WebPluginInfo* plugin) OVERRIDE;
68 61
69 // CanLoadPlugin always grants permission to the browser
70 // (render_process_id == 0)
71 virtual bool CanLoadPlugin(
72 int render_process_id,
73 const FilePath& path) OVERRIDE;
74
75 private: 62 private:
76 friend struct DefaultSingletonTraits<ChromePluginServiceFilter>; 63 friend struct DefaultSingletonTraits<ChromePluginServiceFilter>;
77 64
78 struct OverriddenPlugin { 65 struct OverriddenPlugin {
79 OverriddenPlugin(); 66 int render_process_id;
80 ~OverriddenPlugin();
81
82 int render_view_id; 67 int render_view_id;
83 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.
84 webkit::WebPluginInfo plugin; 69 webkit::WebPluginInfo plugin;
85 }; 70 };
86 71
87 struct ProcessDetails {
88 ProcessDetails();
89 ~ProcessDetails();
90
91 std::vector<OverriddenPlugin> overridden_plugins;
92 std::set<FilePath> authorized_plugins;
93 };
94
95 ChromePluginServiceFilter(); 72 ChromePluginServiceFilter();
96 virtual ~ChromePluginServiceFilter(); 73 virtual ~ChromePluginServiceFilter();
97 74
98 // content::NotificationObserver implementation: 75 // content::NotificationObserver implementation:
99 virtual void Observe(int type, 76 virtual void Observe(int type,
100 const content::NotificationSource& source, 77 const content::NotificationSource& source,
101 const content::NotificationDetails& details) OVERRIDE; 78 const content::NotificationDetails& details) OVERRIDE;
102 79
103 ProcessDetails* GetOrRegisterProcess(int render_process_id);
104 const ProcessDetails* GetProcess(int render_process_id) const;
105
106 content::NotificationRegistrar registrar_; 80 content::NotificationRegistrar registrar_;
107 81
108 base::Lock lock_; // Guards access to member variables. 82 base::Lock lock_; // Guards access to member variables.
109 // Map of plugin paths to the origin they are restricted to. 83 // Map of plugin paths to the origin they are restricted to.
110 typedef std::pair<const void*, GURL> RestrictedPluginPair; 84 typedef std::pair<const void*, GURL> RestrictedPluginPair;
111 typedef base::hash_map<FilePath, RestrictedPluginPair> RestrictedPluginMap; 85 typedef base::hash_map<FilePath, RestrictedPluginPair> RestrictedPluginMap;
112 RestrictedPluginMap restricted_plugins_; 86 RestrictedPluginMap restricted_plugins_;
113 typedef std::map<const void*, scoped_refptr<PluginPrefs> > ResourceContextMap; 87 typedef std::map<const void*, scoped_refptr<PluginPrefs> > ResourceContextMap;
114 ResourceContextMap resource_context_map_; 88 ResourceContextMap resource_context_map_;
115 89
116 std::map<int, ProcessDetails> plugin_details_; 90 std::vector<OverriddenPlugin> overridden_plugins_;
117 }; 91 };
118 92
119 #endif // CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_ 93 #endif // CHROME_BROWSER_PLUGINS_CHROME_PLUGIN_SERVICE_FILTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698