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

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

Issue 8515021: Move PluginPrefs to use PluginService instead of PluginList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update tests Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/plugin_prefs.h ('k') | chrome/browser/plugin_prefs_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_prefs.h" 5 #include "chrome/browser/plugin_prefs.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 profile, &PluginPrefsFactory::CreateWrapperForProfile); 66 profile, &PluginPrefsFactory::CreateWrapperForProfile);
67 return static_cast<PluginPrefsWrapper*>(wrapper)->plugin_prefs(); 67 return static_cast<PluginPrefsWrapper*>(wrapper)->plugin_prefs();
68 } 68 }
69 69
70 void PluginPrefs::SetPluginListForTesting( 70 void PluginPrefs::SetPluginListForTesting(
71 webkit::npapi::PluginList* plugin_list) { 71 webkit::npapi::PluginList* plugin_list) {
72 plugin_list_ = plugin_list; 72 plugin_list_ = plugin_list;
73 } 73 }
74 74
75 void PluginPrefs::EnablePluginGroup(bool enabled, const string16& group_name) { 75 void PluginPrefs::EnablePluginGroup(bool enabled, const string16& group_name) {
76 if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { 76 PluginService::GetInstance()->GetPluginGroups(
77 BrowserThread::PostTask( 77 base::Bind(&PluginPrefs::EnablePluginGroupInternal,
78 BrowserThread::FILE, FROM_HERE, 78 this, enabled, group_name));
79 base::Bind(&PluginPrefs::EnablePluginGroup, this, enabled, group_name)); 79 }
80 return;
81 }
82 80
83 webkit::npapi::PluginList* plugin_list = GetPluginList(); 81 void PluginPrefs::EnablePluginGroupInternal(
84 std::vector<webkit::npapi::PluginGroup> groups; 82 bool enabled,
85 plugin_list->GetPluginGroups(true, &groups); 83 const string16& group_name,
86 84 const std::vector<webkit::npapi::PluginGroup>& groups) {
87 base::AutoLock auto_lock(lock_); 85 base::AutoLock auto_lock(lock_);
88 86
89 // Set the desired state for the group. 87 // Set the desired state for the group.
90 plugin_group_state_[group_name] = enabled; 88 plugin_group_state_[group_name] = enabled;
91 89
92 // Update the state for all plug-ins in the group. 90 // Update the state for all plug-ins in the group.
93 for (size_t i = 0; i < groups.size(); ++i) { 91 for (size_t i = 0; i < groups.size(); ++i) {
94 if (groups[i].GetGroupName() != group_name) 92 if (groups[i].GetGroupName() != group_name)
95 continue; 93 continue;
96 const std::vector<webkit::WebPluginInfo>& plugins = 94 const std::vector<webkit::WebPluginInfo>& plugins =
(...skipping 20 matching lines...) Expand all
117 PolicyStatus group_status = PolicyStatusForPlugin(group->GetGroupName()); 115 PolicyStatus group_status = PolicyStatusForPlugin(group->GetGroupName());
118 if (enabled) { 116 if (enabled) {
119 if (plugin_status == POLICY_DISABLED || group_status == POLICY_DISABLED) 117 if (plugin_status == POLICY_DISABLED || group_status == POLICY_DISABLED)
120 return false; 118 return false;
121 } else { 119 } else {
122 if (plugin_status == POLICY_ENABLED || group_status == POLICY_ENABLED) 120 if (plugin_status == POLICY_ENABLED || group_status == POLICY_ENABLED)
123 return false; 121 return false;
124 } 122 }
125 } 123 }
126 124
127 if (BrowserThread::CurrentlyOn(BrowserThread::FILE)) { 125 PluginService::GetInstance()->GetPluginGroups(
128 EnablePluginInternal(enabled, path); 126 base::Bind(&PluginPrefs::EnablePluginInternal, this, enabled, path));
129 } else {
130 BrowserThread::PostTask(
131 BrowserThread::FILE, FROM_HERE,
132 base::Bind(&PluginPrefs::EnablePluginInternal, this, enabled, path));
133 }
134 return true; 127 return true;
135 } 128 }
136 129
137 void PluginPrefs::EnablePluginInternal(bool enabled, const FilePath& path) { 130 void PluginPrefs::EnablePluginInternal(
138 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 131 bool enabled,
132 const FilePath& path,
133 const std::vector<webkit::npapi::PluginGroup>& groups) {
139 { 134 {
140 // Set the desired state for the plug-in. 135 // Set the desired state for the plug-in.
141 base::AutoLock auto_lock(lock_); 136 base::AutoLock auto_lock(lock_);
142 plugin_state_[path] = enabled; 137 plugin_state_[path] = enabled;
143 } 138 }
144 139
145 std::vector<webkit::npapi::PluginGroup> groups;
146 GetPluginList()->GetPluginGroups(true, &groups);
147
148 bool found_group = false; 140 bool found_group = false;
149 for (size_t i = 0; i < groups.size(); ++i) { 141 for (size_t i = 0; i < groups.size(); ++i) {
150 bool all_disabled = true; 142 bool all_disabled = true;
151 const std::vector<webkit::WebPluginInfo>& plugins = 143 const std::vector<webkit::WebPluginInfo>& plugins =
152 groups[i].web_plugin_infos(); 144 groups[i].web_plugin_infos();
153 for (size_t j = 0; j < plugins.size(); ++j) { 145 for (size_t j = 0; j < plugins.size(); ++j) {
154 all_disabled = all_disabled && !IsPluginEnabled(plugins[j]); 146 all_disabled = all_disabled && !IsPluginEnabled(plugins[j]);
155 if (plugins[j].path == path) { 147 if (plugins[j].path == path) {
156 found_group = true; 148 found_group = true;
157 DCHECK_EQ(enabled, IsPluginEnabled(plugins[j])); 149 DCHECK_EQ(enabled, IsPluginEnabled(plugins[j]));
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } 532 }
541 } 533 }
542 534
543 void PluginPrefs::NotifyPluginStatusChanged() { 535 void PluginPrefs::NotifyPluginStatusChanged() {
544 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 536 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
545 content::NotificationService::current()->Notify( 537 content::NotificationService::current()->Notify(
546 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED, 538 chrome::NOTIFICATION_PLUGIN_ENABLE_STATUS_CHANGED,
547 content::Source<Profile>(profile_), 539 content::Source<Profile>(profile_),
548 content::NotificationService::NoDetails()); 540 content::NotificationService::NoDetails());
549 } 541 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_prefs.h ('k') | chrome/browser/plugin_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698