[email protected] | 67e7999 | 2012-02-13 20:47:58 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 0d8b9aa | 2011-01-19 18:35:50 | [diff] [blame] | 5 | #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 6 | |
[email protected] | ccea03c | 2010-12-17 03:31:50 | [diff] [blame] | 7 | #include <string> |
[email protected] | af878c1e | 2012-03-06 11:23:54 | [diff] [blame] | 8 | #include "chrome/browser/browsing_data_appcache_helper.h" |
| 9 | #include "chrome/browser/browsing_data_cookie_helper.h" |
| 10 | #include "chrome/browser/browsing_data_database_helper.h" |
| 11 | #include "chrome/browser/browsing_data_file_system_helper.h" |
| 12 | #include "chrome/browser/browsing_data_indexed_db_helper.h" |
| 13 | #include "chrome/browser/browsing_data_local_storage_helper.h" |
[email protected] | acfce00 | 2012-04-06 20:28:10 | [diff] [blame] | 14 | #include "chrome/browser/browsing_data_server_bound_cert_helper.h" |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 15 | #include "chrome/browser/content_settings/cookie_settings.h" |
[email protected] | b6ef09a | 2012-03-08 21:53:25 | [diff] [blame] | 16 | #include "chrome/browser/content_settings/local_shared_objects_container.h" |
[email protected] | 9a611a9 | 2011-05-07 17:06:18 | [diff] [blame] | 17 | #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 18 | #include "chrome/browser/cookies_tree_model.h" |
[email protected] | 7e20412 | 2011-09-01 18:56:21 | [diff] [blame] | 19 | #include "chrome/browser/infobars/infobar_tab_helper.h" |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 20 | #include "chrome/browser/prefs/pref_service.h" |
[email protected] | 8ecad5e | 2010-12-02 21:18:33 | [diff] [blame] | 21 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 78e049b | 2011-03-19 20:45:26 | [diff] [blame] | 22 | #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
[email protected] | 48a5cd6 | 2012-02-29 20:24:20 | [diff] [blame] | 23 | #include "chrome/browser/ui/browser_dialogs.h" |
[email protected] | 9d4984e | 2011-08-24 19:16:02 | [diff] [blame] | 24 | #include "chrome/browser/ui/gtk/constrained_window_gtk.h" |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 25 | #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" |
[email protected] | 0d8b9aa | 2011-01-19 18:35:50 | [diff] [blame] | 26 | #include "chrome/browser/ui/gtk/gtk_util.h" |
[email protected] | 58d3065 | 2012-06-11 19:56:34 | [diff] [blame] | 27 | #include "chrome/browser/ui/tab_contents/tab_contents.h" |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 28 | #include "chrome/common/chrome_notification_types.h" |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 29 | #include "chrome/common/pref_names.h" |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 30 | #include "content/public/browser/notification_source.h" |
[email protected] | 1f0b50b | 2012-06-22 20:37:16 | [diff] [blame^] | 31 | #include "content/public/browser/web_contents.h" |
| 32 | #include "content/public/browser/web_contents_view.h" |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 33 | #include "grit/generated_resources.h" |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 34 | #include "ui/base/gtk/gtk_hig_constants.h" |
[email protected] | c051a1b | 2011-01-21 23:30:17 | [diff] [blame] | 35 | #include "ui/base/l10n/l10n_util.h" |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 36 | |
| 37 | namespace { |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 38 | // Width and height of the cookie tree view. |
| 39 | const int kTreeViewWidth = 450; |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 40 | const int kTreeViewHeight = 150; |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 41 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 42 | // The page numbers of the pages in the notebook. |
| 43 | const gint kAllowedPageNumber = 0; |
| 44 | const gint kBlockedPageNumber = 1; |
| 45 | |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 46 | // Padding within the banner box. |
| 47 | const int kBannerPadding = 3; |
| 48 | |
| 49 | // Returns the text to display in the info bar when content settings were |
| 50 | // created. |
| 51 | const std::string GetInfobarLabel(ContentSetting setting, |
| 52 | bool multiple_domains_added, |
| 53 | const string16& domain_name) { |
| 54 | if (multiple_domains_added) { |
| 55 | switch (setting) { |
| 56 | case CONTENT_SETTING_BLOCK: |
| 57 | return l10n_util::GetStringUTF8( |
| 58 | IDS_COLLECTED_COOKIES_MULTIPLE_BLOCK_RULES_CREATED); |
| 59 | |
| 60 | case CONTENT_SETTING_ALLOW: |
| 61 | return l10n_util::GetStringUTF8( |
| 62 | IDS_COLLECTED_COOKIES_MULTIPLE_ALLOW_RULES_CREATED); |
| 63 | |
| 64 | case CONTENT_SETTING_SESSION_ONLY: |
| 65 | return l10n_util::GetStringUTF8( |
| 66 | IDS_COLLECTED_COOKIES_MULTIPLE_SESSION_RULES_CREATED); |
| 67 | |
| 68 | default: |
| 69 | NOTREACHED(); |
| 70 | return std::string(); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | switch (setting) { |
| 75 | case CONTENT_SETTING_BLOCK: |
| 76 | return l10n_util::GetStringFUTF8( |
| 77 | IDS_COLLECTED_COOKIES_BLOCK_RULE_CREATED, domain_name); |
| 78 | |
| 79 | case CONTENT_SETTING_ALLOW: |
| 80 | return l10n_util::GetStringFUTF8( |
| 81 | IDS_COLLECTED_COOKIES_ALLOW_RULE_CREATED, domain_name); |
| 82 | |
| 83 | case CONTENT_SETTING_SESSION_ONLY: |
| 84 | return l10n_util::GetStringFUTF8( |
| 85 | IDS_COLLECTED_COOKIES_SESSION_RULE_CREATED, domain_name); |
| 86 | |
| 87 | default: |
| 88 | NOTREACHED(); |
| 89 | return std::string(); |
| 90 | } |
| 91 | } |
[email protected] | a3627e6 | 2011-09-07 00:04:57 | [diff] [blame] | 92 | |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 93 | } // namespace |
| 94 | |
[email protected] | 48a5cd6 | 2012-02-29 20:24:20 | [diff] [blame] | 95 | namespace browser { |
| 96 | |
| 97 | // Declared in browser_dialogs.h so others don't have to depend on our header. |
[email protected] | 1f0b50b | 2012-06-22 20:37:16 | [diff] [blame^] | 98 | void ShowCollectedCookiesDialog(TabContents* tab_contents) { |
[email protected] | 48a5cd6 | 2012-02-29 20:24:20 | [diff] [blame] | 99 | // Deletes itself on close. |
[email protected] | 1f0b50b | 2012-06-22 20:37:16 | [diff] [blame^] | 100 | new CollectedCookiesGtk( |
| 101 | tab_contents->web_contents()->GetView()->GetTopLevelNativeWindow(), |
| 102 | tab_contents); |
[email protected] | 48a5cd6 | 2012-02-29 20:24:20 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | } // namespace browser |
| 106 | |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 107 | CollectedCookiesGtk::CollectedCookiesGtk(GtkWindow* parent, |
[email protected] | 58d3065 | 2012-06-11 19:56:34 | [diff] [blame] | 108 | TabContents* tab_contents) |
| 109 | : tab_contents_(tab_contents), |
[email protected] | 78e049b | 2011-03-19 20:45:26 | [diff] [blame] | 110 | status_changed_(false) { |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 111 | registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 112 | content::Source<TabSpecificContentSettings>( |
[email protected] | 58d3065 | 2012-06-11 19:56:34 | [diff] [blame] | 113 | tab_contents->content_settings())); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 114 | |
| 115 | Init(); |
| 116 | } |
| 117 | |
| 118 | void CollectedCookiesGtk::Init() { |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 119 | dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); |
| 120 | gtk_box_set_spacing(GTK_BOX(dialog_), ui::kContentAreaSpacing); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 121 | |
| 122 | GtkWidget* label = gtk_label_new( |
| 123 | l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_DIALOG_TITLE).c_str()); |
| 124 | gtk_box_pack_start(GTK_BOX(dialog_), label, TRUE, TRUE, 0); |
| 125 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 126 | notebook_ = gtk_notebook_new(); |
| 127 | gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook_), GTK_POS_TOP); |
| 128 | gtk_box_pack_start(GTK_BOX(dialog_), notebook_, TRUE, TRUE, 0); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 129 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 130 | GtkWidget* allowed_pane = CreateAllowedPane(); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 131 | label = gtk_label_new( |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 132 | l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL) |
| 133 | .c_str()); |
| 134 | gtk_widget_show(label); |
| 135 | gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), allowed_pane, label, |
| 136 | kAllowedPageNumber); |
| 137 | |
| 138 | GtkWidget* blocked_pane = CreateBlockedPane(); |
| 139 | label = gtk_label_new( |
| 140 | l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL) |
| 141 | .c_str()); |
| 142 | gtk_widget_show(label); |
| 143 | gtk_notebook_insert_page(GTK_NOTEBOOK(notebook_), blocked_pane, label, |
| 144 | kBlockedPageNumber); |
| 145 | // Hook up the signal only after all pages are inserted, otherwise not |
| 146 | // all member variables used in OnSwitchPage() will be properly initialized. |
| 147 | g_signal_connect(notebook_, "switch-page", G_CALLBACK(OnSwitchPageThunk), |
| 148 | this); |
| 149 | |
| 150 | // Cookie info view. |
| 151 | cookie_info_view_ = gtk_chrome_cookie_view_new(false); |
| 152 | gtk_box_pack_start(GTK_BOX(dialog_), cookie_info_view_, TRUE, TRUE, 0); |
| 153 | gtk_chrome_cookie_view_clear(GTK_CHROME_COOKIE_VIEW(cookie_info_view_)); |
| 154 | gtk_widget_show_all(cookie_info_view_); |
| 155 | |
| 156 | // Infobar. |
| 157 | infobar_ = gtk_frame_new(NULL); |
| 158 | GtkWidget* infobar_contents = gtk_hbox_new(FALSE, kBannerPadding); |
| 159 | gtk_container_set_border_width(GTK_CONTAINER(infobar_contents), |
| 160 | kBannerPadding); |
| 161 | gtk_container_add(GTK_CONTAINER(infobar_), infobar_contents); |
| 162 | GtkWidget* info_image = |
| 163 | gtk_image_new_from_stock(GTK_STOCK_DIALOG_INFO, |
| 164 | GTK_ICON_SIZE_SMALL_TOOLBAR); |
| 165 | gtk_box_pack_start(GTK_BOX(infobar_contents), info_image, FALSE, FALSE, 0); |
| 166 | infobar_label_ = gtk_label_new(NULL); |
| 167 | gtk_box_pack_start( |
| 168 | GTK_BOX(infobar_contents), infobar_label_, FALSE, FALSE, 0); |
| 169 | gtk_widget_show_all(infobar_); |
| 170 | gtk_widget_set_no_show_all(infobar_, TRUE); |
| 171 | gtk_widget_hide(infobar_); |
| 172 | gtk_box_pack_start(GTK_BOX(dialog_), infobar_, TRUE, TRUE, 0); |
| 173 | |
| 174 | // Close button. |
| 175 | GtkWidget* button_box = gtk_hbutton_box_new(); |
| 176 | gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_END); |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 177 | gtk_box_set_spacing(GTK_BOX(button_box), ui::kControlSpacing); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 178 | gtk_box_pack_end(GTK_BOX(dialog_), button_box, FALSE, TRUE, 0); |
| 179 | close_button_ = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
| 180 | gtk_button_set_label(GTK_BUTTON(close_button_), |
| 181 | l10n_util::GetStringUTF8(IDS_CLOSE).c_str()); |
| 182 | g_signal_connect(close_button_, "clicked", G_CALLBACK(OnCloseThunk), this); |
| 183 | gtk_box_pack_end(GTK_BOX(button_box), close_button_, FALSE, TRUE, 0); |
| 184 | |
| 185 | // Show the dialog. |
| 186 | allowed_cookies_tree_adapter_->Init(); |
| 187 | blocked_cookies_tree_adapter_->Init(); |
| 188 | EnableControls(); |
| 189 | ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); |
[email protected] | 58d3065 | 2012-06-11 19:56:34 | [diff] [blame] | 190 | window_ = new ConstrainedWindowGtk(tab_contents_, this); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | GtkWidget* CollectedCookiesGtk::CreateAllowedPane() { |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 194 | GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 195 | |
| 196 | GtkWidget* label = gtk_label_new( |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 197 | l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_LABEL). |
| 198 | c_str()); |
| 199 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 200 | gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, FALSE, FALSE, |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 201 | ui::kControlSpacing); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 202 | |
| 203 | GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); |
| 204 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), |
| 205 | GTK_POLICY_AUTOMATIC, |
| 206 | GTK_POLICY_AUTOMATIC); |
| 207 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll_window), |
| 208 | GTK_SHADOW_ETCHED_IN); |
| 209 | gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0); |
| 210 | |
[email protected] | 58d3065 | 2012-06-11 19:56:34 | [diff] [blame] | 211 | TabSpecificContentSettings* content_settings = |
| 212 | tab_contents_->content_settings(); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 213 | |
[email protected] | b6ef09a | 2012-03-08 21:53:25 | [diff] [blame] | 214 | const LocalSharedObjectsContainer& allowed_lsos = |
[email protected] | af878c1e | 2012-03-06 11:23:54 | [diff] [blame] | 215 | content_settings->allowed_local_shared_objects(); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 216 | allowed_cookies_tree_model_.reset( |
[email protected] | af878c1e | 2012-03-06 11:23:54 | [diff] [blame] | 217 | new CookiesTreeModel(allowed_lsos.cookies()->Clone(), |
| 218 | allowed_lsos.databases()->Clone(), |
| 219 | allowed_lsos.local_storages()->Clone(), |
| 220 | allowed_lsos.session_storages()->Clone(), |
| 221 | allowed_lsos.appcaches()->Clone(), |
| 222 | allowed_lsos.indexed_dbs()->Clone(), |
| 223 | allowed_lsos.file_systems()->Clone(), |
| 224 | NULL, |
[email protected] | acfce00 | 2012-04-06 20:28:10 | [diff] [blame] | 225 | allowed_lsos.server_bound_certs()->Clone(), |
[email protected] | af878c1e | 2012-03-06 11:23:54 | [diff] [blame] | 226 | true)); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 227 | allowed_cookies_tree_adapter_.reset( |
[email protected] | 6d90ee62 | 2010-08-18 07:42:27 | [diff] [blame] | 228 | new gtk_tree::TreeAdapter(this, allowed_cookies_tree_model_.get())); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 229 | allowed_tree_ = gtk_tree_view_new_with_model( |
| 230 | GTK_TREE_MODEL(allowed_cookies_tree_adapter_->tree_store())); |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 231 | gtk_widget_set_size_request(allowed_tree_, kTreeViewWidth, kTreeViewHeight); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 232 | gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(allowed_tree_), FALSE); |
| 233 | gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(allowed_tree_), TRUE); |
| 234 | gtk_container_add(GTK_CONTAINER(scroll_window), allowed_tree_); |
| 235 | |
| 236 | GtkTreeViewColumn* title_column = gtk_tree_view_column_new(); |
| 237 | GtkCellRenderer* pixbuf_renderer = gtk_cell_renderer_pixbuf_new(); |
| 238 | gtk_tree_view_column_pack_start(title_column, pixbuf_renderer, FALSE); |
| 239 | gtk_tree_view_column_add_attribute(title_column, pixbuf_renderer, "pixbuf", |
[email protected] | 6d90ee62 | 2010-08-18 07:42:27 | [diff] [blame] | 240 | gtk_tree::TreeAdapter::COL_ICON); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 241 | GtkCellRenderer* title_renderer = gtk_cell_renderer_text_new(); |
| 242 | gtk_tree_view_column_pack_start(title_column, title_renderer, TRUE); |
| 243 | gtk_tree_view_column_add_attribute(title_column, title_renderer, "text", |
[email protected] | 6d90ee62 | 2010-08-18 07:42:27 | [diff] [blame] | 244 | gtk_tree::TreeAdapter::COL_TITLE); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 245 | gtk_tree_view_column_set_title( |
| 246 | title_column, l10n_util::GetStringUTF8( |
| 247 | IDS_COOKIES_DOMAIN_COLUMN_HEADER).c_str()); |
| 248 | gtk_tree_view_append_column(GTK_TREE_VIEW(allowed_tree_), title_column); |
| 249 | g_signal_connect(allowed_tree_, "row-expanded", |
| 250 | G_CALLBACK(OnTreeViewRowExpandedThunk), this); |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 251 | allowed_selection_ = |
| 252 | gtk_tree_view_get_selection(GTK_TREE_VIEW(allowed_tree_)); |
| 253 | gtk_tree_selection_set_mode(allowed_selection_, GTK_SELECTION_MULTIPLE); |
| 254 | g_signal_connect(allowed_selection_, "changed", |
| 255 | G_CALLBACK(OnTreeViewSelectionChangeThunk), this); |
| 256 | |
| 257 | GtkWidget* button_box = gtk_hbutton_box_new(); |
| 258 | gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_START); |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 259 | gtk_box_set_spacing(GTK_BOX(button_box), ui::kControlSpacing); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 260 | gtk_box_pack_start(GTK_BOX(cookie_list_vbox), button_box, FALSE, FALSE, |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 261 | ui::kControlSpacing); |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 262 | block_allowed_cookie_button_ = gtk_button_new_with_label( |
| 263 | l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_BLOCK_BUTTON).c_str()); |
| 264 | g_signal_connect(block_allowed_cookie_button_, "clicked", |
| 265 | G_CALLBACK(OnBlockAllowedButtonClickedThunk), this); |
| 266 | gtk_container_add(GTK_CONTAINER(button_box), block_allowed_cookie_button_); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 267 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 268 | // Wrap the vbox inside an hbox so that we can specify padding along the |
| 269 | // horizontal axis. |
| 270 | GtkWidget* box = gtk_hbox_new(FALSE, 0); |
| 271 | gtk_box_pack_start(GTK_BOX(box), cookie_list_vbox, TRUE, TRUE, |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 272 | ui::kControlSpacing); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 273 | return box; |
| 274 | } |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 275 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 276 | GtkWidget* CollectedCookiesGtk::CreateBlockedPane() { |
[email protected] | 58d3065 | 2012-06-11 19:56:34 | [diff] [blame] | 277 | PrefService* prefs = tab_contents_->profile()->GetPrefs(); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 278 | |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 279 | GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 280 | |
| 281 | GtkWidget* label = gtk_label_new( |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 282 | l10n_util::GetStringUTF8( |
[email protected] | 30fde82 | 2011-10-28 09:49:05 | [diff] [blame] | 283 | prefs->GetBoolean(prefs::kBlockThirdPartyCookies) ? |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 284 | IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED : |
| 285 | IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL).c_str()); |
| 286 | gtk_widget_set_size_request(label, kTreeViewWidth, -1); |
| 287 | gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 288 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 289 | gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, TRUE, TRUE, |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 290 | ui::kControlSpacing); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 291 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 292 | GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 293 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), |
| 294 | GTK_POLICY_AUTOMATIC, |
| 295 | GTK_POLICY_AUTOMATIC); |
| 296 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll_window), |
| 297 | GTK_SHADOW_ETCHED_IN); |
| 298 | gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0); |
| 299 | |
[email protected] | 58d3065 | 2012-06-11 19:56:34 | [diff] [blame] | 300 | TabSpecificContentSettings* content_settings = |
| 301 | tab_contents_->content_settings(); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 302 | |
[email protected] | b6ef09a | 2012-03-08 21:53:25 | [diff] [blame] | 303 | const LocalSharedObjectsContainer& blocked_lsos = |
[email protected] | af878c1e | 2012-03-06 11:23:54 | [diff] [blame] | 304 | content_settings->blocked_local_shared_objects(); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 305 | blocked_cookies_tree_model_.reset( |
[email protected] | af878c1e | 2012-03-06 11:23:54 | [diff] [blame] | 306 | new CookiesTreeModel(blocked_lsos.cookies()->Clone(), |
| 307 | blocked_lsos.databases()->Clone(), |
| 308 | blocked_lsos.local_storages()->Clone(), |
| 309 | blocked_lsos.session_storages()->Clone(), |
| 310 | blocked_lsos.appcaches()->Clone(), |
| 311 | blocked_lsos.indexed_dbs()->Clone(), |
| 312 | blocked_lsos.file_systems()->Clone(), |
| 313 | NULL, |
[email protected] | acfce00 | 2012-04-06 20:28:10 | [diff] [blame] | 314 | blocked_lsos.server_bound_certs()->Clone(), |
[email protected] | af878c1e | 2012-03-06 11:23:54 | [diff] [blame] | 315 | true)); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 316 | blocked_cookies_tree_adapter_.reset( |
[email protected] | 6d90ee62 | 2010-08-18 07:42:27 | [diff] [blame] | 317 | new gtk_tree::TreeAdapter(this, blocked_cookies_tree_model_.get())); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 318 | blocked_tree_ = gtk_tree_view_new_with_model( |
| 319 | GTK_TREE_MODEL(blocked_cookies_tree_adapter_->tree_store())); |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 320 | gtk_widget_set_size_request(blocked_tree_, kTreeViewWidth, kTreeViewHeight); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 321 | gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(blocked_tree_), FALSE); |
| 322 | gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(blocked_tree_), TRUE); |
| 323 | gtk_container_add(GTK_CONTAINER(scroll_window), blocked_tree_); |
| 324 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 325 | GtkTreeViewColumn* title_column = gtk_tree_view_column_new(); |
| 326 | GtkCellRenderer* pixbuf_renderer = gtk_cell_renderer_pixbuf_new(); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 327 | gtk_tree_view_column_pack_start(title_column, pixbuf_renderer, FALSE); |
| 328 | gtk_tree_view_column_add_attribute(title_column, pixbuf_renderer, "pixbuf", |
[email protected] | 6d90ee62 | 2010-08-18 07:42:27 | [diff] [blame] | 329 | gtk_tree::TreeAdapter::COL_ICON); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 330 | GtkCellRenderer* title_renderer = gtk_cell_renderer_text_new(); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 331 | gtk_tree_view_column_pack_start(title_column, title_renderer, TRUE); |
| 332 | gtk_tree_view_column_add_attribute(title_column, title_renderer, "text", |
[email protected] | 6d90ee62 | 2010-08-18 07:42:27 | [diff] [blame] | 333 | gtk_tree::TreeAdapter::COL_TITLE); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 334 | gtk_tree_view_column_set_title( |
| 335 | title_column, l10n_util::GetStringUTF8( |
| 336 | IDS_COOKIES_DOMAIN_COLUMN_HEADER).c_str()); |
| 337 | gtk_tree_view_append_column(GTK_TREE_VIEW(blocked_tree_), title_column); |
| 338 | g_signal_connect(blocked_tree_, "row-expanded", |
| 339 | G_CALLBACK(OnTreeViewRowExpandedThunk), this); |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 340 | blocked_selection_ = |
| 341 | gtk_tree_view_get_selection(GTK_TREE_VIEW(blocked_tree_)); |
| 342 | gtk_tree_selection_set_mode(blocked_selection_, GTK_SELECTION_MULTIPLE); |
| 343 | g_signal_connect(blocked_selection_, "changed", |
| 344 | G_CALLBACK(OnTreeViewSelectionChangeThunk), this); |
| 345 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 346 | GtkWidget* button_box = gtk_hbutton_box_new(); |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 347 | gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_START); |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 348 | gtk_box_set_spacing(GTK_BOX(button_box), ui::kControlSpacing); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 349 | gtk_box_pack_start(GTK_BOX(cookie_list_vbox), button_box, FALSE, FALSE, |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 350 | ui::kControlSpacing); |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 351 | allow_blocked_cookie_button_ = gtk_button_new_with_label( |
| 352 | l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_ALLOW_BUTTON).c_str()); |
| 353 | g_signal_connect(allow_blocked_cookie_button_, "clicked", |
| 354 | G_CALLBACK(OnAllowBlockedButtonClickedThunk), this); |
| 355 | gtk_container_add(GTK_CONTAINER(button_box), allow_blocked_cookie_button_); |
| 356 | for_session_blocked_cookie_button_ = gtk_button_new_with_label( |
| 357 | l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON). |
| 358 | c_str()); |
| 359 | g_signal_connect(for_session_blocked_cookie_button_, "clicked", |
| 360 | G_CALLBACK(OnForSessionBlockedButtonClickedThunk), this); |
| 361 | gtk_container_add(GTK_CONTAINER(button_box), |
| 362 | for_session_blocked_cookie_button_); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 363 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 364 | // Wrap the vbox inside an hbox so that we can specify padding along the |
| 365 | // horizontal axis. |
| 366 | GtkWidget* box = gtk_hbox_new(FALSE, 0); |
| 367 | gtk_box_pack_start(GTK_BOX(box), cookie_list_vbox, TRUE, TRUE, |
[email protected] | 82c7bfb | 2011-08-29 22:08:58 | [diff] [blame] | 368 | ui::kControlSpacing); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 369 | return box; |
| 370 | } |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 371 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 372 | void CollectedCookiesGtk::ShowCookieInfo(gint current_page) { |
| 373 | if (current_page == kAllowedPageNumber) { |
| 374 | ShowSelectionInfo(allowed_selection_, allowed_cookies_tree_adapter_.get()); |
| 375 | } else if (current_page == kBlockedPageNumber) { |
| 376 | ShowSelectionInfo(blocked_selection_, blocked_cookies_tree_adapter_.get()); |
| 377 | } |
| 378 | } |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 379 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 380 | void CollectedCookiesGtk::ShowSelectionInfo(GtkTreeSelection* selection, |
| 381 | gtk_tree::TreeAdapter* adapter) { |
| 382 | // Check if one "cookie" node is selected. Don't allow more than one. |
| 383 | GtkTreeModel* model; |
| 384 | GList* paths = gtk_tree_selection_get_selected_rows(selection, &model); |
| 385 | if (g_list_length(paths) == 1) { |
| 386 | GList* item = g_list_first(paths); |
| 387 | GtkTreeIter iter; |
| 388 | gtk_tree_model_get_iter(model, &iter, |
| 389 | reinterpret_cast<GtkTreePath*>(item->data)); |
| 390 | CookieTreeNode* node = |
| 391 | static_cast<CookieTreeNode*>(adapter->GetNode(&iter)); |
| 392 | const CookieTreeNode::DetailedInfo detailed_info = node->GetDetailedInfo(); |
| 393 | if (detailed_info.node_type == CookieTreeNode::DetailedInfo::TYPE_COOKIE) { |
| 394 | gtk_chrome_cookie_view_display_cookie( |
| 395 | GTK_CHROME_COOKIE_VIEW(cookie_info_view_), |
| 396 | detailed_info.cookie->Domain(), |
| 397 | *detailed_info.cookie); |
| 398 | } else { |
| 399 | gtk_chrome_cookie_view_clear(GTK_CHROME_COOKIE_VIEW(cookie_info_view_)); |
| 400 | } |
| 401 | } else { |
| 402 | gtk_chrome_cookie_view_clear(GTK_CHROME_COOKIE_VIEW(cookie_info_view_)); |
| 403 | } |
| 404 | |
[email protected] | 6391e4a | 2011-03-21 19:46:38 | [diff] [blame] | 405 | g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 406 | g_list_free(paths); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | CollectedCookiesGtk::~CollectedCookiesGtk() { |
| 410 | gtk_widget_destroy(dialog_); |
| 411 | } |
| 412 | |
| 413 | GtkWidget* CollectedCookiesGtk::GetWidgetRoot() { |
| 414 | return dialog_; |
| 415 | } |
| 416 | |
[email protected] | 5076008b | 2011-02-15 22:58:02 | [diff] [blame] | 417 | GtkWidget* CollectedCookiesGtk::GetFocusWidget() { |
| 418 | return close_button_; |
| 419 | } |
| 420 | |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 421 | void CollectedCookiesGtk::DeleteDelegate() { |
| 422 | delete this; |
| 423 | } |
| 424 | |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 425 | bool CollectedCookiesGtk::SelectionContainsOriginNode( |
| 426 | GtkTreeSelection* selection, gtk_tree::TreeAdapter* adapter) { |
| 427 | // Check whether at least one "origin" node is selected. |
| 428 | GtkTreeModel* model; |
| 429 | GList* paths = |
| 430 | gtk_tree_selection_get_selected_rows(selection, &model); |
| 431 | bool contains_origin_node = false; |
| 432 | for (GList* item = paths; item; item = item->next) { |
| 433 | GtkTreeIter iter; |
| 434 | gtk_tree_model_get_iter( |
| 435 | model, &iter, reinterpret_cast<GtkTreePath*>(item->data)); |
| 436 | CookieTreeNode* node = |
| 437 | static_cast<CookieTreeNode*>(adapter->GetNode(&iter)); |
| 438 | if (node->GetDetailedInfo().node_type != |
| 439 | CookieTreeNode::DetailedInfo::TYPE_ORIGIN) |
| 440 | continue; |
| 441 | CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( |
| 442 | node); |
| 443 | if (!origin_node->CanCreateContentException()) |
| 444 | continue; |
| 445 | contains_origin_node = true; |
| 446 | } |
| 447 | g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
| 448 | g_list_free(paths); |
| 449 | return contains_origin_node; |
| 450 | } |
| 451 | |
| 452 | void CollectedCookiesGtk::EnableControls() { |
| 453 | // Update button states. |
| 454 | bool enable_for_allowed_cookies = |
| 455 | SelectionContainsOriginNode(allowed_selection_, |
| 456 | allowed_cookies_tree_adapter_.get()); |
| 457 | gtk_widget_set_sensitive(block_allowed_cookie_button_, |
| 458 | enable_for_allowed_cookies); |
| 459 | |
| 460 | bool enable_for_blocked_cookies = |
| 461 | SelectionContainsOriginNode(blocked_selection_, |
| 462 | blocked_cookies_tree_adapter_.get()); |
| 463 | gtk_widget_set_sensitive(allow_blocked_cookie_button_, |
| 464 | enable_for_blocked_cookies); |
| 465 | gtk_widget_set_sensitive(for_session_blocked_cookie_button_, |
| 466 | enable_for_blocked_cookies); |
| 467 | } |
| 468 | |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 469 | void CollectedCookiesGtk::Observe(int type, |
[email protected] | 6c2381d | 2011-10-19 02:52:53 | [diff] [blame] | 470 | const content::NotificationSource& source, |
| 471 | const content::NotificationDetails& details) { |
[email protected] | 43211582 | 2011-07-10 15:52:27 | [diff] [blame] | 472 | DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 473 | window_->CloseConstrainedWindow(); |
| 474 | } |
| 475 | |
| 476 | void CollectedCookiesGtk::OnClose(GtkWidget* close_button) { |
[email protected] | 78e049b | 2011-03-19 20:45:26 | [diff] [blame] | 477 | if (status_changed_) { |
[email protected] | 58d3065 | 2012-06-11 19:56:34 | [diff] [blame] | 478 | InfoBarTabHelper* infobar_helper = tab_contents_->infobar_tab_helper(); |
[email protected] | 95a33ed6 | 2011-09-30 15:07:08 | [diff] [blame] | 479 | infobar_helper->AddInfoBar( |
| 480 | new CollectedCookiesInfoBarDelegate(infobar_helper)); |
[email protected] | 78e049b | 2011-03-19 20:45:26 | [diff] [blame] | 481 | } |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 482 | window_->CloseConstrainedWindow(); |
| 483 | } |
| 484 | |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 485 | void CollectedCookiesGtk::AddExceptions(GtkTreeSelection* selection, |
| 486 | gtk_tree::TreeAdapter* adapter, |
| 487 | ContentSetting setting) { |
| 488 | GtkTreeModel* model; |
| 489 | GList* paths = |
| 490 | gtk_tree_selection_get_selected_rows(selection, &model); |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 491 | string16 last_domain_name; |
| 492 | bool multiple_domains_added = false; |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 493 | for (GList* item = paths; item; item = item->next) { |
| 494 | GtkTreeIter iter; |
| 495 | gtk_tree_model_get_iter( |
| 496 | model, &iter, reinterpret_cast<GtkTreePath*>(item->data)); |
[email protected] | bcb0213 | 2010-11-23 14:38:49 | [diff] [blame] | 497 | CookieTreeNode* node = |
| 498 | static_cast<CookieTreeNode*>(adapter->GetNode(&iter)); |
| 499 | if (node->GetDetailedInfo().node_type != |
| 500 | CookieTreeNode::DetailedInfo::TYPE_ORIGIN) |
| 501 | continue; |
| 502 | CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( |
| 503 | node); |
| 504 | if (origin_node->CanCreateContentException()) { |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 505 | if (!last_domain_name.empty()) |
| 506 | multiple_domains_added = true; |
[email protected] | bcb0213 | 2010-11-23 14:38:49 | [diff] [blame] | 507 | last_domain_name = origin_node->GetTitle(); |
[email protected] | 58d3065 | 2012-06-11 19:56:34 | [diff] [blame] | 508 | Profile* profile = tab_contents_->profile(); |
[email protected] | bcb0213 | 2010-11-23 14:38:49 | [diff] [blame] | 509 | origin_node->CreateContentException( |
[email protected] | 67e7999 | 2012-02-13 20:47:58 | [diff] [blame] | 510 | CookieSettings::Factory::GetForProfile(profile), setting); |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 511 | } |
| 512 | } |
| 513 | g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
| 514 | g_list_free(paths); |
[email protected] | df0f6e8 | 2010-08-20 21:35:32 | [diff] [blame] | 515 | if (last_domain_name.empty()) { |
| 516 | gtk_widget_hide(infobar_); |
| 517 | } else { |
| 518 | gtk_label_set_text( |
| 519 | GTK_LABEL(infobar_label_), GetInfobarLabel( |
| 520 | setting, multiple_domains_added, last_domain_name).c_str()); |
| 521 | gtk_widget_show(infobar_); |
| 522 | } |
[email protected] | 78e049b | 2011-03-19 20:45:26 | [diff] [blame] | 523 | status_changed_ = true; |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | void CollectedCookiesGtk::OnBlockAllowedButtonClicked(GtkWidget* button) { |
| 527 | AddExceptions(allowed_selection_, allowed_cookies_tree_adapter_.get(), |
| 528 | CONTENT_SETTING_BLOCK); |
| 529 | } |
| 530 | |
| 531 | void CollectedCookiesGtk::OnAllowBlockedButtonClicked(GtkWidget* button) { |
| 532 | AddExceptions(blocked_selection_, blocked_cookies_tree_adapter_.get(), |
| 533 | CONTENT_SETTING_ALLOW); |
| 534 | } |
| 535 | |
| 536 | void CollectedCookiesGtk::OnForSessionBlockedButtonClicked(GtkWidget* button) { |
| 537 | AddExceptions(blocked_selection_, blocked_cookies_tree_adapter_.get(), |
| 538 | CONTENT_SETTING_SESSION_ONLY); |
| 539 | } |
| 540 | |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 541 | void CollectedCookiesGtk::OnSwitchPage(GtkWidget* notebook, |
| 542 | gpointer page, |
| 543 | guint page_num) { |
| 544 | EnableControls(); |
| 545 | ShowCookieInfo(page_num); |
| 546 | } |
| 547 | |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 548 | void CollectedCookiesGtk::OnTreeViewRowExpanded(GtkWidget* tree_view, |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 549 | GtkTreeIter* iter, |
| 550 | GtkTreePath* path) { |
[email protected] | a503c97c | 2010-07-16 13:05:48 | [diff] [blame] | 551 | // When a row in the tree is expanded, expand all the children too. |
| 552 | g_signal_handlers_block_by_func( |
| 553 | tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
| 554 | gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); |
| 555 | g_signal_handlers_unblock_by_func( |
| 556 | tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
| 557 | } |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 558 | |
| 559 | void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { |
| 560 | EnableControls(); |
[email protected] | 425328c3e | 2011-03-16 15:36:00 | [diff] [blame] | 561 | ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); |
[email protected] | cf9e078 | 2010-07-19 20:49:30 | [diff] [blame] | 562 | } |