summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-02 07:31:11 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-02 07:31:11 +0000
commit6c8909c917c7e8fc735416adf5e6db82b0f91982 (patch)
tree8bdd526de11cf070c1fad18c92d15fce595b838a /chrome/browser/gtk
parent26420cde5e0df5bc8b9ca304aa6dbe1174e33ea1 (diff)
downloadchromium_src-6c8909c917c7e8fc735416adf5e6db82b0f91982.zip
chromium_src-6c8909c917c7e8fc735416adf5e6db82b0f91982.tar.gz
chromium_src-6c8909c917c7e8fc735416adf5e6db82b0f91982.tar.bz2
Display content settings applying to the current otr session only.
Also allow for editing them... The XIB change adds a column at the end of the table with a NSCheckboxCell in it and the title IDS_EXCEPTIONS_OTR_HEADER BUG=44480 TEST=manual Review URL: http://codereview.chromium.org/2858032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51507 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/options/content_exception_editor.cc27
-rw-r--r--chrome/browser/gtk/options/content_exception_editor.h9
-rw-r--r--chrome/browser/gtk/options/content_exceptions_window_gtk.cc57
-rw-r--r--chrome/browser/gtk/options/content_exceptions_window_gtk.h7
-rw-r--r--chrome/browser/gtk/options/content_filter_page_gtk.cc6
-rw-r--r--chrome/browser/gtk/options/cookie_filter_page_gtk.cc6
6 files changed, 92 insertions, 20 deletions
diff --git a/chrome/browser/gtk/options/content_exception_editor.cc b/chrome/browser/gtk/options/content_exception_editor.cc
index ea12db9..002dfb3 100644
--- a/chrome/browser/gtk/options/content_exception_editor.cc
+++ b/chrome/browser/gtk/options/content_exception_editor.cc
@@ -18,9 +18,11 @@ ContentExceptionEditor::ContentExceptionEditor(
GtkWindow* parent,
ContentExceptionEditor::Delegate* delegate,
ContentExceptionsTableModel* model,
+ bool allow_off_the_record,
int index,
const HostContentSettingsMap::Pattern& pattern,
- ContentSetting setting)
+ ContentSetting setting,
+ bool is_off_the_record)
: delegate_(delegate),
model_(model),
cb_model_(model->content_type() == CONTENT_SETTINGS_TYPE_COOKIES),
@@ -56,6 +58,11 @@ ContentExceptionEditor::ContentExceptionEditor(
gtk_combo_box_set_active(GTK_COMBO_BOX(action_combo_),
cb_model_.IndexForSetting(setting_));
+ otr_checkbox_ = gtk_check_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_EXCEPTION_EDITOR_OTR_TITLE).c_str());
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(otr_checkbox_),
+ is_off_the_record);
+
GtkWidget* table = gtk_util::CreateLabeledControlsGroup(
NULL,
l10n_util::GetStringUTF8(IDS_EXCEPTION_EDITOR_PATTERN_TITLE).c_str(),
@@ -63,6 +70,10 @@ ContentExceptionEditor::ContentExceptionEditor(
l10n_util::GetStringUTF8(IDS_EXCEPTION_EDITOR_ACTION_TITLE).c_str(),
action_combo_,
NULL);
+ if (allow_off_the_record) {
+ gtk_table_attach(GTK_TABLE(table), otr_checkbox_,
+ 0, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
+ }
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog_)->vbox), table,
FALSE, FALSE, 0);
@@ -79,9 +90,10 @@ ContentExceptionEditor::ContentExceptionEditor(
}
bool ContentExceptionEditor::IsPatternValid(
- const HostContentSettingsMap::Pattern& pattern) const {
+ const HostContentSettingsMap::Pattern& pattern,
+ bool is_off_the_record) const {
bool is_valid_pattern = pattern.IsValid() &&
- (model_->IndexOfExceptionByPattern(pattern) == -1);
+ (model_->IndexOfExceptionByPattern(pattern, is_off_the_record) == -1);
return is_new() ? is_valid_pattern : (!pattern.AsString().empty() &&
((pattern_ == pattern) || is_valid_pattern));
@@ -96,7 +108,9 @@ void ContentExceptionEditor::UpdateImage(GtkWidget* image, bool is_valid) {
void ContentExceptionEditor::OnEntryChanged(GtkWidget* entry) {
HostContentSettingsMap::Pattern new_pattern(
gtk_entry_get_text(GTK_ENTRY(entry)));
- bool is_valid = IsPatternValid(new_pattern);
+ bool is_off_the_record =
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(otr_checkbox_));
+ bool is_valid = IsPatternValid(new_pattern, is_off_the_record);
gtk_dialog_set_response_sensitive(GTK_DIALOG(dialog_),
GTK_RESPONSE_OK, is_valid);
UpdateImage(pattern_image_, is_valid);
@@ -109,7 +123,10 @@ void ContentExceptionEditor::OnResponse(GtkWidget* sender, int response_id) {
gtk_entry_get_text(GTK_ENTRY(entry_)));
ContentSetting setting = cb_model_.SettingForIndex(
gtk_combo_box_get_active(GTK_COMBO_BOX(action_combo_)));
- delegate_->AcceptExceptionEdit(new_pattern, setting, index_, is_new());
+ bool is_off_the_record =
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(otr_checkbox_));
+ delegate_->AcceptExceptionEdit(
+ new_pattern, setting, is_off_the_record, index_, is_new());
}
gtk_widget_destroy(dialog_);
diff --git a/chrome/browser/gtk/options/content_exception_editor.h b/chrome/browser/gtk/options/content_exception_editor.h
index 5bd7ad0..98dcbf9 100644
--- a/chrome/browser/gtk/options/content_exception_editor.h
+++ b/chrome/browser/gtk/options/content_exception_editor.h
@@ -26,6 +26,7 @@ class ContentExceptionEditor {
virtual void AcceptExceptionEdit(
const HostContentSettingsMap::Pattern& pattern,
ContentSetting setting,
+ bool is_off_the_record,
int index,
bool is_new) = 0;
@@ -36,15 +37,18 @@ class ContentExceptionEditor {
ContentExceptionEditor(GtkWindow* parent,
Delegate* delegate,
ContentExceptionsTableModel* model,
+ bool allow_off_the_record,
int index,
const HostContentSettingsMap::Pattern& pattern,
- ContentSetting setting);
+ ContentSetting setting,
+ bool is_off_the_record);
private:
// Returns true if we're adding a new item.
bool is_new() const { return index_ == -1; }
- bool IsPatternValid(const HostContentSettingsMap::Pattern& pattern) const;
+ bool IsPatternValid(const HostContentSettingsMap::Pattern& pattern,
+ bool is_off_the_record) const;
void UpdateImage(GtkWidget* image, bool is_valid);
@@ -69,6 +73,7 @@ class ContentExceptionEditor {
GtkWidget* entry_;
GtkWidget* pattern_image_;
GtkWidget* action_combo_;
+ GtkWidget* otr_checkbox_;
DISALLOW_COPY_AND_ASSIGN(ContentExceptionEditor);
};
diff --git a/chrome/browser/gtk/options/content_exceptions_window_gtk.cc b/chrome/browser/gtk/options/content_exceptions_window_gtk.cc
index 0aa85e3..5894e9f 100644
--- a/chrome/browser/gtk/options/content_exceptions_window_gtk.cc
+++ b/chrome/browser/gtk/options/content_exceptions_window_gtk.cc
@@ -26,6 +26,7 @@ ContentExceptionsWindowGtk* instances[CONTENT_SETTINGS_NUM_TYPES] = { NULL };
void ContentExceptionsWindowGtk::ShowExceptionsWindow(
GtkWindow* parent,
HostContentSettingsMap* map,
+ HostContentSettingsMap* off_the_record_map,
ContentSettingsType type) {
DCHECK(map);
DCHECK(type < CONTENT_SETTINGS_NUM_TYPES);
@@ -34,7 +35,8 @@ void ContentExceptionsWindowGtk::ShowExceptionsWindow(
if (!instances[type]) {
// Create the options window.
- instances[type] = new ContentExceptionsWindowGtk(parent, map, type);
+ instances[type] =
+ new ContentExceptionsWindowGtk(parent, map, off_the_record_map, type);
} else {
gtk_util::PresentWindow(instances[type]->dialog_, 0);
}
@@ -46,10 +48,13 @@ ContentExceptionsWindowGtk::~ContentExceptionsWindowGtk() {
ContentExceptionsWindowGtk::ContentExceptionsWindowGtk(
GtkWindow* parent,
HostContentSettingsMap* map,
- ContentSettingsType type) {
+ HostContentSettingsMap* off_the_record_map,
+ ContentSettingsType type)
+ : allow_off_the_record_(off_the_record_map) {
// Build the model adapters that translate views and TableModels into
// something GTK can use.
- list_store_ = gtk_list_store_new(COL_COUNT, G_TYPE_STRING, G_TYPE_STRING);
+ list_store_ = gtk_list_store_new(
+ COL_COUNT, G_TYPE_STRING, G_TYPE_STRING, PANGO_TYPE_STYLE);
treeview_ = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store_));
g_object_unref(list_store_);
@@ -62,6 +67,7 @@ ContentExceptionsWindowGtk::ContentExceptionsWindowGtk(
l10n_util::GetStringUTF8(IDS_EXCEPTIONS_PATTERN_HEADER).c_str(),
gtk_cell_renderer_text_new(),
"text", COL_PATTERN,
+ "style", COL_OTR,
NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview_), pattern_column);
gtk_tree_view_column_set_sort_column_id(pattern_column, COL_PATTERN);
@@ -70,6 +76,7 @@ ContentExceptionsWindowGtk::ContentExceptionsWindowGtk(
l10n_util::GetStringUTF8(IDS_EXCEPTIONS_ACTION_HEADER).c_str(),
gtk_cell_renderer_text_new(),
"text", COL_ACTION,
+ "style", COL_OTR,
NULL);
gtk_tree_view_append_column(GTK_TREE_VIEW(treeview_), action_column);
gtk_tree_view_column_set_sort_column_id(action_column, COL_ACTION);
@@ -81,7 +88,7 @@ ContentExceptionsWindowGtk::ContentExceptionsWindowGtk(
G_CALLBACK(OnTreeSelectionChangedThunk), this);
// Bind |list_store_| to our C++ model.
- model_.reset(new ContentExceptionsTableModel(map, type));
+ model_.reset(new ContentExceptionsTableModel(map, off_the_record_map, type));
model_adapter_.reset(new gtk_tree::TableAdapter(this, list_store_,
model_.get()));
// Force a reload of everything to copy data into |list_store_|.
@@ -103,6 +110,8 @@ ContentExceptionsWindowGtk::ContentExceptionsWindowGtk(
GtkWidget* hbox = gtk_hbox_new(FALSE, gtk_util::kControlSpacing);
gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), hbox);
+ GtkWidget* treeview_box = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
+
// Create a scrolled window to wrap the treeview widget.
GtkWidget* scrolled = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled),
@@ -110,7 +119,23 @@ ContentExceptionsWindowGtk::ContentExceptionsWindowGtk(
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_container_add(GTK_CONTAINER(scrolled), treeview_);
- gtk_box_pack_start(GTK_BOX(hbox), scrolled, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(treeview_box), scrolled, TRUE, TRUE, 0);
+
+ // If we also have an OTR profile, inform the user that OTR exceptions are
+ // displayed in italics.
+ if (allow_off_the_record_) {
+ GtkWidget* incognito_label = gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_EXCEPTIONS_OTR_IN_ITALICS).c_str());
+ PangoAttrList* attributes = pango_attr_list_new();
+ pango_attr_list_insert(attributes,
+ pango_attr_style_new(PANGO_STYLE_ITALIC));
+ gtk_label_set_attributes(GTK_LABEL(incognito_label), attributes);
+ pango_attr_list_unref(attributes);
+ gtk_misc_set_alignment(GTK_MISC(incognito_label), 0, 0);
+ gtk_box_pack_start(GTK_BOX(treeview_box), incognito_label, FALSE, FALSE, 0);
+ }
+
+ gtk_box_pack_start(GTK_BOX(hbox), treeview_box, TRUE, TRUE, 0);
GtkWidget* button_box = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
@@ -161,19 +186,27 @@ void ContentExceptionsWindowGtk::SetColumnValues(int row, GtkTreeIter* iter) {
std::wstring action = model_->GetText(row, IDS_EXCEPTIONS_ACTION_HEADER);
gtk_list_store_set(list_store_, iter, COL_ACTION,
WideToUTF8(action).c_str(), -1);
+
+ bool is_off_the_record = model_->entry_is_off_the_record(row);
+ PangoStyle style =
+ is_off_the_record ? PANGO_STYLE_ITALIC : PANGO_STYLE_NORMAL;
+ gtk_list_store_set(list_store_, iter, COL_OTR, style, -1);
}
void ContentExceptionsWindowGtk::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_NE(-1, new_index);
gtk_tree::SelectAndFocusRowNum(new_index, GTK_TREE_VIEW(treeview_));
@@ -196,9 +229,9 @@ void ContentExceptionsWindowGtk::UpdateButtonState() {
void ContentExceptionsWindowGtk::Add(GtkWidget* widget) {
new ContentExceptionEditor(GTK_WINDOW(dialog_),
- this, model_.get(), -1,
+ this, model_.get(), allow_off_the_record_, -1,
HostContentSettingsMap::Pattern(),
- CONTENT_SETTING_BLOCK);
+ CONTENT_SETTING_BLOCK, false);
}
void ContentExceptionsWindowGtk::Edit(GtkWidget* widget) {
@@ -208,8 +241,10 @@ void ContentExceptionsWindowGtk::Edit(GtkWidget* widget) {
int index = *indices.begin();
const HostContentSettingsMap::PatternSettingPair& entry =
model_->entry_at(index);
- new ContentExceptionEditor(GTK_WINDOW(dialog_), this, model_.get(), index,
- entry.first, entry.second);
+ new ContentExceptionEditor(GTK_WINDOW(dialog_), this, model_.get(),
+ allow_off_the_record_, index,
+ entry.first, entry.second,
+ model_->entry_is_off_the_record(index));
}
void ContentExceptionsWindowGtk::Remove(GtkWidget* widget) {
diff --git a/chrome/browser/gtk/options/content_exceptions_window_gtk.h b/chrome/browser/gtk/options/content_exceptions_window_gtk.h
index c415419..aadd3ad 100644
--- a/chrome/browser/gtk/options/content_exceptions_window_gtk.h
+++ b/chrome/browser/gtk/options/content_exceptions_window_gtk.h
@@ -26,6 +26,7 @@ class ContentExceptionsWindowGtk : public gtk_tree::TableAdapter::Delegate,
public:
static void ShowExceptionsWindow(GtkWindow* window,
HostContentSettingsMap* map,
+ HostContentSettingsMap* off_the_record_map,
ContentSettingsType content_type);
~ContentExceptionsWindowGtk();
@@ -37,6 +38,7 @@ class ContentExceptionsWindowGtk : public gtk_tree::TableAdapter::Delegate,
virtual void AcceptExceptionEdit(
const HostContentSettingsMap::Pattern& pattern,
ContentSetting setting,
+ bool is_off_the_record,
int index,
bool is_new);
@@ -45,11 +47,13 @@ class ContentExceptionsWindowGtk : public gtk_tree::TableAdapter::Delegate,
enum {
COL_PATTERN,
COL_ACTION,
+ COL_OTR,
COL_COUNT
};
ContentExceptionsWindowGtk(GtkWindow* parent,
HostContentSettingsMap* map,
+ HostContentSettingsMap* off_the_record_map,
ContentSettingsType type);
// Updates which buttons are enabled.
@@ -79,6 +83,9 @@ class ContentExceptionsWindowGtk : public gtk_tree::TableAdapter::Delegate,
// gold standard data.
scoped_ptr<ContentExceptionsTableModel> model_;
+ // True if we also show exceptions from an OTR profile.
+ bool allow_off_the_record_;
+
// The adapter that ferries data back and forth between |model_| and
// |list_store_| whenever either of them change.
scoped_ptr<gtk_tree::TableAdapter> model_adapter_;
diff --git a/chrome/browser/gtk/options/content_filter_page_gtk.cc b/chrome/browser/gtk/options/content_filter_page_gtk.cc
index 522a9a1..ae568ab 100644
--- a/chrome/browser/gtk/options/content_filter_page_gtk.cc
+++ b/chrome/browser/gtk/options/content_filter_page_gtk.cc
@@ -184,9 +184,13 @@ void ContentFilterPageGtk::OnExceptionsClicked(GtkWidget* button) {
}
HostContentSettingsMap* settings_map =
profile()->GetHostContentSettingsMap();
+ HostContentSettingsMap* otr_settings_map =
+ profile()->HasOffTheRecordProfile() ?
+ profile()->GetOffTheRecordProfile()->GetHostContentSettingsMap() :
+ NULL;
ContentExceptionsWindowGtk::ShowExceptionsWindow(
GTK_WINDOW(gtk_widget_get_toplevel(button)),
- settings_map, content_type_);
+ settings_map, otr_settings_map, content_type_);
}
void ContentFilterPageGtk::OnPluginsPageLinkClicked(GtkWidget* button) {
diff --git a/chrome/browser/gtk/options/cookie_filter_page_gtk.cc b/chrome/browser/gtk/options/cookie_filter_page_gtk.cc
index e5714b2..d32ed23 100644
--- a/chrome/browser/gtk/options/cookie_filter_page_gtk.cc
+++ b/chrome/browser/gtk/options/cookie_filter_page_gtk.cc
@@ -170,9 +170,13 @@ void CookieFilterPageGtk::OnCookiesAllowToggled(GtkWidget* toggle_button) {
void CookieFilterPageGtk::OnExceptionsClicked(GtkWidget* button) {
HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap();
+ HostContentSettingsMap* otr_settings_map =
+ profile()->HasOffTheRecordProfile() ?
+ profile()->GetOffTheRecordProfile()->GetHostContentSettingsMap() :
+ NULL;
ContentExceptionsWindowGtk::ShowExceptionsWindow(
GTK_WINDOW(gtk_widget_get_toplevel(button)),
- settings_map, CONTENT_SETTINGS_TYPE_COOKIES);
+ settings_map, otr_settings_map, CONTENT_SETTINGS_TYPE_COOKIES);
}
void CookieFilterPageGtk::OnBlockThirdPartyToggled(GtkWidget* toggle_button) {