| 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/content_exceptions_table_model.h" | 5 #include "chrome/browser/content_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/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/host_content_settings_map.h" | 10 #include "chrome/browser/host_content_settings_map.h" |
| 11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 12 | 12 |
| 13 ContentExceptionsTableModel::ContentExceptionsTableModel( | 13 ContentExceptionsTableModel::ContentExceptionsTableModel( |
| 14 HostContentSettingsMap* map, | 14 HostContentSettingsMap* map, |
| 15 ContentSettingsType type) | 15 ContentSettingsType type) |
| 16 : map_(map), | 16 : map_(map), |
| 17 content_type_(type), | 17 content_type_(type), |
| 18 observer_(NULL) { | 18 observer_(NULL) { |
| 19 registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED, |
| 20 NotificationService::AllSources()); |
| 21 |
| 19 // Load the contents. | 22 // Load the contents. |
| 20 map->GetSettingsForOneType(type, &entries_); | 23 map->GetSettingsForOneType(type, &entries_); |
| 21 } | 24 } |
| 22 | 25 |
| 23 void ContentExceptionsTableModel::AddException(const std::string& host, | 26 void ContentExceptionsTableModel::AddException(const std::string& host, |
| 24 ContentSetting setting) { | 27 ContentSetting setting) { |
| 25 entries_.push_back(HostContentSettingsMap::HostSettingPair(host, setting)); | 28 entries_.push_back(HostContentSettingsMap::HostSettingPair(host, setting)); |
| 26 map_->SetContentSetting(host, content_type_, setting); | 29 map_->SetContentSetting(host, content_type_, setting); |
| 27 if (observer_) | 30 if (observer_) |
| 28 observer_->OnItemsAdded(RowCount() - 1, 1); | 31 observer_->OnItemsAdded(RowCount() - 1, 1); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 default: | 85 default: |
| 83 NOTREACHED(); | 86 NOTREACHED(); |
| 84 } | 87 } |
| 85 | 88 |
| 86 return std::wstring(); | 89 return std::wstring(); |
| 87 } | 90 } |
| 88 | 91 |
| 89 void ContentExceptionsTableModel::SetObserver(TableModelObserver* observer) { | 92 void ContentExceptionsTableModel::SetObserver(TableModelObserver* observer) { |
| 90 observer_ = observer; | 93 observer_ = observer; |
| 91 } | 94 } |
| 95 |
| 96 void ContentExceptionsTableModel::Observe( |
| 97 NotificationType type, |
| 98 const NotificationSource& source, |
| 99 const NotificationDetails& details) { |
| 100 // XXX: check the notification is for the right type |
| 101 fprintf(stderr, "observing\n"); |
| 102 // Reload the contents. |
| 103 map_->GetSettingsForOneType(content_type_, &entries_); |
| 104 |
| 105 if (observer_) { |
| 106 fprintf(stderr, "notifying\n"); |
| 107 observer_->OnModelChanged(); |
| 108 } |
| 109 } |
| OLD | NEW |