diff options
author | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-31 13:19:12 +0000 |
---|---|---|
committer | markusheintz@chromium.org <markusheintz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-31 13:19:12 +0000 |
commit | e190daff7a901701211b34cd92796cf21aca76e2 (patch) | |
tree | dc51c4909e8fdcde8a4d891d56ac5015a31f94b2 /chrome/browser/notifications/notification_exceptions_table_model.cc | |
parent | b64c0d95e3f8bad04c44bb0ee14529c9060a3e66 (diff) | |
download | chromium_src-e190daff7a901701211b34cd92796cf21aca76e2.zip chromium_src-e190daff7a901701211b34cd92796cf21aca76e2.tar.gz chromium_src-e190daff7a901701211b34cd92796cf21aca76e2.tar.bz2 |
Migrate Obsolete NotificationsSettings and remove content_settings::NotificationsProvider.
BUG=63656
TEST=host_content_settings_map_unittest.cc,
content_settings_pref_provider.cc,
desktop_notifications_service_unittest.cc
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=98938
Review URL: http://codereview.chromium.org/7655019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications/notification_exceptions_table_model.cc')
-rw-r--r-- | chrome/browser/notifications/notification_exceptions_table_model.cc | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/chrome/browser/notifications/notification_exceptions_table_model.cc b/chrome/browser/notifications/notification_exceptions_table_model.cc index 71ff312..943672b 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(); } |