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