summaryrefslogtreecommitdiffstats
path: root/chrome/browser/geolocation
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-01 16:17:37 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-01 16:17:37 +0000
commit508d27e151318b0a2ffdc6a4089ea3613462c26d (patch)
tree0aadf1f0948c5086a624e37f95bc966fa4bb8633 /chrome/browser/geolocation
parentbf784d4ca187ca12d455e91ae7c0d2e0380a3154 (diff)
downloadchromium_src-508d27e151318b0a2ffdc6a4089ea3613462c26d.zip
chromium_src-508d27e151318b0a2ffdc6a4089ea3613462c26d.tar.gz
chromium_src-508d27e151318b0a2ffdc6a4089ea3613462c26d.tar.bz2
Introduce RemoveRowTableModel interface, let GeolocationExceptionsTableModel derive from it.
No functionality change. This will be used to share the content settings exceptions dialog code between geolocation and notifications. BUG=45547 Review URL: http://codereview.chromium.org/2838037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51370 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation')
-rw-r--r--chrome/browser/geolocation/geolocation_exceptions_table_model.cc14
-rw-r--r--chrome/browser/geolocation/geolocation_exceptions_table_model.h14
-rw-r--r--chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc10
3 files changed, 19 insertions, 19 deletions
diff --git a/chrome/browser/geolocation/geolocation_exceptions_table_model.cc b/chrome/browser/geolocation/geolocation_exceptions_table_model.cc
index 95d2e79..c8a6202 100644
--- a/chrome/browser/geolocation/geolocation_exceptions_table_model.cc
+++ b/chrome/browser/geolocation/geolocation_exceptions_table_model.cc
@@ -57,7 +57,7 @@ GeolocationExceptionsTableModel::GeolocationExceptionsTableModel(
AddEntriesForOrigin(i->first, i->second);
}
-bool GeolocationExceptionsTableModel::CanRemoveExceptions(
+bool GeolocationExceptionsTableModel::CanRemoveRows(
const Rows& rows) const {
for (Rows::const_iterator i(rows.begin()); i != rows.end(); ++i) {
const Entry& entry = entries_[*i];
@@ -73,7 +73,7 @@ bool GeolocationExceptionsTableModel::CanRemoveExceptions(
return !rows.empty();
}
-void GeolocationExceptionsTableModel::RemoveExceptions(const Rows& rows) {
+void GeolocationExceptionsTableModel::RemoveRows(const Rows& rows) {
for (Rows::const_reverse_iterator i(rows.rbegin()); i != rows.rend(); ++i) {
size_t row = *i;
Entry* entry = &entries_[row];
@@ -95,11 +95,11 @@ void GeolocationExceptionsTableModel::RemoveExceptions(const Rows& rows) {
entries_.erase(entries_.begin() + row); // Note: |entry| is now garbage.
if (observer_)
observer_->OnItemsRemoved(row, 1);
- // If we remove the last non-default child of a default parent, we
- // should remove the parent too. We do these removals one-at-a-time
- // because the table view will end up being called back as each row is
- // removed, in turn calling back to CanRemoveExceptions(), and if we've
- // already removed more entries than the view has, we'll have problems.
+ // If we remove the last non-default child of a default parent, we should
+ // remove the parent too. We do these removals one-at-a-time because the
+ // table view will end up being called back as each row is removed, in
+ // turn calling back to CanRemoveRows(), and if we've already removed
+ // more entries than the view has, we'll have problems.
if ((row == 0) || rows.count(row - 1))
break;
entry = &entries_[--row];
diff --git a/chrome/browser/geolocation/geolocation_exceptions_table_model.h b/chrome/browser/geolocation/geolocation_exceptions_table_model.h
index 6328166..c458c0e 100644
--- a/chrome/browser/geolocation/geolocation_exceptions_table_model.h
+++ b/chrome/browser/geolocation/geolocation_exceptions_table_model.h
@@ -8,32 +8,32 @@
#include <set>
#include <vector>
-#include "app/table_model.h"
#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
+#include "chrome/browser/remove_rows_table_model.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/content_settings_types.h"
-class GeolocationExceptionsTableModel : public TableModel {
+class GeolocationExceptionsTableModel : public RemoveRowsTableModel {
public:
- typedef std::set<size_t> Rows;
-
explicit GeolocationExceptionsTableModel(
GeolocationContentSettingsMap* map);
+ // RemoveRowsTableModel overrides:
+
// Return whether the given set of rows can be removed. A parent with setting
// of CONTENT_SETTING_DEFAULT can't be removed unless all its children are
// also being removed.
- bool CanRemoveExceptions(const Rows& rows) const;
+ virtual bool CanRemoveRows(const Rows& rows) const;
// Removes the exceptions at the specified indexes. If an exception is a
// parent, and it has children, the row in model will be updated to have
// CONTENT_SETTING_DEFAULT. If it is the only child of a
// CONTENT_SETTING_DEFAULT parent, the parent will be removed from the model
// too.
- void RemoveExceptions(const Rows& rows);
+ virtual void RemoveRows(const Rows& rows);
// Removes all the exceptions from both the map and model.
- void RemoveAll();
+ virtual void RemoveAll();
// TableModel overrides:
virtual int RowCount();
diff --git a/chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc b/chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc
index 62b65c0..d6d1f5e 100644
--- a/chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc
+++ b/chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc
@@ -71,7 +71,7 @@ TEST_F(GeolocationExceptionsTableModelTest, CanRemoveException) {
EXPECT_EQ(1, model_->RowCount());
GeolocationExceptionsTableModel::Rows rows;
rows.insert(0U);
- EXPECT_TRUE(model_->CanRemoveExceptions(rows));
+ EXPECT_TRUE(model_->CanRemoveRows(rows));
// Ensure an entry with children can't be removed.
@@ -80,13 +80,13 @@ TEST_F(GeolocationExceptionsTableModelTest, CanRemoveException) {
map->SetContentSetting(kUrl0, kUrl2, CONTENT_SETTING_BLOCK);
ResetModel();
EXPECT_EQ(3, model_->RowCount());
- EXPECT_FALSE(model_->CanRemoveExceptions(rows));
+ EXPECT_FALSE(model_->CanRemoveRows(rows));
// Ensure it can be removed if removing all children.
rows.clear();
rows.insert(1U);
rows.insert(2U);
- EXPECT_TRUE(model_->CanRemoveExceptions(rows));
+ EXPECT_TRUE(model_->CanRemoveRows(rows));
}
TEST_F(GeolocationExceptionsTableModelTest, RemoveExceptions) {
@@ -97,7 +97,7 @@ TEST_F(GeolocationExceptionsTableModelTest, RemoveExceptions) {
// Test removing parent exception.
GeolocationExceptionsTableModel::Rows rows;
rows.insert(0U);
- model_->RemoveExceptions(rows);
+ model_->RemoveRows(rows);
EXPECT_EQ(CONTENT_SETTING_ASK, map->GetContentSetting(kUrl0, kUrl0));
EXPECT_EQ(CONTENT_SETTING_ALLOW, map->GetContentSetting(kUrl0, kUrl1));
EXPECT_EQ(CONTENT_SETTING_ALLOW, map->GetContentSetting(kUrl0, kUrl2));
@@ -109,7 +109,7 @@ TEST_F(GeolocationExceptionsTableModelTest, RemoveExceptions) {
rows.clear();
rows.insert(1U);
rows.insert(2U);
- model_->RemoveExceptions(rows);
+ model_->RemoveRows(rows);
EXPECT_EQ(0, model_->RowCount());
EXPECT_EQ(CONTENT_SETTING_ASK, map->GetContentSetting(kUrl0, kUrl0));
EXPECT_EQ(CONTENT_SETTING_ASK, map->GetContentSetting(kUrl0, kUrl1));