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

Side by Side Diff: chrome/browser/plugin_updater.cc

Issue 5699005: Policy: Re-enabled plugin still disabled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up WebPluginInfo and rebased on fixed PluginGroup::InitFrom. Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/plugin_updater.h" 5 #include "chrome/browser/plugin_updater.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return plugin_groups_data; 57 return plugin_groups_data;
58 } 58 }
59 59
60 void PluginUpdater::EnablePluginGroup(bool enable, const string16& group_name) { 60 void PluginUpdater::EnablePluginGroup(bool enable, const string16& group_name) {
61 if (webkit::npapi::PluginGroup::IsPluginNameDisabledByPolicy(group_name)) 61 if (webkit::npapi::PluginGroup::IsPluginNameDisabledByPolicy(group_name))
62 enable = false; 62 enable = false;
63 webkit::npapi::PluginList::Singleton()->EnableGroup(enable, group_name); 63 webkit::npapi::PluginList::Singleton()->EnableGroup(enable, group_name);
64 NotifyPluginStatusChanged(); 64 NotifyPluginStatusChanged();
65 } 65 }
66 66
67 void PluginUpdater::EnablePluginFile(bool enable, 67 void PluginUpdater::EnablePlugin(bool enable,
68 const FilePath::StringType& path) { 68 const FilePath::StringType& path,
69 const string16& name) {
69 FilePath file_path(path); 70 FilePath file_path(path);
70 if (enable && 71 if (enable)
71 !webkit::npapi::PluginGroup::IsPluginPathDisabledByPolicy(file_path)) 72 webkit::npapi::PluginList::Singleton()->EnablePlugin(file_path, name);
72 webkit::npapi::PluginList::Singleton()->EnablePlugin(file_path);
73 else 73 else
74 webkit::npapi::PluginList::Singleton()->DisablePlugin(file_path); 74 webkit::npapi::PluginList::Singleton()->DisablePlugin(file_path, name);
75 75
76 NotifyPluginStatusChanged(); 76 NotifyPluginStatusChanged();
77 } 77 }
78 78
79 void PluginUpdater::Observe(NotificationType type, 79 void PluginUpdater::Observe(NotificationType type,
80 const NotificationSource& source, 80 const NotificationSource& source,
81 const NotificationDetails& details) { 81 const NotificationDetails& details) {
82 DCHECK_EQ(NotificationType::PREF_CHANGED, type.value); 82 DCHECK_EQ(NotificationType::PREF_CHANGED, type.value);
83 const std::string* pref_name = Details<std::string>(details).ptr(); 83 const std::string* pref_name = Details<std::string>(details).ptr();
84 if (!pref_name) { 84 if (!pref_name) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 found_internal_pdf = true; 185 found_internal_pdf = true;
186 if (!enabled) { 186 if (!enabled) {
187 if (force_enable_internal_pdf) { 187 if (force_enable_internal_pdf) {
188 enabled = true; 188 enabled = true;
189 plugin->SetBoolean("enabled", true); 189 plugin->SetBoolean("enabled", true);
190 } else if (force_internal_pdf_for_this_run) { 190 } else if (force_internal_pdf_for_this_run) {
191 enabled = true; 191 enabled = true;
192 } 192 }
193 } 193 }
194 } 194 }
195 if (!enabled) 195 if (!enabled) {
196 webkit::npapi::PluginList::Singleton()->DisablePlugin(plugin_path); 196 string16 name;
197 plugin->GetString("name", &name);
198 webkit::npapi::PluginList::Singleton()->DisablePlugin(plugin_path,
199 name);
200 }
197 } else if (!enabled && plugin->GetString("name", &group_name)) { 201 } else if (!enabled && plugin->GetString("name", &group_name)) {
198 // Don't disable this group if it's for the pdf plugin and we just 202 // Don't disable this group if it's for the pdf plugin and we just
199 // forced it on. 203 // forced it on.
200 if (force_enable_internal_pdf && pdf_group_name == group_name) 204 if (force_enable_internal_pdf && pdf_group_name == group_name)
201 continue; 205 continue;
202 206
203 // Otherwise this is a list of groups. 207 // Otherwise this is a list of groups.
204 EnablePluginGroup(false, group_name); 208 EnablePluginGroup(false, group_name);
205 } 209 }
206 } 210 }
207 } 211 }
208 212
209 // Build the set of policy-disabled plugin patterns once and cache it. 213 // Build the set of policy-disabled plugin patterns once and cache it.
210 // Don't do this in the constructor, there's no profile available there. 214 // Don't do this in the constructor, there's no profile available there.
211 const ListValue* plugin_blacklist = 215 const ListValue* plugin_blacklist =
212 profile->GetPrefs()->GetList(prefs::kPluginsPluginsBlacklist); 216 profile->GetPrefs()->GetList(prefs::kPluginsPluginsBlacklist);
213 DisablePluginsFromPolicy(plugin_blacklist); 217 DisablePluginsFromPolicy(plugin_blacklist);
214 218
215 if ((!enable_internal_pdf_ && !found_internal_pdf) && 219 if ((!enable_internal_pdf_ && !found_internal_pdf) &&
216 !force_internal_pdf_for_this_run) { 220 !force_internal_pdf_for_this_run) {
217 // The internal PDF plugin is disabled by default, and the user hasn't 221 // The internal PDF plugin is disabled by default, and the user hasn't
218 // overridden the default. 222 // overridden the default.
219 webkit::npapi::PluginList::Singleton()->DisablePlugin(pdf_path); 223 webkit::npapi::PluginList::Singleton()->DisablePlugin(pdf_path,
224 pdf_group_name);
220 EnablePluginGroup(false, pdf_group_name); 225 EnablePluginGroup(false, pdf_group_name);
221 } 226 }
222 227
223 if (force_enable_internal_pdf) { 228 if (force_enable_internal_pdf) {
224 // See http://crbug.com/50105 for background. 229 // See http://crbug.com/50105 for background.
225 EnablePluginGroup(false, ASCIIToUTF16( 230 EnablePluginGroup(false, ASCIIToUTF16(
226 webkit::npapi::PluginGroup::kAdobeReaderGroupName)); 231 webkit::npapi::PluginGroup::kAdobeReaderGroupName));
227 232
228 // We want to save this, but doing so requires loading the list of plugins, 233 // We want to save this, but doing so requires loading the list of plugins,
229 // so do it after a minute as to not impact startup performance. Note that 234 // so do it after a minute as to not impact startup performance. Note that
(...skipping 13 matching lines...) Expand all
243 void PluginUpdater::GetPreferencesDataOnFileThread(void* profile) { 248 void PluginUpdater::GetPreferencesDataOnFileThread(void* profile) {
244 std::vector<webkit::npapi::WebPluginInfo> plugins; 249 std::vector<webkit::npapi::WebPluginInfo> plugins;
245 webkit::npapi::PluginList::Singleton()->GetPlugins(false, &plugins); 250 webkit::npapi::PluginList::Singleton()->GetPlugins(false, &plugins);
246 251
247 std::vector<webkit::npapi::PluginGroup> groups; 252 std::vector<webkit::npapi::PluginGroup> groups;
248 webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, &groups); 253 webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, &groups);
249 254
250 BrowserThread::PostTask( 255 BrowserThread::PostTask(
251 BrowserThread::UI, 256 BrowserThread::UI,
252 FROM_HERE, 257 FROM_HERE,
253 NewRunnableFunction( 258 NewRunnableFunction(&PluginUpdater::OnUpdatePreferences,
254 &PluginUpdater::OnUpdatePreferences, 259 static_cast<Profile*>(profile),
255 static_cast<Profile*>(profile), plugins, groups)); 260 plugins, groups));
256 } 261 }
257 262
258 void PluginUpdater::OnUpdatePreferences( 263 void PluginUpdater::OnUpdatePreferences(
259 Profile* profile, 264 Profile* profile,
260 const std::vector<webkit::npapi::WebPluginInfo>& plugins, 265 const std::vector<webkit::npapi::WebPluginInfo>& plugins,
261 const std::vector<webkit::npapi::PluginGroup>& groups) { 266 const std::vector<webkit::npapi::PluginGroup>& groups) {
262 ListValue* plugins_list = profile->GetPrefs()->GetMutableList( 267 ListValue* plugins_list = profile->GetPrefs()->GetMutableList(
263 prefs::kPluginsPluginsList); 268 prefs::kPluginsPluginsList);
264 plugins_list->Clear(); 269 plugins_list->Clear();
265 270
266 FilePath internal_dir; 271 FilePath internal_dir;
267 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir)) 272 if (PathService::Get(chrome::DIR_INTERNAL_PLUGINS, &internal_dir))
268 profile->GetPrefs()->SetFilePath(prefs::kPluginsLastInternalDirectory, 273 profile->GetPrefs()->SetFilePath(prefs::kPluginsLastInternalDirectory,
269 internal_dir); 274 internal_dir);
270 275
271 // Add the plugin files. 276 // Add the plugin files.
272 for (std::vector<webkit::npapi::WebPluginInfo>::const_iterator it = 277 for (size_t i = 0; i < plugins.size(); ++i) {
273 plugins.begin(); 278 DictionaryValue* summary = CreatePluginFileSummary(plugins[i]);
274 it != plugins.end(); 279 // If the plugin is disabled only by policy don't store this state in the
275 ++it) { 280 // user pref store.
276 plugins_list->Append(CreatePluginFileSummary(*it)); 281 if (!webkit::npapi::WebPluginInfoUtils::IsEnabled(plugins[i]) &&
282 plugins[i].reason == webkit::npapi::WebPluginInfo::MANAGED)
283 summary->SetBoolean("enabled", true);
284 plugins_list->Append(summary);
277 } 285 }
278 286
279 // Add the groups as well. 287 // Add the groups as well.
280 for (size_t i = 0; i < groups.size(); ++i) { 288 for (size_t i = 0; i < groups.size(); ++i) {
281 plugins_list->Append(groups[i].GetSummary()); 289 DictionaryValue* summary = groups[i].GetSummary();
290 // If the plugin is disabled only by policy don't store this state in the
291 // user pref store.
292 if (!groups[i].Enabled() &&
293 webkit::npapi::PluginGroup::IsPluginNameDisabledByPolicy(
294 groups[i].GetGroupName()))
295 summary->SetBoolean("enabled", true);
296 plugins_list->Append(summary);
282 } 297 }
283 } 298 }
284 299
285 void PluginUpdater::NotifyPluginStatusChanged() { 300 void PluginUpdater::NotifyPluginStatusChanged() {
286 if (notify_pending_) 301 if (notify_pending_)
287 return; 302 return;
288 notify_pending_ = true; 303 notify_pending_ = true;
289 MessageLoop::current()->PostTask( 304 MessageLoop::current()->PostTask(
290 FROM_HERE, 305 FROM_HERE,
291 NewRunnableFunction(&PluginUpdater::OnNotifyPluginStatusChanged)); 306 NewRunnableFunction(&PluginUpdater::OnNotifyPluginStatusChanged));
292 } 307 }
293 308
294 void PluginUpdater::OnNotifyPluginStatusChanged() { 309 void PluginUpdater::OnNotifyPluginStatusChanged() {
295 GetInstance()->notify_pending_ = false; 310 GetInstance()->notify_pending_ = false;
296 NotificationService::current()->Notify( 311 NotificationService::current()->Notify(
297 NotificationType::PLUGIN_ENABLE_STATUS_CHANGED, 312 NotificationType::PLUGIN_ENABLE_STATUS_CHANGED,
298 Source<PluginUpdater>(GetInstance()), 313 Source<PluginUpdater>(GetInstance()),
299 NotificationService::NoDetails()); 314 NotificationService::NoDetails());
300 } 315 }
301 316
302 /*static*/ 317 /*static*/
303 PluginUpdater* PluginUpdater::GetInstance() { 318 PluginUpdater* PluginUpdater::GetInstance() {
304 return Singleton<PluginUpdater>::get(); 319 return Singleton<PluginUpdater>::get();
305 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698