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

Side by Side Diff: chrome/browser/notifications/notification_exceptions_table_model.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/notifications/notification_exceptions_table_model.h" 5 #include "chrome/browser/notifications/notification_exceptions_table_model.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "chrome/common/chrome_notification_types.h"
8 #include "chrome/common/content_settings.h" 9 #include "chrome/common/content_settings.h"
9 #include "chrome/common/content_settings_helper.h" 10 #include "chrome/common/content_settings_helper.h"
10 #include "chrome/common/content_settings_types.h" 11 #include "chrome/common/content_settings_types.h"
11 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
12 #include "content/common/notification_service.h" 13 #include "content/common/notification_service.h"
13 #include "content/common/notification_type.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/models/table_model_observer.h" 16 #include "ui/base/models/table_model_observer.h"
17 17
18 struct NotificationExceptionsTableModel::Entry { 18 struct NotificationExceptionsTableModel::Entry {
19 Entry(const GURL& origin, ContentSetting setting); 19 Entry(const GURL& origin, ContentSetting setting);
20 bool operator<(const Entry& b) const; 20 bool operator<(const Entry& b) const;
21 21
22 GURL origin; 22 GURL origin;
23 ContentSetting setting; 23 ContentSetting setting;
24 }; 24 };
25 25
26 NotificationExceptionsTableModel::NotificationExceptionsTableModel( 26 NotificationExceptionsTableModel::NotificationExceptionsTableModel(
27 DesktopNotificationService* service) 27 DesktopNotificationService* service)
28 : service_(service), 28 : service_(service),
29 updates_disabled_(false), 29 updates_disabled_(false),
30 observer_(NULL) { 30 observer_(NULL) {
31 registrar_.Add(this, NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED, 31 registrar_.Add(this,
32 chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED,
32 NotificationService::AllSources()); 33 NotificationService::AllSources());
33 LoadEntries(); 34 LoadEntries();
34 } 35 }
35 36
36 NotificationExceptionsTableModel::~NotificationExceptionsTableModel() {} 37 NotificationExceptionsTableModel::~NotificationExceptionsTableModel() {}
37 38
38 bool NotificationExceptionsTableModel::CanRemoveRows( 39 bool NotificationExceptionsTableModel::CanRemoveRows(
39 const Rows& rows) const { 40 const Rows& rows) const {
40 return !rows.empty(); 41 return !rows.empty();
41 } 42 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 NOTREACHED(); 92 NOTREACHED();
92 return string16(); 93 return string16();
93 } 94 }
94 95
95 void NotificationExceptionsTableModel::SetObserver( 96 void NotificationExceptionsTableModel::SetObserver(
96 ui::TableModelObserver* observer) { 97 ui::TableModelObserver* observer) {
97 observer_ = observer; 98 observer_ = observer;
98 } 99 }
99 100
100 void NotificationExceptionsTableModel::Observe( 101 void NotificationExceptionsTableModel::Observe(
101 NotificationType type, 102 int type,
102 const NotificationSource& source, 103 const NotificationSource& source,
103 const NotificationDetails& details) { 104 const NotificationDetails& details) {
104 if (!updates_disabled_) { 105 if (!updates_disabled_) {
105 DCHECK(type == NotificationType::DESKTOP_NOTIFICATION_SETTINGS_CHANGED); 106 DCHECK(type == chrome::NOTIFICATION_DESKTOP_NOTIFICATION_SETTINGS_CHANGED);
106 entries_.clear(); 107 entries_.clear();
107 LoadEntries(); 108 LoadEntries();
108 109
109 if (observer_) 110 if (observer_)
110 observer_->OnModelChanged(); 111 observer_->OnModelChanged();
111 } 112 }
112 } 113 }
113 114
114 void NotificationExceptionsTableModel::LoadEntries() { 115 void NotificationExceptionsTableModel::LoadEntries() {
115 std::vector<GURL> allowed(service_->GetAllowedOrigins()); 116 std::vector<GURL> allowed(service_->GetAllowedOrigins());
(...skipping 11 matching lines...) Expand all
127 ContentSetting in_setting) 128 ContentSetting in_setting)
128 : origin(in_origin), 129 : origin(in_origin),
129 setting(in_setting) { 130 setting(in_setting) {
130 } 131 }
131 132
132 bool NotificationExceptionsTableModel::Entry::operator<( 133 bool NotificationExceptionsTableModel::Entry::operator<(
133 const NotificationExceptionsTableModel::Entry& b) const { 134 const NotificationExceptionsTableModel::Entry& b) const {
134 DCHECK_NE(origin, b.origin); 135 DCHECK_NE(origin, b.origin);
135 return origin < b.origin; 136 return origin < b.origin;
136 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698