OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" | 5 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/api/infobars/infobar_service.h" | 9 #include "chrome/browser/api/infobars/infobar_service.h" |
10 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 TabSpecificContentSettings::FromWebContents(web_contents); | 114 TabSpecificContentSettings::FromWebContents(web_contents); |
115 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, | 115 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, |
116 content::Source<TabSpecificContentSettings>(content_settings)); | 116 content::Source<TabSpecificContentSettings>(content_settings)); |
117 | 117 |
118 Init(); | 118 Init(); |
119 } | 119 } |
120 | 120 |
121 void CollectedCookiesGtk::Init() { | 121 void CollectedCookiesGtk::Init() { |
122 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); | 122 dialog_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing); |
123 gtk_box_set_spacing(GTK_BOX(dialog_), ui::kContentAreaSpacing); | 123 gtk_box_set_spacing(GTK_BOX(dialog_), ui::kContentAreaSpacing); |
| 124 g_signal_connect(dialog_, "destroy", G_CALLBACK(OnDestroyThunk), this); |
124 | 125 |
125 GtkWidget* label = gtk_label_new( | 126 GtkWidget* label = gtk_label_new( |
126 l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_DIALOG_TITLE).c_str()); | 127 l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_DIALOG_TITLE).c_str()); |
127 gtk_box_pack_start(GTK_BOX(dialog_), label, TRUE, TRUE, 0); | 128 gtk_box_pack_start(GTK_BOX(dialog_), label, TRUE, TRUE, 0); |
128 | 129 |
129 notebook_ = gtk_notebook_new(); | 130 notebook_ = gtk_notebook_new(); |
130 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook_), GTK_POS_TOP); | 131 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook_), GTK_POS_TOP); |
131 gtk_box_pack_start(GTK_BOX(dialog_), notebook_, TRUE, TRUE, 0); | 132 gtk_box_pack_start(GTK_BOX(dialog_), notebook_, TRUE, TRUE, 0); |
132 | 133 |
133 GtkWidget* allowed_pane = CreateAllowedPane(); | 134 GtkWidget* allowed_pane = CreateAllowedPane(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 gtk_button_set_label(GTK_BUTTON(close_button_), | 184 gtk_button_set_label(GTK_BUTTON(close_button_), |
184 l10n_util::GetStringUTF8(IDS_CLOSE).c_str()); | 185 l10n_util::GetStringUTF8(IDS_CLOSE).c_str()); |
185 g_signal_connect(close_button_, "clicked", G_CALLBACK(OnCloseThunk), this); | 186 g_signal_connect(close_button_, "clicked", G_CALLBACK(OnCloseThunk), this); |
186 gtk_box_pack_end(GTK_BOX(button_box), close_button_, FALSE, TRUE, 0); | 187 gtk_box_pack_end(GTK_BOX(button_box), close_button_, FALSE, TRUE, 0); |
187 | 188 |
188 // Show the dialog. | 189 // Show the dialog. |
189 allowed_cookies_tree_adapter_->Init(); | 190 allowed_cookies_tree_adapter_->Init(); |
190 blocked_cookies_tree_adapter_->Init(); | 191 blocked_cookies_tree_adapter_->Init(); |
191 EnableControls(); | 192 EnableControls(); |
192 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); | 193 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); |
193 window_ = CreateWebContentsModalDialogGtk(web_contents_, this); | 194 window_ = CreateWebContentsModalDialogGtk(web_contents_, |
| 195 dialog_, |
| 196 close_button_); |
194 | 197 |
195 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 198 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
196 WebContentsModalDialogManager::FromWebContents(web_contents_); | 199 WebContentsModalDialogManager::FromWebContents(web_contents_); |
197 web_contents_modal_dialog_manager->ShowDialog(window_); | 200 web_contents_modal_dialog_manager->ShowDialog(window_); |
198 } | 201 } |
199 | 202 |
200 GtkWidget* CollectedCookiesGtk::CreateAllowedPane() { | 203 GtkWidget* CollectedCookiesGtk::CreateAllowedPane() { |
201 GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); | 204 GtkWidget* cookie_list_vbox = gtk_vbox_new(FALSE, ui::kControlSpacing); |
202 | 205 |
203 GtkWidget* label = gtk_label_new( | 206 GtkWidget* label = gtk_label_new( |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 } | 396 } |
394 | 397 |
395 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); | 398 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
396 g_list_free(paths); | 399 g_list_free(paths); |
397 } | 400 } |
398 | 401 |
399 CollectedCookiesGtk::~CollectedCookiesGtk() { | 402 CollectedCookiesGtk::~CollectedCookiesGtk() { |
400 gtk_widget_destroy(dialog_); | 403 gtk_widget_destroy(dialog_); |
401 } | 404 } |
402 | 405 |
403 GtkWidget* CollectedCookiesGtk::GetWidgetRoot() { | |
404 return dialog_; | |
405 } | |
406 | |
407 GtkWidget* CollectedCookiesGtk::GetFocusWidget() { | |
408 return close_button_; | |
409 } | |
410 | |
411 void CollectedCookiesGtk::DeleteDelegate() { | |
412 delete this; | |
413 } | |
414 | |
415 bool CollectedCookiesGtk::SelectionContainsHostNode( | 406 bool CollectedCookiesGtk::SelectionContainsHostNode( |
416 GtkTreeSelection* selection, gtk_tree::TreeAdapter* adapter) { | 407 GtkTreeSelection* selection, gtk_tree::TreeAdapter* adapter) { |
417 // Check whether at least one "origin" node is selected. | 408 // Check whether at least one "origin" node is selected. |
418 GtkTreeModel* model; | 409 GtkTreeModel* model; |
419 GList* paths = | 410 GList* paths = |
420 gtk_tree_selection_get_selected_rows(selection, &model); | 411 gtk_tree_selection_get_selected_rows(selection, &model); |
421 bool contains_host_node = false; | 412 bool contains_host_node = false; |
422 for (GList* item = paths; item; item = item->next) { | 413 for (GList* item = paths; item; item = item->next) { |
423 GtkTreeIter iter; | 414 GtkTreeIter iter; |
424 gtk_tree_model_get_iter( | 415 gtk_tree_model_get_iter( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 534 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
544 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); | 535 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); |
545 g_signal_handlers_unblock_by_func( | 536 g_signal_handlers_unblock_by_func( |
546 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 537 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
547 } | 538 } |
548 | 539 |
549 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { | 540 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { |
550 EnableControls(); | 541 EnableControls(); |
551 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); | 542 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); |
552 } | 543 } |
| 544 |
| 545 void CollectedCookiesGtk::OnDestroy(GtkWidget* widget) { |
| 546 delete this; |
| 547 } |
OLD | NEW |