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

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

Issue 2838037: Introduce RemoveRowTableModel interface, let GeolocationExceptionsTableModel derive from it. (Closed)
Patch Set: '' Created 10 years, 5 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
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 GeolocationContentSettingsMap* map) 50 GeolocationContentSettingsMap* map)
51 : map_(map), 51 : map_(map),
52 observer_(NULL) { 52 observer_(NULL) {
53 GeolocationContentSettingsMap::AllOriginsSettings settings( 53 GeolocationContentSettingsMap::AllOriginsSettings settings(
54 map_->GetAllOriginsSettings()); 54 map_->GetAllOriginsSettings());
55 GeolocationContentSettingsMap::AllOriginsSettings::const_iterator i; 55 GeolocationContentSettingsMap::AllOriginsSettings::const_iterator i;
56 for (i = settings.begin(); i != settings.end(); ++i) 56 for (i = settings.begin(); i != settings.end(); ++i)
57 AddEntriesForOrigin(i->first, i->second); 57 AddEntriesForOrigin(i->first, i->second);
58 } 58 }
59 59
60 bool GeolocationExceptionsTableModel::CanRemoveExceptions( 60 bool GeolocationExceptionsTableModel::CanRemoveRows(
61 const Rows& rows) const { 61 const Rows& rows) const {
62 for (Rows::const_iterator i(rows.begin()); i != rows.end(); ++i) { 62 for (Rows::const_iterator i(rows.begin()); i != rows.end(); ++i) {
63 const Entry& entry = entries_[*i]; 63 const Entry& entry = entries_[*i];
64 if ((entry.origin == entry.embedding_origin) && 64 if ((entry.origin == entry.embedding_origin) &&
65 (entry.setting == CONTENT_SETTING_DEFAULT)) { 65 (entry.setting == CONTENT_SETTING_DEFAULT)) {
66 for (size_t j = (*i) + 1; 66 for (size_t j = (*i) + 1;
67 (j < entries_.size()) && (entries_[j].origin == entry.origin); ++j) { 67 (j < entries_.size()) && (entries_[j].origin == entry.origin); ++j) {
68 if (!rows.count(j)) 68 if (!rows.count(j))
69 return false; 69 return false;
70 } 70 }
71 } 71 }
72 } 72 }
73 return !rows.empty(); 73 return !rows.empty();
74 } 74 }
75 75
76 void GeolocationExceptionsTableModel::RemoveExceptions(const Rows& rows) { 76 void GeolocationExceptionsTableModel::RemoveRows(const Rows& rows) {
77 for (Rows::const_reverse_iterator i(rows.rbegin()); i != rows.rend(); ++i) { 77 for (Rows::const_reverse_iterator i(rows.rbegin()); i != rows.rend(); ++i) {
78 size_t row = *i; 78 size_t row = *i;
79 Entry* entry = &entries_[row]; 79 Entry* entry = &entries_[row];
80 GURL entry_origin(entry->origin); // Copy, not reference, since we'll erase 80 GURL entry_origin(entry->origin); // Copy, not reference, since we'll erase
81 // |entry| before we're done with this. 81 // |entry| before we're done with this.
82 bool next_has_same_origin = ((row + 1) < entries_.size()) && 82 bool next_has_same_origin = ((row + 1) < entries_.size()) &&
83 (entries_[row + 1].origin == entry_origin); 83 (entries_[row + 1].origin == entry_origin);
84 bool has_children = (entry_origin == entry->embedding_origin) && 84 bool has_children = (entry_origin == entry->embedding_origin) &&
85 next_has_same_origin; 85 next_has_same_origin;
86 map_->SetContentSetting(entry_origin, entry->embedding_origin, 86 map_->SetContentSetting(entry_origin, entry->embedding_origin,
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 241
242 // static 242 // static
243 GeolocationExceptionsTableModel::Entry::Entry( 243 GeolocationExceptionsTableModel::Entry::Entry(
244 const GURL& in_origin, const GURL& in_embedding_origin, 244 const GURL& in_origin, const GURL& in_embedding_origin,
245 ContentSetting in_setting) 245 ContentSetting in_setting)
246 : origin(in_origin), 246 : origin(in_origin),
247 embedding_origin(in_embedding_origin), 247 embedding_origin(in_embedding_origin),
248 setting(in_setting) { 248 setting(in_setting) {
249 } 249 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698