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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "app/table_model.h" | 10 #include "app/table_model.h" |
11 #include "chrome/common/content_settings.h" | 11 #include "chrome/common/content_settings.h" |
12 #include "chrome/common/content_settings_types.h" | 12 #include "chrome/common/content_settings_types.h" |
13 #include "chrome/browser/host_content_settings_map.h" | 13 #include "chrome/browser/host_content_settings_map.h" |
14 | 14 |
15 class ContentExceptionsTableModel : public TableModel { | 15 class ContentExceptionsTableModel : public TableModel { |
16 public: | 16 public: |
17 ContentExceptionsTableModel(HostContentSettingsMap* map, | 17 ContentExceptionsTableModel(HostContentSettingsMap* map, |
| 18 HostContentSettingsMap* off_the_record_map, |
18 ContentSettingsType content_type); | 19 ContentSettingsType content_type); |
19 | 20 |
20 HostContentSettingsMap* map() const { return map_; } | 21 HostContentSettingsMap* map() const { return map_; } |
| 22 HostContentSettingsMap* off_the_record_map() const { |
| 23 return off_the_record_map_; |
| 24 } |
21 ContentSettingsType content_type() const { return content_type_; } | 25 ContentSettingsType content_type() const { return content_type_; } |
22 | 26 |
| 27 bool entry_is_off_the_record(int index) { |
| 28 return index >= static_cast<int>(entries_.size()); |
| 29 } |
| 30 |
23 const HostContentSettingsMap::PatternSettingPair& entry_at(int index) { | 31 const HostContentSettingsMap::PatternSettingPair& entry_at(int index) { |
24 return entries_[index]; | 32 return (entry_is_off_the_record(index) ? |
| 33 off_the_record_entries_[index - entries_.size()] : entries_[index]); |
25 } | 34 } |
26 | 35 |
27 // Adds a new exception on the map and table model. | 36 // Adds a new exception on the map and table model. |
28 void AddException(const HostContentSettingsMap::Pattern& pattern, | 37 void AddException(const HostContentSettingsMap::Pattern& pattern, |
29 ContentSetting setting); | 38 ContentSetting setting, |
| 39 bool is_off_the_record); |
30 | 40 |
31 // Removes the exception at the specified index from both the map and model. | 41 // Removes the exception at the specified index from both the map and model. |
32 void RemoveException(int row); | 42 void RemoveException(int row); |
33 | 43 |
34 // Removes all the exceptions from both the map and model. | 44 // Removes all the exceptions from both the map and model. |
35 void RemoveAll(); | 45 void RemoveAll(); |
36 | 46 |
37 // Returns the index of the specified exception given a host, or -1 if there | 47 // Returns the index of the specified exception given a host, or -1 if there |
38 // is no exception for the specified host. | 48 // is no exception for the specified host. |
39 int IndexOfExceptionByPattern(const HostContentSettingsMap::Pattern& pattern); | 49 int IndexOfExceptionByPattern(const HostContentSettingsMap::Pattern& pattern, |
| 50 bool is_off_the_record); |
40 | 51 |
41 // TableModel overrides: | 52 // TableModel overrides: |
42 virtual int RowCount(); | 53 virtual int RowCount(); |
43 virtual std::wstring GetText(int row, int column_id); | 54 virtual std::wstring GetText(int row, int column_id); |
44 virtual void SetObserver(TableModelObserver* observer); | 55 virtual void SetObserver(TableModelObserver* observer); |
45 | 56 |
46 private: | 57 private: |
| 58 HostContentSettingsMap* map(bool is_off_the_record) { |
| 59 return is_off_the_record ? off_the_record_map_ : map_; |
| 60 } |
| 61 HostContentSettingsMap::SettingsForOneType& entries(bool is_off_the_record) { |
| 62 return is_off_the_record ? off_the_record_entries_ : entries_; |
| 63 } |
| 64 |
47 HostContentSettingsMap* map_; | 65 HostContentSettingsMap* map_; |
| 66 HostContentSettingsMap* off_the_record_map_; |
48 ContentSettingsType content_type_; | 67 ContentSettingsType content_type_; |
49 HostContentSettingsMap::SettingsForOneType entries_; | 68 HostContentSettingsMap::SettingsForOneType entries_; |
| 69 HostContentSettingsMap::SettingsForOneType off_the_record_entries_; |
50 TableModelObserver* observer_; | 70 TableModelObserver* observer_; |
51 | 71 |
52 DISALLOW_COPY_AND_ASSIGN(ContentExceptionsTableModel); | 72 DISALLOW_COPY_AND_ASSIGN(ContentExceptionsTableModel); |
53 }; | 73 }; |
54 | 74 |
55 #endif // CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ | 75 #endif // CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ |
OLD | NEW |