| 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 #ifndef CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ |
| 6 #define CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ | 6 #define CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 bool entry_is_off_the_record(int index) { | 30 bool entry_is_off_the_record(int index) { |
| 31 return index >= static_cast<int>(entries_.size()); | 31 return index >= static_cast<int>(entries_.size()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 const HostContentSettingsMap::PatternSettingPair& entry_at(int index) { | 34 const HostContentSettingsMap::PatternSettingPair& entry_at(int index) { |
| 35 return (entry_is_off_the_record(index) ? | 35 return (entry_is_off_the_record(index) ? |
| 36 off_the_record_entries_[index - entries_.size()] : entries_[index]); | 36 off_the_record_entries_[index - entries_.size()] : entries_[index]); |
| 37 } | 37 } |
| 38 | 38 |
| 39 // Adds a new exception on the map and table model. | 39 // Adds a new exception on the map and table model. |
| 40 void AddException(const HostContentSettingsMap::Pattern& pattern, | 40 void AddException(const ContentSettingsPattern& pattern, |
| 41 ContentSetting setting, | 41 ContentSetting setting, |
| 42 bool is_off_the_record); | 42 bool is_off_the_record); |
| 43 | 43 |
| 44 // Removes the exception at the specified index from both the map and model. | 44 // Removes the exception at the specified index from both the map and model. |
| 45 void RemoveException(int row); | 45 void RemoveException(int row); |
| 46 | 46 |
| 47 // Removes all the exceptions from both the map and model. | 47 // Removes all the exceptions from both the map and model. |
| 48 void RemoveAll(); | 48 void RemoveAll(); |
| 49 | 49 |
| 50 // Returns the index of the specified exception given a host, or -1 if there | 50 // Returns the index of the specified exception given a host, or -1 if there |
| 51 // is no exception for the specified host. | 51 // is no exception for the specified host. |
| 52 int IndexOfExceptionByPattern(const HostContentSettingsMap::Pattern& pattern, | 52 int IndexOfExceptionByPattern(const ContentSettingsPattern& pattern, |
| 53 bool is_off_the_record); | 53 bool is_off_the_record); |
| 54 | 54 |
| 55 // TableModel overrides: | 55 // TableModel overrides: |
| 56 virtual int RowCount(); | 56 virtual int RowCount(); |
| 57 virtual std::wstring GetText(int row, int column_id); | 57 virtual std::wstring GetText(int row, int column_id); |
| 58 virtual void SetObserver(TableModelObserver* observer); | 58 virtual void SetObserver(TableModelObserver* observer); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 HostContentSettingsMap* map(bool is_off_the_record) { | 61 HostContentSettingsMap* map(bool is_off_the_record) { |
| 62 return is_off_the_record ? off_the_record_map_ : map_; | 62 return is_off_the_record ? off_the_record_map_ : map_; |
| 63 } | 63 } |
| 64 HostContentSettingsMap::SettingsForOneType& entries(bool is_off_the_record) { | 64 HostContentSettingsMap::SettingsForOneType& entries(bool is_off_the_record) { |
| 65 return is_off_the_record ? off_the_record_entries_ : entries_; | 65 return is_off_the_record ? off_the_record_entries_ : entries_; |
| 66 } | 66 } |
| 67 | 67 |
| 68 scoped_refptr<HostContentSettingsMap> map_; | 68 scoped_refptr<HostContentSettingsMap> map_; |
| 69 scoped_refptr<HostContentSettingsMap> off_the_record_map_; | 69 scoped_refptr<HostContentSettingsMap> off_the_record_map_; |
| 70 ContentSettingsType content_type_; | 70 ContentSettingsType content_type_; |
| 71 HostContentSettingsMap::SettingsForOneType entries_; | 71 HostContentSettingsMap::SettingsForOneType entries_; |
| 72 HostContentSettingsMap::SettingsForOneType off_the_record_entries_; | 72 HostContentSettingsMap::SettingsForOneType off_the_record_entries_; |
| 73 TableModelObserver* observer_; | 73 TableModelObserver* observer_; |
| 74 | 74 |
| 75 DISALLOW_COPY_AND_ASSIGN(ContentExceptionsTableModel); | 75 DISALLOW_COPY_AND_ASSIGN(ContentExceptionsTableModel); |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 #endif // CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ | 78 #endif // CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ |
| OLD | NEW |