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

Side by Side Diff: chrome/browser/content_exceptions_table_model.cc

Issue 5574001: Move ContentSettingsDetails and Pattern out of HostContentSettingsMap as separate classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/browser/content_settings
Patch Set: updates Created 10 years 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) 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/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
(...skipping 12 matching lines...) Expand all
23 if (off_the_record_map) { 23 if (off_the_record_map) {
24 off_the_record_map->GetSettingsForOneType(type, 24 off_the_record_map->GetSettingsForOneType(type,
25 "", 25 "",
26 &off_the_record_entries_); 26 &off_the_record_entries_);
27 } 27 }
28 } 28 }
29 29
30 ContentExceptionsTableModel::~ContentExceptionsTableModel() {} 30 ContentExceptionsTableModel::~ContentExceptionsTableModel() {}
31 31
32 void ContentExceptionsTableModel::AddException( 32 void ContentExceptionsTableModel::AddException(
33 const HostContentSettingsMap::Pattern& original_pattern, 33 const ContentSettingsPattern& original_pattern,
34 ContentSetting setting, 34 ContentSetting setting,
35 bool is_off_the_record) { 35 bool is_off_the_record) {
36 DCHECK(!is_off_the_record || off_the_record_map_); 36 DCHECK(!is_off_the_record || off_the_record_map_);
37 37
38 int insert_position = 38 int insert_position =
39 is_off_the_record ? RowCount() : static_cast<int>(entries_.size()); 39 is_off_the_record ? RowCount() : static_cast<int>(entries_.size());
40 40
41 const HostContentSettingsMap::Pattern pattern( 41 const ContentSettingsPattern pattern(
42 original_pattern.CanonicalizePattern()); 42 original_pattern.CanonicalizePattern());
43 43
44 entries(is_off_the_record).push_back( 44 entries(is_off_the_record).push_back(
45 HostContentSettingsMap::PatternSettingPair(pattern, setting)); 45 HostContentSettingsMap::PatternSettingPair(pattern, setting));
46 map(is_off_the_record)->SetContentSetting(pattern, 46 map(is_off_the_record)->SetContentSetting(pattern,
47 content_type_, 47 content_type_,
48 "", 48 "",
49 setting); 49 setting);
50 if (observer_) 50 if (observer_)
51 observer_->OnItemsAdded(insert_position, 1); 51 observer_->OnItemsAdded(insert_position, 1);
(...skipping 18 matching lines...) Expand all
70 entries_.clear(); 70 entries_.clear();
71 off_the_record_entries_.clear(); 71 off_the_record_entries_.clear();
72 map_->ClearSettingsForOneType(content_type_); 72 map_->ClearSettingsForOneType(content_type_);
73 if (off_the_record_map_) 73 if (off_the_record_map_)
74 off_the_record_map_->ClearSettingsForOneType(content_type_); 74 off_the_record_map_->ClearSettingsForOneType(content_type_);
75 if (observer_) 75 if (observer_)
76 observer_->OnItemsRemoved(0, old_row_count); 76 observer_->OnItemsRemoved(0, old_row_count);
77 } 77 }
78 78
79 int ContentExceptionsTableModel::IndexOfExceptionByPattern( 79 int ContentExceptionsTableModel::IndexOfExceptionByPattern(
80 const HostContentSettingsMap::Pattern& original_pattern, 80 const ContentSettingsPattern& original_pattern,
81 bool is_off_the_record) { 81 bool is_off_the_record) {
82 DCHECK(!is_off_the_record || off_the_record_map_); 82 DCHECK(!is_off_the_record || off_the_record_map_);
83 83
84 int offset = 84 int offset =
85 is_off_the_record ? static_cast<int>(entries_.size()) : 0; 85 is_off_the_record ? static_cast<int>(entries_.size()) : 0;
86 86
87 const HostContentSettingsMap::Pattern pattern( 87 const ContentSettingsPattern pattern(
88 original_pattern.CanonicalizePattern()); 88 original_pattern.CanonicalizePattern());
89 89
90 // This is called on every key type in the editor. Move to a map if we end up 90 // This is called on every key type in the editor. Move to a map if we end up
91 // with lots of exceptions. 91 // with lots of exceptions.
92 for (size_t i = 0; i < entries(is_off_the_record).size(); ++i) { 92 for (size_t i = 0; i < entries(is_off_the_record).size(); ++i) {
93 if (entries(is_off_the_record)[i].first == pattern) 93 if (entries(is_off_the_record)[i].first == pattern)
94 return offset + static_cast<int>(i); 94 return offset + static_cast<int>(i);
95 } 95 }
96 return -1; 96 return -1;
97 } 97 }
(...skipping 27 matching lines...) Expand all
125 default: 125 default:
126 NOTREACHED(); 126 NOTREACHED();
127 } 127 }
128 128
129 return std::wstring(); 129 return std::wstring();
130 } 130 }
131 131
132 void ContentExceptionsTableModel::SetObserver(TableModelObserver* observer) { 132 void ContentExceptionsTableModel::SetObserver(TableModelObserver* observer) {
133 observer_ = observer; 133 observer_ = observer;
134 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698