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

Unified Diff: chrome/browser/notifications/notification_exceptions_table_model.cc

Issue 7655019: Migrate Obsolete NotificationsSettings and remove content_settings::NotificationsProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove include of deleted notifications_prefs_cache.h Created 9 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/notification_exceptions_table_model.cc
diff --git a/chrome/browser/notifications/notification_exceptions_table_model.cc b/chrome/browser/notifications/notification_exceptions_table_model.cc
index 71ff312f7bf6c1779ee2b0571475282327c8de49..943672bbeb7fba3f40c1fffd38029bb014acee20 100644
--- a/chrome/browser/notifications/notification_exceptions_table_model.cc
+++ b/chrome/browser/notifications/notification_exceptions_table_model.cc
@@ -4,10 +4,15 @@
#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"
@@ -16,10 +21,10 @@
#include "ui/base/models/table_model_observer.h"
struct NotificationExceptionsTableModel::Entry {
- Entry(const GURL& origin, ContentSetting setting);
+ Entry(const ContentSettingsPattern& origin, ContentSetting setting);
bool operator<(const Entry& b) const;
- GURL origin;
+ ContentSettingsPattern origin;
ContentSetting setting;
};
@@ -47,12 +52,9 @@ void NotificationExceptionsTableModel::RemoveRows(const Rows& rows) {
for (Rows::const_reverse_iterator i(rows.rbegin()); i != rows.rend(); ++i) {
size_t row = *i;
Entry* entry = &entries_[row];
- if (entry->setting == CONTENT_SETTING_ALLOW) {
- service_->ResetAllowedOrigin(entry->origin);
- } else {
- DCHECK_EQ(entry->setting, CONTENT_SETTING_BLOCK);
- service_->ResetBlockedOrigin(entry->origin);
- }
+ DCHECK(entry->setting == CONTENT_SETTING_ALLOW ||
+ entry->setting == CONTENT_SETTING_BLOCK);
+ service_->ClearSetting(entry->origin);
entries_.erase(entries_.begin() + row); // Note: |entry| is now garbage.
if (observer_)
observer_->OnItemsRemoved(row, 1);
@@ -75,7 +77,7 @@ string16 NotificationExceptionsTableModel::GetText(int row,
int column_id) {
const Entry& entry = entries_[row];
if (column_id == IDS_EXCEPTIONS_HOSTNAME_HEADER) {
- return content_settings_helper::OriginToString16(entry.origin);
+ return UTF8ToUTF16(entry.origin.ToString());
}
if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) {
@@ -114,18 +116,22 @@ void NotificationExceptionsTableModel::Observe(
}
void NotificationExceptionsTableModel::LoadEntries() {
- 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));
+ 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::sort(entries_.begin(), entries_.end());
}
NotificationExceptionsTableModel::Entry::Entry(
- const GURL& in_origin,
+ const ContentSettingsPattern& in_origin,
ContentSetting in_setting)
: origin(in_origin),
setting(in_setting) {
@@ -134,5 +140,5 @@ NotificationExceptionsTableModel::Entry::Entry(
bool NotificationExceptionsTableModel::Entry::operator<(
const NotificationExceptionsTableModel::Entry& b) const {
DCHECK_NE(origin, b.origin);
- return origin < b.origin;
+ return origin.ToString() < b.origin.ToString();
}

Powered by Google App Engine
This is Rietveld 408576698