| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/table_model_observer.h" | 8 #include "app/table_model_observer.h" |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 // TODO(avi): remove when conversions not needed any more | |
| 11 #include "base/utf_string_conversions.h" | |
| 12 #include "chrome/common/content_settings.h" | 10 #include "chrome/common/content_settings.h" |
| 13 #include "chrome/common/content_settings_helper.h" | 11 #include "chrome/common/content_settings_helper.h" |
| 14 #include "chrome/common/content_settings_types.h" | 12 #include "chrome/common/content_settings_types.h" |
| 15 #include "chrome/common/notification_service.h" | 13 #include "chrome/common/notification_service.h" |
| 16 #include "chrome/common/notification_type.h" | 14 #include "chrome/common/notification_type.h" |
| 17 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 18 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 19 | 17 |
| 20 struct NotificationExceptionsTableModel::Entry { | 18 struct NotificationExceptionsTableModel::Entry { |
| 21 Entry(const GURL& origin, ContentSetting setting); | 19 Entry(const GURL& origin, ContentSetting setting); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 entries_.clear(); | 63 entries_.clear(); |
| 66 service_->ResetAllOrigins(); | 64 service_->ResetAllOrigins(); |
| 67 if (observer_) | 65 if (observer_) |
| 68 observer_->OnModelChanged(); | 66 observer_->OnModelChanged(); |
| 69 } | 67 } |
| 70 | 68 |
| 71 int NotificationExceptionsTableModel::RowCount() { | 69 int NotificationExceptionsTableModel::RowCount() { |
| 72 return static_cast<int>(entries_.size()); | 70 return static_cast<int>(entries_.size()); |
| 73 } | 71 } |
| 74 | 72 |
| 75 std::wstring NotificationExceptionsTableModel::GetText(int row, | 73 string16 NotificationExceptionsTableModel::GetText(int row, |
| 76 int column_id) { | 74 int column_id) { |
| 77 const Entry& entry = entries_[row]; | 75 const Entry& entry = entries_[row]; |
| 78 if (column_id == IDS_EXCEPTIONS_HOSTNAME_HEADER) { | 76 if (column_id == IDS_EXCEPTIONS_HOSTNAME_HEADER) { |
| 79 return content_settings_helper::OriginToWString(entry.origin); | 77 return content_settings_helper::OriginToString16(entry.origin); |
| 80 } | 78 } |
| 81 | 79 |
| 82 if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { | 80 if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { |
| 83 switch (entry.setting) { | 81 switch (entry.setting) { |
| 84 case CONTENT_SETTING_ALLOW: | 82 case CONTENT_SETTING_ALLOW: |
| 85 return UTF16ToWideHack( | 83 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON); |
| 86 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); | |
| 87 case CONTENT_SETTING_BLOCK: | 84 case CONTENT_SETTING_BLOCK: |
| 88 return UTF16ToWideHack( | 85 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON); |
| 89 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); | |
| 90 default: | 86 default: |
| 91 break; | 87 break; |
| 92 } | 88 } |
| 93 } | 89 } |
| 94 | 90 |
| 95 NOTREACHED(); | 91 NOTREACHED(); |
| 96 return std::wstring(); | 92 return string16(); |
| 97 } | 93 } |
| 98 | 94 |
| 99 void NotificationExceptionsTableModel::SetObserver( | 95 void NotificationExceptionsTableModel::SetObserver( |
| 100 TableModelObserver* observer) { | 96 TableModelObserver* observer) { |
| 101 observer_ = observer; | 97 observer_ = observer; |
| 102 } | 98 } |
| 103 | 99 |
| 104 void NotificationExceptionsTableModel::Observe( | 100 void NotificationExceptionsTableModel::Observe( |
| 105 NotificationType type, | 101 NotificationType type, |
| 106 const NotificationSource& source, | 102 const NotificationSource& source, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 131 ContentSetting in_setting) | 127 ContentSetting in_setting) |
| 132 : origin(in_origin), | 128 : origin(in_origin), |
| 133 setting(in_setting) { | 129 setting(in_setting) { |
| 134 } | 130 } |
| 135 | 131 |
| 136 bool NotificationExceptionsTableModel::Entry::operator<( | 132 bool NotificationExceptionsTableModel::Entry::operator<( |
| 137 const NotificationExceptionsTableModel::Entry& b) const { | 133 const NotificationExceptionsTableModel::Entry& b) const { |
| 138 DCHECK_NE(origin, b.origin); | 134 DCHECK_NE(origin, b.origin); |
| 139 return origin < b.origin; | 135 return origin < b.origin; |
| 140 } | 136 } |
| OLD | NEW |