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 "content/common/notification_service.h" | 11 #include "content/common/notification_service.h" |
11 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
13 #include "ui/base/models/table_model_observer.h" | 14 #include "ui/base/models/table_model_observer.h" |
14 | 15 |
15 PluginExceptionsTableModel::PluginExceptionsTableModel( | 16 PluginExceptionsTableModel::PluginExceptionsTableModel( |
16 HostContentSettingsMap* content_settings_map, | 17 HostContentSettingsMap* content_settings_map, |
17 HostContentSettingsMap* otr_content_settings_map) | 18 HostContentSettingsMap* otr_content_settings_map) |
18 : map_(content_settings_map), | 19 : map_(content_settings_map), |
19 otr_map_(otr_content_settings_map), | 20 otr_map_(otr_content_settings_map), |
20 updates_disabled_(false), | 21 updates_disabled_(false), |
21 observer_(NULL) { | 22 observer_(NULL) { |
22 registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, | 23 registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, |
23 Source<HostContentSettingsMap>(map_)); | 24 Source<HostContentSettingsMap>(map_)); |
24 if (otr_map_) { | 25 if (otr_map_) { |
25 registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, | 26 registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, |
26 Source<HostContentSettingsMap>(otr_map_)); | 27 Source<HostContentSettingsMap>(otr_map_)); |
27 } | 28 } |
28 } | 29 } |
29 | 30 |
30 PluginExceptionsTableModel::~PluginExceptionsTableModel() { | 31 PluginExceptionsTableModel::~PluginExceptionsTableModel() { |
31 } | 32 } |
32 | 33 |
33 bool PluginExceptionsTableModel::CanRemoveRows(const Rows& rows) const { | 34 bool PluginExceptionsTableModel::CanRemoveRows(const Rows& rows) const { |
34 return !rows.empty(); | 35 return !rows.empty(); |
35 } | 36 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 | 116 |
116 ui::TableModel::Groups PluginExceptionsTableModel::GetGroups() { | 117 ui::TableModel::Groups PluginExceptionsTableModel::GetGroups() { |
117 return groups_; | 118 return groups_; |
118 } | 119 } |
119 | 120 |
120 int PluginExceptionsTableModel::GetGroupID(int row) { | 121 int PluginExceptionsTableModel::GetGroupID(int row) { |
121 DCHECK_LT(row, static_cast<int>(settings_.size())); | 122 DCHECK_LT(row, static_cast<int>(settings_.size())); |
122 return settings_[row].plugin_id; | 123 return settings_[row].plugin_id; |
123 } | 124 } |
124 | 125 |
125 void PluginExceptionsTableModel::Observe(NotificationType type, | 126 void PluginExceptionsTableModel::Observe(int type, |
126 const NotificationSource& source, | 127 const NotificationSource& source, |
127 const NotificationDetails& details) { | 128 const NotificationDetails& details) { |
128 if (!updates_disabled_) | 129 if (!updates_disabled_) |
129 ReloadSettings(); | 130 ReloadSettings(); |
130 } | 131 } |
131 | 132 |
132 void PluginExceptionsTableModel::ClearSettings() { | 133 void PluginExceptionsTableModel::ClearSettings() { |
133 settings_.clear(); | 134 settings_.clear(); |
134 groups_.clear(); | 135 groups_.clear(); |
135 row_counts_.clear(); | 136 row_counts_.clear(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 191 } |
191 } | 192 } |
192 | 193 |
193 void PluginExceptionsTableModel::ReloadSettings() { | 194 void PluginExceptionsTableModel::ReloadSettings() { |
194 ClearSettings(); | 195 ClearSettings(); |
195 LoadSettings(); | 196 LoadSettings(); |
196 | 197 |
197 if (observer_) | 198 if (observer_) |
198 observer_->OnModelChanged(); | 199 observer_->OnModelChanged(); |
199 } | 200 } |
OLD | NEW |