| OLD | NEW |
| 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_exceptions_table_model.h" | 5 #include "chrome/browser/plugin_exceptions_table_model.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "chrome/browser/content_settings/content_settings_provider.h" |
| 11 #include "content/common/notification_service.h" | 12 #include "content/common/notification_service.h" |
| 12 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/base/models/table_model_observer.h" | 15 #include "ui/base/models/table_model_observer.h" |
| 15 | 16 |
| 16 PluginExceptionsTableModel::PluginExceptionsTableModel( | 17 PluginExceptionsTableModel::PluginExceptionsTableModel( |
| 17 HostContentSettingsMap* content_settings_map, | 18 HostContentSettingsMap* content_settings_map, |
| 18 HostContentSettingsMap* otr_content_settings_map) | 19 HostContentSettingsMap* otr_content_settings_map) |
| 19 : map_(content_settings_map), | 20 : map_(content_settings_map), |
| 20 otr_map_(otr_content_settings_map), | 21 otr_map_(otr_content_settings_map), |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 std::vector<webkit::npapi::PluginGroup>* plugin_groups) { | 142 std::vector<webkit::npapi::PluginGroup>* plugin_groups) { |
| 142 webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, plugin_groups); | 143 webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, plugin_groups); |
| 143 } | 144 } |
| 144 | 145 |
| 145 void PluginExceptionsTableModel::LoadSettings() { | 146 void PluginExceptionsTableModel::LoadSettings() { |
| 146 int group_id = 0; | 147 int group_id = 0; |
| 147 std::vector<webkit::npapi::PluginGroup> plugins; | 148 std::vector<webkit::npapi::PluginGroup> plugins; |
| 148 GetPlugins(&plugins); | 149 GetPlugins(&plugins); |
| 149 for (size_t i = 0; i < plugins.size(); ++i) { | 150 for (size_t i = 0; i < plugins.size(); ++i) { |
| 150 std::string plugin = plugins[i].identifier(); | 151 std::string plugin = plugins[i].identifier(); |
| 151 HostContentSettingsMap::SettingsForOneType settings; | 152 ContentSettingsForOneType settings; |
| 152 map_->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS, | 153 map_->GetSettingsForOneType( |
| 153 plugin, | 154 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 154 &settings); | 155 plugin, |
| 155 HostContentSettingsMap::SettingsForOneType otr_settings; | 156 content_settings::ProviderInterface::Rule::LexicographicalSort, |
| 157 &settings); |
| 158 ContentSettingsForOneType otr_settings; |
| 156 if (otr_map_) { | 159 if (otr_map_) { |
| 157 otr_map_->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS, | 160 otr_map_->GetSettingsForOneType( |
| 158 plugin, | 161 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 159 &otr_settings); | 162 plugin, |
| 163 content_settings::ProviderInterface::Rule::LexicographicalSort, |
| 164 &otr_settings); |
| 160 } | 165 } |
| 161 string16 title = plugins[i].GetGroupName(); | 166 string16 title = plugins[i].GetGroupName(); |
| 162 for (HostContentSettingsMap::SettingsForOneType::iterator setting_it = | 167 for (ContentSettingsForOneType::iterator setting_it = |
| 163 settings.begin(); | 168 settings.begin(); |
| 164 setting_it != settings.end(); ++setting_it) { | 169 setting_it != settings.end(); ++setting_it) { |
| 165 SettingsEntry entry = { | 170 SettingsEntry entry = { |
| 166 setting_it->a, | 171 setting_it->a, |
| 167 group_id, | 172 group_id, |
| 168 setting_it->c, | 173 setting_it->c, |
| 169 false | 174 false |
| 170 }; | 175 }; |
| 171 settings_.push_back(entry); | 176 settings_.push_back(entry); |
| 172 } | 177 } |
| 173 for (HostContentSettingsMap::SettingsForOneType::iterator setting_it = | 178 for (ContentSettingsForOneType::iterator setting_it = |
| 174 otr_settings.begin(); | 179 otr_settings.begin(); |
| 175 setting_it != otr_settings.end(); ++setting_it) { | 180 setting_it != otr_settings.end(); ++setting_it) { |
| 176 SettingsEntry entry = { | 181 SettingsEntry entry = { |
| 177 setting_it->a, | 182 setting_it->a, |
| 178 group_id, | 183 group_id, |
| 179 setting_it->c, | 184 setting_it->c, |
| 180 true | 185 true |
| 181 }; | 186 }; |
| 182 settings_.push_back(entry); | 187 settings_.push_back(entry); |
| 183 } | 188 } |
| 184 int num_plugins = settings.size() + otr_settings.size(); | 189 int num_plugins = settings.size() + otr_settings.size(); |
| 185 if (num_plugins > 0) { | 190 if (num_plugins > 0) { |
| 186 Group group = { title, group_id++ }; | 191 Group group = { title, group_id++ }; |
| 187 groups_.push_back(group); | 192 groups_.push_back(group); |
| 188 resources_.push_back(plugin); | 193 resources_.push_back(plugin); |
| 189 row_counts_.push_back(num_plugins); | 194 row_counts_.push_back(num_plugins); |
| 190 } | 195 } |
| 191 } | 196 } |
| 192 } | 197 } |
| 193 | 198 |
| 194 void PluginExceptionsTableModel::ReloadSettings() { | 199 void PluginExceptionsTableModel::ReloadSettings() { |
| 195 ClearSettings(); | 200 ClearSettings(); |
| 196 LoadSettings(); | 201 LoadSettings(); |
| 197 | 202 |
| 198 if (observer_) | 203 if (observer_) |
| 199 observer_->OnModelChanged(); | 204 observer_->OnModelChanged(); |
| 200 } | 205 } |
| OLD | NEW |