Chromium Code Reviews

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

Issue 5516004: Clean up PluginGroup and related code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | 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_exceptions_table_model.h" 5 #include "chrome/browser/plugin_exceptions_table_model.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/table_model_observer.h" 8 #include "app/table_model_observer.h"
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 111 matching lines...)
122 ReloadSettings(); 122 ReloadSettings();
123 } 123 }
124 124
125 void PluginExceptionsTableModel::ClearSettings() { 125 void PluginExceptionsTableModel::ClearSettings() {
126 settings_.clear(); 126 settings_.clear();
127 groups_.clear(); 127 groups_.clear();
128 row_counts_.clear(); 128 row_counts_.clear();
129 resources_.clear(); 129 resources_.clear();
130 } 130 }
131 131
132 void PluginExceptionsTableModel::GetPlugins( 132 std::vector<PluginGroup> PluginExceptionsTableModel::GetPlugins() {
133 NPAPI::PluginList::PluginMap* plugins) { 133 return NPAPI::PluginList::Singleton()->GetPluginGroups(false);
134 NPAPI::PluginList::Singleton()->GetPluginGroups(false, plugins);
135 } 134 }
136 135
137 void PluginExceptionsTableModel::LoadSettings() { 136 void PluginExceptionsTableModel::LoadSettings() {
138 int group_id = 0; 137 int group_id = 0;
139 NPAPI::PluginList::PluginMap plugins; 138 std::vector<PluginGroup> plugins(GetPlugins());
Bernhard Bauer 2010/12/03 16:13:28 Are we sure that the compiler optimizes any unnece
Jakob Kummerow 2010/12/06 18:21:12 Done. (Changed the interface.)
140 GetPlugins(&plugins); 139 for (size_t i = 0; i < plugins.size(); ++i) {
141 for (NPAPI::PluginList::PluginMap::iterator it = plugins.begin(); 140 std::string plugin = plugins[i].identifier();
142 it != plugins.end(); ++it) {
143 std::string plugin = it->first;
144 HostContentSettingsMap::SettingsForOneType settings; 141 HostContentSettingsMap::SettingsForOneType settings;
145 map_->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS, 142 map_->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS,
146 plugin, 143 plugin,
147 &settings); 144 &settings);
148 HostContentSettingsMap::SettingsForOneType otr_settings; 145 HostContentSettingsMap::SettingsForOneType otr_settings;
149 if (otr_map_) { 146 if (otr_map_) {
150 otr_map_->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS, 147 otr_map_->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS,
151 plugin, 148 plugin,
152 &otr_settings); 149 &otr_settings);
153 } 150 }
154 std::wstring title = UTF16ToWide(it->second->GetGroupName()); 151 std::wstring title = UTF16ToWide(plugins[i].GetGroupName());
155 for (HostContentSettingsMap::SettingsForOneType::iterator setting_it = 152 for (HostContentSettingsMap::SettingsForOneType::iterator setting_it =
156 settings.begin(); setting_it != settings.end(); ++setting_it) { 153 settings.begin(); setting_it != settings.end(); ++setting_it) {
157 SettingsEntry entry = { 154 SettingsEntry entry = {
158 setting_it->first, 155 setting_it->first,
159 group_id, 156 group_id,
160 setting_it->second, 157 setting_it->second,
161 false 158 false
162 }; 159 };
163 settings_.push_back(entry); 160 settings_.push_back(entry);
164 } 161 }
(...skipping 19 matching lines...)
184 } 181 }
185 182
186 void PluginExceptionsTableModel::ReloadSettings() { 183 void PluginExceptionsTableModel::ReloadSettings() {
187 ClearSettings(); 184 ClearSettings();
188 LoadSettings(); 185 LoadSettings();
189 186
190 if (observer_) 187 if (observer_)
191 observer_->OnModelChanged(); 188 observer_->OnModelChanged();
192 } 189 }
193 190
OLDNEW

Powered by Google App Engine