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

Unified Diff: chrome/browser/views/options/simple_content_exceptions_view.cc

Issue 2835031: Rename GeolocationExceptionsView, make it more reusable. (Closed)
Patch Set: comments Created 10 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/views/options/simple_content_exceptions_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/options/simple_content_exceptions_view.cc
diff --git a/chrome/browser/views/options/geolocation_exceptions_view.cc b/chrome/browser/views/options/simple_content_exceptions_view.cc
similarity index 73%
rename from chrome/browser/views/options/geolocation_exceptions_view.cc
rename to chrome/browser/views/options/simple_content_exceptions_view.cc
index 4adff3bdbab086cc42553f4657be4220e1345d56..3a241d29ba13905a251735f5a98ca0ba649df971 100644
--- a/chrome/browser/views/options/geolocation_exceptions_view.cc
+++ b/chrome/browser/views/options/simple_content_exceptions_view.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/views/options/geolocation_exceptions_view.h"
+#include "chrome/browser/views/options/simple_content_exceptions_view.h"
#include <algorithm>
#include <vector>
@@ -18,14 +18,15 @@
#include "views/window/window.h"
static const int kExceptionsViewInsetSize = 5;
-static GeolocationExceptionsView* instance = NULL;
+static SimpleContentExceptionsView* instance = NULL;
// static
-void GeolocationExceptionsView::ShowExceptionsWindow(
+void SimpleContentExceptionsView::ShowExceptionsWindow(
gfx::NativeWindow parent,
- GeolocationContentSettingsMap* map) {
+ RemoveRowsTableModel* model) {
+ scoped_ptr<RemoveRowsTableModel> owned_model(model);
if (!instance) {
- instance = new GeolocationExceptionsView(map);
+ instance = new SimpleContentExceptionsView(owned_model.release());
views::Window::CreateChromeWindow(parent, gfx::Rect(), instance);
}
@@ -33,21 +34,21 @@ void GeolocationExceptionsView::ShowExceptionsWindow(
instance->window()->Show();
}
-GeolocationExceptionsView::~GeolocationExceptionsView() {
+SimpleContentExceptionsView::~SimpleContentExceptionsView() {
instance = NULL;
table_->SetModel(NULL);
}
-void GeolocationExceptionsView::OnSelectionChanged() {
+void SimpleContentExceptionsView::OnSelectionChanged() {
UpdateButtonState();
}
-void GeolocationExceptionsView::OnTableViewDelete(
+void SimpleContentExceptionsView::OnTableViewDelete(
views::TableView* table_view) {
Remove();
}
-void GeolocationExceptionsView::ButtonPressed(views::Button* sender,
+void SimpleContentExceptionsView::ButtonPressed(views::Button* sender,
const views::Event& event) {
switch (sender->tag()) {
case IDS_EXCEPTIONS_REMOVEALL_BUTTON:
@@ -61,7 +62,7 @@ void GeolocationExceptionsView::ButtonPressed(views::Button* sender,
}
}
-void GeolocationExceptionsView::Layout() {
+void SimpleContentExceptionsView::Layout() {
views::NativeButton* buttons[] = { remove_button_, remove_all_button_ };
// The buttons are placed in the parent, but we need to lay them out.
@@ -79,32 +80,32 @@ void GeolocationExceptionsView::Layout() {
View::Layout();
}
-gfx::Size GeolocationExceptionsView::GetPreferredSize() {
+gfx::Size SimpleContentExceptionsView::GetPreferredSize() {
return gfx::Size(views::Window::GetLocalizedContentsSize(
IDS_GEOLOCATION_EXCEPTION_DIALOG_WIDTH_CHARS,
IDS_GEOLOCATION_EXCEPTION_DIALOG_HEIGHT_LINES));
}
-void GeolocationExceptionsView::ViewHierarchyChanged(bool is_add,
+void SimpleContentExceptionsView::ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) {
if (is_add && child == this)
Init();
}
-std::wstring GeolocationExceptionsView::GetWindowTitle() const {
+std::wstring SimpleContentExceptionsView::GetWindowTitle() const {
return l10n_util::GetString(IDS_GEOLOCATION_EXCEPTION_TITLE);
}
-GeolocationExceptionsView::GeolocationExceptionsView(
- GeolocationContentSettingsMap* map)
- : model_(map),
+SimpleContentExceptionsView::SimpleContentExceptionsView(
+ RemoveRowsTableModel* model)
+ : model_(model),
table_(NULL),
remove_button_(NULL),
remove_all_button_(NULL) {
}
-void GeolocationExceptionsView::Init() {
+void SimpleContentExceptionsView::Init() {
if (table_)
return; // We've already Init'd.
@@ -117,8 +118,8 @@ void GeolocationExceptionsView::Init() {
columns.push_back(
TableColumn(IDS_EXCEPTIONS_ACTION_HEADER, TableColumn::LEFT, -1, .25));
columns.back().sortable = true;
- table_ = new views::TableView(&model_, columns, views::TEXT_ONLY, false, true,
- false);
+ table_ = new views::TableView(model_.get(), columns, views::TEXT_ONLY,
+ false, true, false);
views::TableView::SortDescriptors sort;
sort.push_back(
views::TableView::SortDescriptor(IDS_EXCEPTIONS_HOSTNAME_HEADER, true));
@@ -155,26 +156,26 @@ void GeolocationExceptionsView::Init() {
UpdateButtonState();
}
-GeolocationExceptionsTableModel::Rows
- GeolocationExceptionsView::GetSelectedRows() const {
- GeolocationExceptionsTableModel::Rows rows;
+RemoveRowsTableModel::Rows
+ SimpleContentExceptionsView::GetSelectedRows() const {
+ RemoveRowsTableModel::Rows rows;
for (views::TableView::iterator i(table_->SelectionBegin());
i != table_->SelectionEnd(); ++i)
rows.insert(*i);
return rows;
}
-void GeolocationExceptionsView::UpdateButtonState() {
- remove_button_->SetEnabled(model_.CanRemoveRows(GetSelectedRows()));
- remove_all_button_->SetEnabled(model_.RowCount() > 0);
+void SimpleContentExceptionsView::UpdateButtonState() {
+ remove_button_->SetEnabled(model_->CanRemoveRows(GetSelectedRows()));
+ remove_all_button_->SetEnabled(model_->RowCount() > 0);
}
-void GeolocationExceptionsView::Remove() {
- model_.RemoveRows(GetSelectedRows());
+void SimpleContentExceptionsView::Remove() {
+ model_->RemoveRows(GetSelectedRows());
UpdateButtonState();
}
-void GeolocationExceptionsView::RemoveAll() {
- model_.RemoveAll();
+void SimpleContentExceptionsView::RemoveAll() {
+ model_->RemoveAll();
UpdateButtonState();
}
« no previous file with comments | « chrome/browser/views/options/simple_content_exceptions_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698