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

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

Issue 7810017: Revert 98938 - Migrate Obsolete NotificationsSettings and remove content_settings::NotificationsP... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
===================================================================
--- 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;
}

Powered by Google App Engine
This is Rietveld 408576698