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

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: Fixing another comment from Pam Created 8 years, 3 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
71 72 // ignore enabling the plug-in and calling |enableCallback|.
72 // Enables or disables a specific plugin file, and calls |callback| 73 // |canEnableCallback| will be called after the plug-in state-change
73 // afterwards. 74 // check is called regardless of the check's result.
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, 75 void EnablePlugin(bool enable, const FilePath& file_path,
77 const base::Closure& callback); 76 const base::Closure& enableCallback,
77 const base::Callback<void(bool)>& canEnableCallback);
78 78
79 // Enables or disables a plug-in in all profiles, and calls |callback| 79 // 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 80 // afterwards. This sets a default for profiles which are created later as
81 // well. 81 // well.
82 // If the plug-in state in a profile cannot be changed because of a policy, 82 // If the plug-in state in a profile cannot be changed because of a policy,
83 // it will be silently ignored. 83 // it will be silently ignored.
84 // This method should only be called on the UI thread. 84 // This method should only be called on the UI thread.
85 static void EnablePluginGlobally(bool enable, const FilePath& file_path, 85 static void EnablePluginGlobally(bool enable, const FilePath& file_path,
86 const base::Closure& callback); 86 const base::Closure& callback);
87 87
(...skipping 30 matching lines...) Expand all
118 const std::set<string16>& disabled_exception_patterns, 118 const std::set<string16>& disabled_exception_patterns,
119 const std::set<string16>& enabled_patterns); 119 const std::set<string16>& enabled_patterns);
120 120
121 // Returns the plugin list to use, either the singleton or the override. 121 // Returns the plugin list to use, either the singleton or the override.
122 webkit::npapi::PluginList* GetPluginList() const; 122 webkit::npapi::PluginList* GetPluginList() const;
123 123
124 // Callback for after the plugin groups have been loaded. 124 // Callback for after the plugin groups have been loaded.
125 void EnablePluginGroupInternal( 125 void EnablePluginGroupInternal(
126 bool enabled, 126 bool enabled,
127 const string16& group_name, 127 const string16& group_name,
128 const std::vector<webkit::npapi::PluginGroup>& groups); 128 PluginFinder* plugin_finder,
129 const std::vector<webkit::WebPluginInfo>& plugins);
129 void EnablePluginInternal( 130 void EnablePluginInternal(
130 bool enabled, 131 bool enabled,
131 const FilePath& path, 132 const FilePath& path,
133 PluginFinder* plugin_finder,
132 const base::Closure& callback, 134 const base::Closure& callback,
133 const std::vector<webkit::npapi::PluginGroup>& groups); 135 const std::vector<webkit::WebPluginInfo>& plugins);
134 136
135 // Called on the file thread to get the data necessary to update the saved 137 // Called on the file thread to get the data necessary to update the saved
136 // preferences. 138 // preferences.
137 void GetPreferencesDataOnFileThread(); 139 void GetPreferencesDataOnFileThread();
138 140
139 // Called on the UI thread with the plugin data to save the preferences. 141 // Called on the UI thread with the plugin data to save the preferences.
140 void OnUpdatePreferences( 142 void OnUpdatePreferences(const std::vector<webkit::WebPluginInfo>& plugins,
141 const std::vector<webkit::npapi::PluginGroup>& groups); 143 PluginFinder* finder);
142 144
143 // Sends the notification that plugin data has changed. 145 // Sends the notification that plugin data has changed.
144 void NotifyPluginStatusChanged(); 146 void NotifyPluginStatusChanged();
145 147
146 static void ListValueToStringSet(const base::ListValue* src, 148 static void ListValueToStringSet(const base::ListValue* src,
147 std::set<string16>* dest); 149 std::set<string16>* dest);
148 150
149 // Checks if |name| matches any of the patterns in |pattern_set|. 151 // Checks if |name| matches any of the patterns in |pattern_set|.
150 static bool IsStringMatchedInSet(const string16& name, 152 static bool IsStringMatchedInSet(const string16& name,
151 const std::set<string16>& pattern_set); 153 const std::set<string16>& pattern_set);
152 154
155 // Callback method called by 'EnablePlugin' method.
156 // It performs the logic to check if a plug-in can be enabled.
157 void EnablePluginIfPossibleCallback(
158 bool enabled, const FilePath& path,
159 const base::Closure& enableCallback,
160 const base::Callback<void(bool)>& canEnableCallback,
161 PluginFinder* finder);
162
163 // Callback method that takes in the asynchronously created
164 // plug-in finder instance. It is called by 'EnablePluginGroup'.
165 void GetPluginFinderForEnablePluginGroup(bool enabled,
166 const string16& group_name,
167 PluginFinder* finder);
168
169 // Callback method that takes in the asynchronously created plug-in finder
170 // instance. It is called by 'GetPreferencesDataOnFileThread'.
171 void GetPluginFinderForGetPreferencesDataOnFileThread(PluginFinder* finder);
172
153 // Guards access to the following data structures. 173 // Guards access to the following data structures.
154 mutable base::Lock lock_; 174 mutable base::Lock lock_;
155 175
156 std::map<FilePath, bool> plugin_state_; 176 std::map<FilePath, bool> plugin_state_;
157 std::map<string16, bool> plugin_group_state_; 177 std::map<string16, bool> plugin_group_state_;
158 178
159 std::set<string16> policy_disabled_plugin_patterns_; 179 std::set<string16> policy_disabled_plugin_patterns_;
160 std::set<string16> policy_disabled_plugin_exception_patterns_; 180 std::set<string16> policy_disabled_plugin_exception_patterns_;
161 std::set<string16> policy_enabled_plugin_patterns_; 181 std::set<string16> policy_enabled_plugin_patterns_;
162 182
163 // Weak pointer, owns us. Only used as a notification source. 183 // Weak pointer, owns us. Only used as a notification source.
164 Profile* profile_; 184 Profile* profile_;
165 185
166 // Weak pointer, owned by the profile. 186 // Weak pointer, owned by the profile.
167 PrefService* prefs_; 187 PrefService* prefs_;
168 188
169 // PluginList to use for testing. If this is NULL, defaults to the global 189 // PluginList to use for testing. If this is NULL, defaults to the global
170 // singleton. 190 // singleton.
171 webkit::npapi::PluginList* plugin_list_; 191 webkit::npapi::PluginList* plugin_list_;
172 192
173 PrefChangeRegistrar registrar_; 193 PrefChangeRegistrar registrar_;
174 194
175 DISALLOW_COPY_AND_ASSIGN(PluginPrefs); 195 DISALLOW_COPY_AND_ASSIGN(PluginPrefs);
176 }; 196 };
177 197
178 #endif // CHROME_BROWSER_PLUGIN_PREFS_H_ 198 #endif // CHROME_BROWSER_PLUGIN_PREFS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698