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

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

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

Powered by Google App Engine
This is Rietveld 408576698