OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // This is the Gtk implementation of the collected Cookies dialog. | 5 // This is the Gtk implementation of the collected Cookies dialog. |
6 | 6 |
7 #ifndef CHROME_BROWSER_GTK_COLLECTED_COOKIES_GTK_H_ | 7 #ifndef CHROME_BROWSER_GTK_COLLECTED_COOKIES_GTK_H_ |
8 #define CHROME_BROWSER_GTK_COLLECTED_COOKIES_GTK_H_ | 8 #define CHROME_BROWSER_GTK_COLLECTED_COOKIES_GTK_H_ |
9 | 9 |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
11 | 11 |
12 #include "app/gtk_signal.h" | 12 #include "app/gtk_signal.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "chrome/browser/gtk/constrained_window_gtk.h" | 14 #include "chrome/browser/gtk/constrained_window_gtk.h" |
15 #include "chrome/browser/gtk/gtk_tree.h" | 15 #include "chrome/browser/gtk/gtk_tree.h" |
| 16 #include "chrome/common/content_settings.h" |
16 #include "chrome/common/notification_registrar.h" | 17 #include "chrome/common/notification_registrar.h" |
17 | 18 |
18 class CookiesTreeModel; | 19 class CookiesTreeModel; |
19 | 20 |
20 // CollectedCookiesGtk is a dialog that displays the allowed and blocked | 21 // CollectedCookiesGtk is a dialog that displays the allowed and blocked |
21 // cookies of the current tab contents. To display the dialog, invoke | 22 // cookies of the current tab contents. To display the dialog, invoke |
22 // ShowCollectedCookiesDialog() on the delegate of the tab contents. | 23 // ShowCollectedCookiesDialog() on the delegate of the tab contents. |
23 | 24 |
24 class CollectedCookiesGtk : public ConstrainedDialogDelegate, | 25 class CollectedCookiesGtk : public ConstrainedDialogDelegate, |
25 gtk_tree::TreeAdapter::Delegate, | 26 gtk_tree::TreeAdapter::Delegate, |
26 NotificationObserver { | 27 NotificationObserver { |
27 public: | 28 public: |
28 CollectedCookiesGtk(GtkWindow* parent, TabContents* tab_contents); | 29 CollectedCookiesGtk(GtkWindow* parent, TabContents* tab_contents); |
29 | 30 |
30 // ConstrainedDialogDelegate methods. | 31 // ConstrainedDialogDelegate methods. |
31 virtual GtkWidget* GetWidgetRoot(); | 32 virtual GtkWidget* GetWidgetRoot(); |
32 virtual void DeleteDelegate(); | 33 virtual void DeleteDelegate(); |
33 | 34 |
34 private: | 35 private: |
35 virtual ~CollectedCookiesGtk(); | 36 virtual ~CollectedCookiesGtk(); |
36 | 37 |
| 38 // Initialize all widgets of this dialog. |
37 void Init(); | 39 void Init(); |
38 | 40 |
| 41 // True if the selection contains at least one origin node. |
| 42 bool SelectionContainsOriginNode(GtkTreeSelection* selection, |
| 43 gtk_tree::TreeAdapter* adapter); |
| 44 |
| 45 // Enable the allow/block buttons if at least one origin node is selected. |
| 46 void EnableControls(); |
| 47 |
| 48 // Add exceptions for all origin nodes within the selection. |
| 49 void AddExceptions(GtkTreeSelection* selection, |
| 50 gtk_tree::TreeAdapter* adapter, |
| 51 ContentSetting setting); |
| 52 |
39 // Notification Observer implementation. | 53 // Notification Observer implementation. |
40 void Observe(NotificationType type, | 54 void Observe(NotificationType type, |
41 const NotificationSource& source, | 55 const NotificationSource& source, |
42 const NotificationDetails& details); | 56 const NotificationDetails& details); |
43 | 57 |
44 // Callbacks. | 58 // Callbacks. |
45 CHROMEGTK_CALLBACK_2(CollectedCookiesGtk, void, OnTreeViewRowExpanded, | 59 CHROMEGTK_CALLBACK_2(CollectedCookiesGtk, void, OnTreeViewRowExpanded, |
46 GtkTreeIter*, GtkTreePath*); | 60 GtkTreeIter*, GtkTreePath*); |
| 61 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnTreeViewSelectionChange); |
47 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnClose); | 62 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnClose); |
| 63 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnBlockAllowedButtonClicked); |
| 64 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnAllowBlockedButtonClicked); |
| 65 CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, |
| 66 OnForSessionBlockedButtonClicked); |
48 | 67 |
49 NotificationRegistrar registrar_; | 68 NotificationRegistrar registrar_; |
50 | 69 |
51 ConstrainedWindow* window_; | 70 ConstrainedWindow* window_; |
52 | 71 |
53 // Widgets of the dialog. | 72 // Widgets of the dialog. |
54 GtkWidget* dialog_; | 73 GtkWidget* dialog_; |
55 | 74 |
56 GtkWidget* allowed_description_label_; | 75 GtkWidget* allowed_description_label_; |
57 GtkWidget* blocked_description_label_; | 76 GtkWidget* blocked_description_label_; |
58 | 77 |
| 78 GtkWidget* block_allowed_cookie_button_; |
| 79 |
| 80 GtkWidget* allow_blocked_cookie_button_; |
| 81 GtkWidget* for_session_blocked_cookie_button_; |
| 82 |
59 // The table listing the cookies. | 83 // The table listing the cookies. |
60 GtkWidget* allowed_tree_; | 84 GtkWidget* allowed_tree_; |
61 GtkWidget* blocked_tree_; | 85 GtkWidget* blocked_tree_; |
62 | 86 |
63 GtkWidget* allowed_cookie_display_; | 87 GtkTreeSelection* allowed_selection_; |
64 GtkWidget* blocked_cookie_display_; | 88 GtkTreeSelection* blocked_selection_; |
65 | 89 |
66 // The tab contents. | 90 // The tab contents. |
67 TabContents* tab_contents_; | 91 TabContents* tab_contents_; |
68 | 92 |
69 // The Cookies Table model. | 93 // The Cookies Table model. |
70 scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_; | 94 scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_; |
71 scoped_ptr<CookiesTreeModel> blocked_cookies_tree_model_; | 95 scoped_ptr<CookiesTreeModel> blocked_cookies_tree_model_; |
72 scoped_ptr<gtk_tree::TreeAdapter> allowed_cookies_tree_adapter_; | 96 scoped_ptr<gtk_tree::TreeAdapter> allowed_cookies_tree_adapter_; |
73 scoped_ptr<gtk_tree::TreeAdapter> blocked_cookies_tree_adapter_; | 97 scoped_ptr<gtk_tree::TreeAdapter> blocked_cookies_tree_adapter_; |
74 | 98 |
75 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesGtk); | 99 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesGtk); |
76 }; | 100 }; |
77 | 101 |
78 #endif // CHROME_BROWSER_GTK_COLLECTED_COOKIES_GTK_H_ | 102 #endif // CHROME_BROWSER_GTK_COLLECTED_COOKIES_GTK_H_ |
OLD | NEW |