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

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

Issue 10872034: Changing PluginPrefs to use PluginFinder's async interface. (Closed) Base URL: http://git.chromium.org/chromium/src.git@test_async
Patch Set: "Fixed review comments and added support for other methods in PluginPrefs to use async interface" Created 8 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
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_PLUGIN_PREFS_H_ 5 #ifndef CHROME_BROWSER_PLUGIN_PREFS_H_
6 #define CHROME_BROWSER_PLUGIN_PREFS_H_ 6 #define CHROME_BROWSER_PLUGIN_PREFS_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "chrome/browser/api/prefs/pref_change_registrar.h" 15 #include "chrome/browser/api/prefs/pref_change_registrar.h"
16 #include "chrome/browser/plugin_finder.h"
16 #include "chrome/browser/prefs/pref_service.h" 17 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h" 18 #include "chrome/browser/profiles/refcounted_profile_keyed_service.h"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 20
20 class Profile; 21 class Profile;
21 22
22 namespace base { 23 namespace base {
23 class ListValue; 24 class ListValue;
24 } 25 }
25 26
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 PluginPrefs(); 59 PluginPrefs();
59 60
60 // Associates this instance with |prefs|. This enables or disables 61 // Associates this instance with |prefs|. This enables or disables
61 // plugin groups as defined by the user's preferences. 62 // plugin groups as defined by the user's preferences.
62 // This method should only be called on the UI thread. 63 // This method should only be called on the UI thread.
63 void SetPrefs(PrefService* prefs); 64 void SetPrefs(PrefService* prefs);
64 65
65 // Enable or disable a plugin group. 66 // Enable or disable a plugin group.
66 void EnablePluginGroup(bool enable, const string16& group_name); 67 void EnablePluginGroup(bool enable, const string16& group_name);
67 68
68 // Returns true if the plug-in state can be enabled or disabled according to 69 // Enables or disables a specific plugin file, if possible,
69 // |enable|, false if the plug-in state cannot be changed because of a policy. 70 // and calls |enableCallback| afterwards. If not possible (because the
70 bool CanEnablePlugin(bool enable, const FilePath& file_path); 71 // plug-in state cannot be changed because of a policy), it will silently
Pam (message me for reviews) 2012/08/27 13:18:05 nit: clarify "it": something like "this entire met
ibraaaa 2012/08/28 09:25:52 Done.
71 72 // be ignored. |canEnabledCallback| will be called after the plug-in
Pam (message me for reviews) 2012/08/27 13:18:05 typo: |canEnableCallback|
ibraaaa 2012/08/28 09:25:52 Done.
72 // Enables or disables a specific plugin file, and calls |callback| 73 // change state check is called.
Pam (message me for reviews) 2012/08/27 13:18:05 I don't understand what a "plug-in change state ch
ibraaaa 2012/08/28 09:25:52 Done.
73 // afterwards.
74 // If the plug-in state cannot be changed because of a policy (as indicated
75 // by |CanEnablePlugin|), it will be silently ignored.
76 void EnablePlugin(bool enable, const FilePath& file_path, 74 void EnablePlugin(bool enable, const FilePath& file_path,
77 const base::Closure& callback); 75 const base::Closure& enableCallback,
76 const base::Callback<void(bool)>& canEnableCallback);
78 77
79 // Enables or disables a plug-in in all profiles, and calls |callback| 78 // Enables or disables a plug-in in all profiles, and calls |callback|
80 // afterwards. This sets a default for profiles which are created later as 79 // afterwards. This sets a default for profiles which are created later as
81 // well. 80 // well.
82 // If the plug-in state in a profile cannot be changed because of a policy, 81 // If the plug-in state in a profile cannot be changed because of a policy,
83 // it will be silently ignored. 82 // it will be silently ignored.
84 // This method should only be called on the UI thread. 83 // This method should only be called on the UI thread.
85 static void EnablePluginGlobally(bool enable, const FilePath& file_path, 84 static void EnablePluginGlobally(bool enable, const FilePath& file_path,
86 const base::Closure& callback); 85 const base::Closure& callback);
87 86
(...skipping 30 matching lines...) Expand all
118 const std::set<string16>& disabled_exception_patterns, 117 const std::set<string16>& disabled_exception_patterns,
119 const std::set<string16>& enabled_patterns); 118 const std::set<string16>& enabled_patterns);
120 119
121 // Returns the plugin list to use, either the singleton or the override. 120 // Returns the plugin list to use, either the singleton or the override.
122 webkit::npapi::PluginList* GetPluginList() const; 121 webkit::npapi::PluginList* GetPluginList() const;
123 122
124 // Callback for after the plugin groups have been loaded. 123 // Callback for after the plugin groups have been loaded.
125 void EnablePluginGroupInternal( 124 void EnablePluginGroupInternal(
126 bool enabled, 125 bool enabled,
127 const string16& group_name, 126 const string16& group_name,
128 const std::vector<webkit::npapi::PluginGroup>& groups); 127 PluginFinder* plugin_finder,
128 const std::vector<webkit::WebPluginInfo>& plugins);
129 void EnablePluginInternal( 129 void EnablePluginInternal(
130 bool enabled, 130 bool enabled,
131 const FilePath& path, 131 const FilePath& path,
132 PluginFinder* plugin_finder,
132 const base::Closure& callback, 133 const base::Closure& callback,
133 const std::vector<webkit::npapi::PluginGroup>& groups); 134 const std::vector<webkit::WebPluginInfo>& plugins);
134 135
135 // Called on the file thread to get the data necessary to update the saved 136 // Called on the file thread to get the data necessary to update the saved
136 // preferences. 137 // preferences.
137 void GetPreferencesDataOnFileThread(); 138 void GetPreferencesDataOnFileThread();
138 139
139 // Called on the UI thread with the plugin data to save the preferences. 140 // Called on the UI thread with the plugin data to save the preferences.
140 void OnUpdatePreferences( 141 void OnUpdatePreferences(const std::vector<webkit::WebPluginInfo>& plugins,
141 const std::vector<webkit::npapi::PluginGroup>& groups); 142 PluginFinder* finder);
142 143
143 // Sends the notification that plugin data has changed. 144 // Sends the notification that plugin data has changed.
144 void NotifyPluginStatusChanged(); 145 void NotifyPluginStatusChanged();
145 146
146 static void ListValueToStringSet(const base::ListValue* src, 147 static void ListValueToStringSet(const base::ListValue* src,
147 std::set<string16>* dest); 148 std::set<string16>* dest);
148 149
149 // Checks if |name| matches any of the patterns in |pattern_set|. 150 // Checks if |name| matches any of the patterns in |pattern_set|.
150 static bool IsStringMatchedInSet(const string16& name, 151 static bool IsStringMatchedInSet(const string16& name,
151 const std::set<string16>& pattern_set); 152 const std::set<string16>& pattern_set);
152 153
154 // Callback method called by 'EnablePlugin' method.
155 // It performs the logic to check if a plug-in can be enabled.
156 void EnablePluginIfPossibleCallback(
157 bool enabled, const FilePath& path,
158 const base::Closure& enableCallback,
159 const base::Callback<void(bool)>& canEnableCallback,
160 PluginFinder* finder);
161
162 // Callback method that takes in the asynchronously created
163 // plug-in finder instance. It is called by 'EnablePluginGroup'.
164 void GetPluginFinderForEnablePluginGroup(bool enabled,
165 const string16& group_name,
166 PluginFinder* finder);
167
168 // Callback method that takes in the asynchronously created plug-in finder
169 // instance. It is called by 'GetPreferencesDataOnFileThread'.
170 void GetPluginFinderForGetPreferencesDataOnFileThread(PluginFinder* finder);
171
153 // Guards access to the following data structures. 172 // Guards access to the following data structures.
154 mutable base::Lock lock_; 173 mutable base::Lock lock_;
155 174
156 std::map<FilePath, bool> plugin_state_; 175 std::map<FilePath, bool> plugin_state_;
157 std::map<string16, bool> plugin_group_state_; 176 std::map<string16, bool> plugin_group_state_;
158 177
159 std::set<string16> policy_disabled_plugin_patterns_; 178 std::set<string16> policy_disabled_plugin_patterns_;
160 std::set<string16> policy_disabled_plugin_exception_patterns_; 179 std::set<string16> policy_disabled_plugin_exception_patterns_;
161 std::set<string16> policy_enabled_plugin_patterns_; 180 std::set<string16> policy_enabled_plugin_patterns_;
162 181
163 // Weak pointer, owns us. Only used as a notification source. 182 // Weak pointer, owns us. Only used as a notification source.
164 Profile* profile_; 183 Profile* profile_;
165 184
166 // Weak pointer, owned by the profile. 185 // Weak pointer, owned by the profile.
167 PrefService* prefs_; 186 PrefService* prefs_;
168 187
169 // PluginList to use for testing. If this is NULL, defaults to the global 188 // PluginList to use for testing. If this is NULL, defaults to the global
170 // singleton. 189 // singleton.
171 webkit::npapi::PluginList* plugin_list_; 190 webkit::npapi::PluginList* plugin_list_;
172 191
173 PrefChangeRegistrar registrar_; 192 PrefChangeRegistrar registrar_;
174 193
175 DISALLOW_COPY_AND_ASSIGN(PluginPrefs); 194 DISALLOW_COPY_AND_ASSIGN(PluginPrefs);
176 }; 195 };
177 196
178 #endif // CHROME_BROWSER_PLUGIN_PREFS_H_ 197 #endif // CHROME_BROWSER_PLUGIN_PREFS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698