| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // This is the Gtk implementation of the collected Cookies dialog. | |
| 6 | |
| 7 #ifndef CHROME_BROWSER_UI_GTK_COLLECTED_COOKIES_GTK_H_ | |
| 8 #define CHROME_BROWSER_UI_GTK_COLLECTED_COOKIES_GTK_H_ | |
| 9 | |
| 10 #include <gtk/gtk.h> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "chrome/browser/ui/gtk/constrained_window_gtk.h" | |
| 15 #include "chrome/browser/ui/gtk/gtk_tree.h" | |
| 16 #include "chrome/common/content_settings.h" | |
| 17 #include "content/public/browser/notification_observer.h" | |
| 18 #include "content/public/browser/notification_registrar.h" | |
| 19 #include "ui/base/gtk/gtk_signal.h" | |
| 20 | |
| 21 class CookiesTreeModel; | |
| 22 | |
| 23 namespace content { | |
| 24 class WebContents; | |
| 25 } | |
| 26 | |
| 27 // CollectedCookiesGtk is a dialog that displays the allowed and blocked | |
| 28 // cookies of the current tab contents. To display the dialog, invoke | |
| 29 // ShowCollectedCookiesDialog() on the delegate of the web contents's | |
| 30 // content settings tab helper. | |
| 31 | |
| 32 class CollectedCookiesGtk : public gtk_tree::TreeAdapter::Delegate, | |
| 33 public content::NotificationObserver { | |
| 34 public: | |
| 35 CollectedCookiesGtk(GtkWindow* parent, content::WebContents* web_contents); | |
| 36 | |
| 37 private: | |
| 38 virtual ~CollectedCookiesGtk(); | |
| 39 | |
| 40 // Initialize all widgets of this dialog. | |
| 41 void Init(); | |
| 42 | |
| 43 // True if the selection contains at least one host node. | |
| 44 bool SelectionContainsHostNode(GtkTreeSelection* selection, | |
| 45 gtk_tree::TreeAdapter* adapter); | |
| 46 | |
| 47 // Enable the allow/block buttons if at least one host node is selected. | |
| 48 void EnableControls(); | |
| 49 | |
| 50 // Add exceptions for all origin nodes within the selection. | |
| 51 void AddExceptions(GtkTreeSelection* selection, | |
| 52 gtk_tree::TreeAdapter* adapter, | |
| 53 ContentSetting setting); | |
| 54 | |
| 55 // Notification Observer implementation. | |
| 56 virtual void Observe(int type, | |
| 57 const content::NotificationSource& source, | |
| 58 const content::NotificationDetails& details) OVERRIDE; | |
| 59 | |
| 60 // Create the information panes for the allowed and blocked cookies. | |
| 61 GtkWidget* CreateAllowedPane(); | |
| 62 GtkWidget* CreateBlockedPane(); | |
| 63 | |
| 64 // Show information about selected cookie in the cookie info view. | |
| 65 void ShowCookieInfo(gint current_page); | |
| 66 void ShowSelectionInfo(GtkTreeSelection* selection, | |
| 67 gtk_tree::TreeAdapter* adapter); | |
| 68 | |
| 69 | |
| 70 // Callbacks. | |
| 71 CHROMEGTK_CALLBACK_2(CollectedCookiesGtk, void, OnTreeViewRowExpanded, | |
| 72 GtkTreeIter*, GtkTreePath*); | |
| 73 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnTreeViewSelectionChange); | |
| 74 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnClose); | |
| 75 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnBlockAllowedButtonClicked); | |
| 76 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnDeleteAllowedButtonClicked); | |
| 77 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnAllowBlockedButtonClicked); | |
| 78 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, | |
| 79 OnForSessionBlockedButtonClicked); | |
| 80 CHROMEGTK_CALLBACK_2(CollectedCookiesGtk, void, OnSwitchPage, | |
| 81 gpointer, guint); | |
| 82 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnDestroy); | |
| 83 | |
| 84 content::NotificationRegistrar registrar_; | |
| 85 | |
| 86 GtkWidget* window_; | |
| 87 | |
| 88 // Widgets of the dialog. | |
| 89 GtkWidget* dialog_; | |
| 90 | |
| 91 GtkWidget* allowed_description_label_; | |
| 92 GtkWidget* blocked_description_label_; | |
| 93 | |
| 94 GtkWidget* block_allowed_cookie_button_; | |
| 95 GtkWidget* delete_allowed_cookie_button_; | |
| 96 | |
| 97 GtkWidget* allow_blocked_cookie_button_; | |
| 98 GtkWidget* for_session_blocked_cookie_button_; | |
| 99 GtkWidget* close_button_; | |
| 100 | |
| 101 // The table listing the cookies. | |
| 102 GtkWidget* notebook_; | |
| 103 GtkWidget* allowed_tree_; | |
| 104 GtkWidget* blocked_tree_; | |
| 105 | |
| 106 GtkTreeSelection* allowed_selection_; | |
| 107 GtkTreeSelection* blocked_selection_; | |
| 108 | |
| 109 // The infobar widget. | |
| 110 GtkWidget* infobar_; | |
| 111 GtkWidget* infobar_label_; | |
| 112 | |
| 113 // Displays information about selected cookie. | |
| 114 GtkWidget* cookie_info_view_; | |
| 115 | |
| 116 // The web contents. | |
| 117 content::WebContents* web_contents_; | |
| 118 | |
| 119 bool status_changed_; | |
| 120 | |
| 121 // The Cookies Table model. | |
| 122 scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_; | |
| 123 scoped_ptr<CookiesTreeModel> blocked_cookies_tree_model_; | |
| 124 scoped_ptr<gtk_tree::TreeAdapter> allowed_cookies_tree_adapter_; | |
| 125 scoped_ptr<gtk_tree::TreeAdapter> blocked_cookies_tree_adapter_; | |
| 126 | |
| 127 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesGtk); | |
| 128 }; | |
| 129 | |
| 130 #endif // CHROME_BROWSER_UI_GTK_COLLECTED_COOKIES_GTK_H_ | |
| OLD | NEW |