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

Side by Side Diff: chrome/browser/geolocation/geolocation_exceptions_table_model.cc

Issue 6044007: Remove wstring from TableModel.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 12 months 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/geolocation/geolocation_exceptions_table_model.h" 5 #include "chrome/browser/geolocation/geolocation_exceptions_table_model.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/l10n_util_collator.h" 8 #include "app/l10n_util_collator.h"
9 #include "app/table_model_observer.h" 9 #include "app/table_model_observer.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 entries_.clear(); 131 entries_.clear();
132 map_->ResetToDefault(); 132 map_->ResetToDefault();
133 if (observer_) 133 if (observer_)
134 observer_->OnItemsRemoved(0, old_row_count); 134 observer_->OnItemsRemoved(0, old_row_count);
135 } 135 }
136 136
137 int GeolocationExceptionsTableModel::RowCount() { 137 int GeolocationExceptionsTableModel::RowCount() {
138 return entries_.size(); 138 return entries_.size();
139 } 139 }
140 140
141 std::wstring GeolocationExceptionsTableModel::GetText(int row, 141 string16 GeolocationExceptionsTableModel::GetText(int row,
142 int column_id) { 142 int column_id) {
143 const Entry& entry = entries_[row]; 143 const Entry& entry = entries_[row];
144 if (column_id == IDS_EXCEPTIONS_HOSTNAME_HEADER) { 144 if (column_id == IDS_EXCEPTIONS_HOSTNAME_HEADER) {
145 if (entry.origin == entry.embedding_origin) { 145 if (entry.origin == entry.embedding_origin) {
146 return content_settings_helper::OriginToWString(entry.origin); 146 return content_settings_helper::OriginToString16(entry.origin);
147 } 147 }
148 std::wstring indent(L" "); 148 string16 indent(ASCIIToUTF16(" "));
149 if (entry.embedding_origin.is_empty()) { 149 if (entry.embedding_origin.is_empty()) {
150 // NOTE: As long as the user cannot add/edit entries from the exceptions 150 // NOTE: As long as the user cannot add/edit entries from the exceptions
151 // dialog, it's impossible to actually have a non-default setting for some 151 // dialog, it's impossible to actually have a non-default setting for some
152 // origin "embedded on any other site", so this row will never appear. If 152 // origin "embedded on any other site", so this row will never appear. If
153 // we add the ability to add/edit exceptions, we'll need to decide when to 153 // we add the ability to add/edit exceptions, we'll need to decide when to
154 // display this and how "removing" it will function. 154 // display this and how "removing" it will function.
155 return indent + UTF16ToWideHack(l10n_util::GetStringUTF16( 155 return indent + l10n_util::GetStringUTF16(
156 IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ANY_OTHER)); 156 IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ANY_OTHER);
157 } 157 }
158 return indent + UTF16ToWideHack(l10n_util::GetStringFUTF16( 158 return indent + l10n_util::GetStringFUTF16(
159 IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST, 159 IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST,
160 WideToUTF16Hack( 160 content_settings_helper::OriginToString16(entry.embedding_origin));
161 content_settings_helper::OriginToWString(entry.embedding_origin))));
162 } 161 }
163 162
164 if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { 163 if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) {
165 switch (entry.setting) { 164 switch (entry.setting) {
166 case CONTENT_SETTING_ALLOW: 165 case CONTENT_SETTING_ALLOW:
167 return UTF16ToWideHack( 166 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON);
168 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON));
169 case CONTENT_SETTING_BLOCK: 167 case CONTENT_SETTING_BLOCK:
170 return UTF16ToWideHack( 168 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON);
171 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON));
172 case CONTENT_SETTING_ASK: 169 case CONTENT_SETTING_ASK:
173 return UTF16ToWideHack( 170 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON);
174 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON));
175 case CONTENT_SETTING_DEFAULT: 171 case CONTENT_SETTING_DEFAULT:
176 return UTF16ToWideHack( 172 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_NOT_SET_BUTTON);
177 l10n_util::GetStringUTF16(IDS_EXCEPTIONS_NOT_SET_BUTTON));
178 default: 173 default:
179 break; 174 break;
180 } 175 }
181 } 176 }
182 177
183 NOTREACHED(); 178 NOTREACHED();
184 return std::wstring(); 179 return string16();
185 } 180 }
186 181
187 void GeolocationExceptionsTableModel::SetObserver( 182 void GeolocationExceptionsTableModel::SetObserver(
188 TableModelObserver* observer) { 183 TableModelObserver* observer) {
189 observer_ = observer; 184 observer_ = observer;
190 } 185 }
191 186
192 int GeolocationExceptionsTableModel::CompareValues(int row1, 187 int GeolocationExceptionsTableModel::CompareValues(int row1,
193 int row2, 188 int row2,
194 int column_id) { 189 int column_id) {
(...skipping 26 matching lines...) Expand all
221 // origins will compare. 216 // origins will compare.
222 while (entries_[row1].origin != entries_[row1].embedding_origin) 217 while (entries_[row1].origin != entries_[row1].embedding_origin)
223 --row1; 218 --row1;
224 while (entries_[row2].origin != entries_[row2].embedding_origin) 219 while (entries_[row2].origin != entries_[row2].embedding_origin)
225 --row2; 220 --row2;
226 } 221 }
227 222
228 // The entries are at the same "scope". If we're sorting by action, then do 223 // The entries are at the same "scope". If we're sorting by action, then do
229 // that now. 224 // that now.
230 if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { 225 if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) {
231 int compare_text = l10n_util::CompareStringWithCollator( 226 int compare_text = l10n_util::CompareString16WithCollator(
232 GetCollator(), GetText(row1, column_id), GetText(row2, column_id)); 227 GetCollator(), GetText(row1, column_id), GetText(row2, column_id));
233 if (compare_text != 0) 228 if (compare_text != 0)
234 return compare_text; 229 return compare_text;
235 } 230 }
236 231
237 // Sort by the relevant origin. 232 // Sort by the relevant origin.
238 return origin_comparison; 233 return origin_comparison;
239 } 234 }
240 235
241 void GeolocationExceptionsTableModel::AddEntriesForOrigin( 236 void GeolocationExceptionsTableModel::AddEntriesForOrigin(
242 const GURL& origin, 237 const GURL& origin,
243 const GeolocationContentSettingsMap::OneOriginSettings& settings) { 238 const GeolocationContentSettingsMap::OneOriginSettings& settings) {
244 GeolocationContentSettingsMap::OneOriginSettings::const_iterator parent = 239 GeolocationContentSettingsMap::OneOriginSettings::const_iterator parent =
245 settings.find(origin); 240 settings.find(origin);
246 241
247 // Add the "parent" entry for the non-embedded setting. 242 // Add the "parent" entry for the non-embedded setting.
248 entries_.push_back(Entry(origin, origin, 243 entries_.push_back(Entry(origin, origin,
249 (parent == settings.end()) ? CONTENT_SETTING_DEFAULT : parent->second)); 244 (parent == settings.end()) ? CONTENT_SETTING_DEFAULT : parent->second));
250 245
251 // Add the "children" for any embedded settings. 246 // Add the "children" for any embedded settings.
252 GeolocationContentSettingsMap::OneOriginSettings::const_iterator i; 247 GeolocationContentSettingsMap::OneOriginSettings::const_iterator i;
253 for (i = settings.begin(); i != settings.end(); ++i) { 248 for (i = settings.begin(); i != settings.end(); ++i) {
254 // Skip the non-embedded setting which we already added above. 249 // Skip the non-embedded setting which we already added above.
255 if (i == parent) 250 if (i == parent)
256 continue; 251 continue;
257 252
258 entries_.push_back(Entry(origin, i->first, i->second)); 253 entries_.push_back(Entry(origin, i->first, i->second));
259 } 254 }
260 } 255 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698