Index: chrome/browser/gtk/options/content_exceptions_window_gtk.cc |
diff --git a/chrome/browser/gtk/options/content_exceptions_window_gtk.cc b/chrome/browser/gtk/options/content_exceptions_window_gtk.cc |
index 0aa85e31e85f605b10f576b29f0ec4ee9910daca..5894e9f250e2b29fc86263e8748721fe4db8f6ec 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) { |