summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/options/exceptions_view.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views/options/exceptions_view.cc')
-rw-r--r--chrome/browser/views/options/exceptions_view.cc44
1 files changed, 32 insertions, 12 deletions
diff --git a/chrome/browser/views/options/exceptions_view.cc b/chrome/browser/views/options/exceptions_view.cc
index 8d7fc76..eadaf75 100644
--- a/chrome/browser/views/options/exceptions_view.cc
+++ b/chrome/browser/views/options/exceptions_view.cc
@@ -8,10 +8,12 @@
#include <vector>
#include "app/l10n_util.h"
+#include "chrome/browser/views/options/content_exceptions_table_view.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "gfx/rect.h"
#include "views/controls/button/native_button.h"
+#include "views/controls/label.h"
#include "views/controls/table/table_view.h"
#include "views/grid_layout.h"
#include "views/standard_layout.h"
@@ -21,11 +23,14 @@ static const int kExceptionsViewInsetSize = 5;
static ExceptionsView* instances[CONTENT_SETTINGS_NUM_TYPES] = { NULL };
// static
-void ExceptionsView::ShowExceptionsWindow(gfx::NativeWindow parent,
- HostContentSettingsMap* map,
- ContentSettingsType content_type) {
+void ExceptionsView::ShowExceptionsWindow(
+ gfx::NativeWindow parent,
+ HostContentSettingsMap* map,
+ HostContentSettingsMap* off_the_record_map,
+ ContentSettingsType content_type) {
if (!instances[content_type]) {
- instances[content_type] = new ExceptionsView(map, content_type);
+ instances[content_type] =
+ new ExceptionsView(map, off_the_record_map, content_type);
views::Window::CreateChromeWindow(parent, gfx::Rect(),
instances[content_type]);
}
@@ -125,20 +130,25 @@ std::wstring ExceptionsView::GetWindowTitle() const {
void ExceptionsView::AcceptExceptionEdit(
const HostContentSettingsMap::Pattern& pattern,
ContentSetting setting,
+ bool is_off_the_record,
int index,
bool is_new) {
+ DCHECK(!is_off_the_record || allow_off_the_record_);
+
if (!is_new)
model_.RemoveException(index);
- model_.AddException(pattern, setting);
+ model_.AddException(pattern, setting, is_off_the_record);
- int new_index = model_.IndexOfExceptionByPattern(pattern);
+ int new_index = model_.IndexOfExceptionByPattern(pattern, is_off_the_record);
DCHECK(new_index != -1);
table_->Select(new_index);
}
ExceptionsView::ExceptionsView(HostContentSettingsMap* map,
+ HostContentSettingsMap* off_the_record_map,
ContentSettingsType type)
- : model_(map, type),
+ : model_(map, off_the_record_map, type),
+ allow_off_the_record_(off_the_record_map != NULL),
table_(NULL),
add_button_(NULL),
edit_button_(NULL),
@@ -159,8 +169,7 @@ void ExceptionsView::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 ContentExceptionsTableView(&model_, columns);
views::TableView::SortDescriptors sort;
sort.push_back(
views::TableView::SortDescriptor(IDS_EXCEPTIONS_PATTERN_HEADER, true));
@@ -202,6 +211,15 @@ void ExceptionsView::Init() {
layout->AddView(table_);
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ if (allow_off_the_record_) {
+ views::Label* label = new views::Label(l10n_util::GetString(
+ IDS_EXCEPTIONS_OTR_IN_ITALICS));
+ label->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ layout->StartRow(0, single_column_layout_id);
+ layout->AddView(label, 1, 1, GridLayout::LEADING, GridLayout::CENTER);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+ }
+
UpdateButtonState();
}
@@ -215,9 +233,9 @@ void ExceptionsView::UpdateButtonState() {
void ExceptionsView::Add() {
ExceptionEditorView* view =
- new ExceptionEditorView(this, &model_, -1,
+ new ExceptionEditorView(this, &model_, allow_off_the_record_, -1,
HostContentSettingsMap::Pattern(),
- CONTENT_SETTING_BLOCK);
+ CONTENT_SETTING_BLOCK, false);
view->Show(window()->GetNativeWindow());
UpdateButtonState();
@@ -229,7 +247,9 @@ void ExceptionsView::Edit() {
const HostContentSettingsMap::PatternSettingPair& entry =
model_.entry_at(index);
ExceptionEditorView* view =
- new ExceptionEditorView(this, &model_, index, entry.first, entry.second);
+ new ExceptionEditorView(this, &model_, allow_off_the_record_, index,
+ entry.first, entry.second,
+ model_.entry_is_off_the_record(index));
view->Show(window()->GetNativeWindow());
}