Index: chrome/browser/notifications/notification_exceptions_table_model.cc |
=================================================================== |
--- chrome/browser/notifications/notification_exceptions_table_model.cc (revision 98940) |
+++ chrome/browser/notifications/notification_exceptions_table_model.cc (working copy) |
@@ -4,15 +4,10 @@ |
#include "chrome/browser/notifications/notification_exceptions_table_model.h" |
-#include <algorithm> |
-#include <string> |
- |
#include "base/auto_reset.h" |
-#include "base/utf_string_conversions.h" |
-#include "chrome/browser/content_settings/content_settings_pattern.h" |
-#include "chrome/browser/content_settings/host_content_settings_map.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/content_settings.h" |
+#include "chrome/common/content_settings_helper.h" |
#include "chrome/common/content_settings_types.h" |
#include "chrome/common/url_constants.h" |
#include "content/common/notification_service.h" |
@@ -21,10 +16,10 @@ |
#include "ui/base/models/table_model_observer.h" |
struct NotificationExceptionsTableModel::Entry { |
- Entry(const ContentSettingsPattern& origin, ContentSetting setting); |
+ Entry(const GURL& origin, ContentSetting setting); |
bool operator<(const Entry& b) const; |
- ContentSettingsPattern origin; |
+ GURL origin; |
ContentSetting setting; |
}; |
@@ -52,9 +47,12 @@ |
for (Rows::const_reverse_iterator i(rows.rbegin()); i != rows.rend(); ++i) { |
size_t row = *i; |
Entry* entry = &entries_[row]; |
- DCHECK(entry->setting == CONTENT_SETTING_ALLOW || |
- entry->setting == CONTENT_SETTING_BLOCK); |
- service_->ClearSetting(entry->origin); |
+ if (entry->setting == CONTENT_SETTING_ALLOW) { |
+ service_->ResetAllowedOrigin(entry->origin); |
+ } else { |
+ DCHECK_EQ(entry->setting, CONTENT_SETTING_BLOCK); |
+ service_->ResetBlockedOrigin(entry->origin); |
+ } |
entries_.erase(entries_.begin() + row); // Note: |entry| is now garbage. |
if (observer_) |
observer_->OnItemsRemoved(row, 1); |
@@ -77,7 +75,7 @@ |
int column_id) { |
const Entry& entry = entries_[row]; |
if (column_id == IDS_EXCEPTIONS_HOSTNAME_HEADER) { |
- return UTF8ToUTF16(entry.origin.ToString()); |
+ return content_settings_helper::OriginToString16(entry.origin); |
} |
if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { |
@@ -116,22 +114,18 @@ |
} |
void NotificationExceptionsTableModel::LoadEntries() { |
- HostContentSettingsMap::SettingsForOneType settings; |
- service_->GetNotificationsSettings(&settings); |
- |
- entries_.reserve(settings.size()); |
- for (HostContentSettingsMap::SettingsForOneType::const_iterator i = |
- settings.begin(); |
- i != settings.end(); |
- ++i) { |
- const HostContentSettingsMap::PatternSettingSourceTuple& tuple(*i); |
- entries_.push_back(Entry(tuple.a, tuple.c)); |
- } |
+ std::vector<GURL> allowed(service_->GetAllowedOrigins()); |
+ std::vector<GURL> blocked(service_->GetBlockedOrigins()); |
+ entries_.reserve(allowed.size() + blocked.size()); |
+ for (size_t i = 0; i < allowed.size(); ++i) |
+ entries_.push_back(Entry(allowed[i], CONTENT_SETTING_ALLOW)); |
+ for (size_t i = 0; i < blocked.size(); ++i) |
+ entries_.push_back(Entry(blocked[i], CONTENT_SETTING_BLOCK)); |
std::sort(entries_.begin(), entries_.end()); |
} |
NotificationExceptionsTableModel::Entry::Entry( |
- const ContentSettingsPattern& in_origin, |
+ const GURL& in_origin, |
ContentSetting in_setting) |
: origin(in_origin), |
setting(in_setting) { |
@@ -140,5 +134,5 @@ |
bool NotificationExceptionsTableModel::Entry::operator<( |
const NotificationExceptionsTableModel::Entry& b) const { |
DCHECK_NE(origin, b.origin); |
- return origin.ToString() < b.origin.ToString(); |
+ return origin < b.origin; |
} |