OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 Cookie Manager dialog. | 5 // This is the Gtk implementation of the Cookie Manager dialog. |
6 | 6 |
7 #ifndef CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ | 7 #ifndef CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ |
8 #define CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ | 8 #define CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ |
9 | 9 |
10 #include <gtk/gtk.h> | 10 #include <gtk/gtk.h> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
14 #include "base/task.h" | 14 #include "base/task.h" |
| 15 #include "chrome/browser/browsing_data_local_storage_helper.h" |
15 #include "chrome/common/gtk_tree.h" | 16 #include "chrome/common/gtk_tree.h" |
16 #include "net/base/cookie_monster.h" | 17 #include "net/base/cookie_monster.h" |
17 #include "testing/gtest/include/gtest/gtest_prod.h" | 18 #include "testing/gtest/include/gtest/gtest_prod.h" |
18 | 19 |
19 class CookiesTreeModel; | 20 class CookiesTreeModel; |
20 class CookiesViewTest; | 21 class CookiesViewTest; |
21 class Profile; | 22 class Profile; |
22 | 23 |
23 // CookiesView is thread-hostile, and should only be called on the UI thread. | 24 // CookiesView is thread-hostile, and should only be called on the UI thread. |
24 // Usage: | 25 // Usage: |
25 // CookiesView::Show(profile); | 26 // CookiesView::Show(profile); |
26 // Once the CookiesView is shown, it is responsible for deleting itself when the | 27 // Once the CookiesView is shown, it is responsible for deleting itself when the |
27 // user closes the dialog. | 28 // user closes the dialog. |
28 | 29 |
29 class CookiesView : public gtk_tree::TreeAdapter::Delegate { | 30 class CookiesView : public gtk_tree::TreeAdapter::Delegate { |
30 public: | 31 public: |
31 virtual ~CookiesView(); | 32 virtual ~CookiesView(); |
32 | 33 |
33 // Create (if necessary) and show the cookie manager window. | 34 // Create (if necessary) and show the cookie manager window. |
34 static void Show(Profile* profile); | 35 static void Show( |
| 36 Profile* profile, |
| 37 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper); |
35 | 38 |
36 // gtk_tree::TreeAdapter::Delegate implementation. | 39 // gtk_tree::TreeAdapter::Delegate implementation. |
37 virtual void OnAnyModelUpdateStart(); | 40 virtual void OnAnyModelUpdateStart(); |
38 virtual void OnAnyModelUpdate(); | 41 virtual void OnAnyModelUpdate(); |
39 | 42 |
40 private: | 43 private: |
41 explicit CookiesView(Profile* profile); | 44 CookiesView( |
| 45 Profile* profile, |
| 46 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper); |
42 | 47 |
43 // Initialize the dialog contents and layout. | 48 // Initialize the dialog contents and layout. |
44 void Init(); | 49 void Init(); |
45 | 50 |
46 // Initialize the widget styles and display the dialog. | 51 // Initialize the widget styles and display the dialog. |
47 void InitStylesAndShow(); | 52 void InitStylesAndShow(); |
48 | 53 |
49 // Helper for initializing cookie details table. | 54 // Helper for initializing cookie / local storage details table. |
50 void InitCookieDetailRow(int row, int label_id, GtkWidget** display_label); | 55 void InitDetailRow(int row, int label_id, |
| 56 GtkWidget* details_table, GtkWidget** display_label); |
51 | 57 |
52 // Set the initial selection and tree expanded state. | 58 // Set the initial selection and tree expanded state. |
53 void SetInitialTreeState(); | 59 void SetInitialTreeState(); |
54 | 60 |
55 // Set sensitivity of buttons based on selection and filter state. | 61 // Set sensitivity of buttons based on selection and filter state. |
56 void EnableControls(); | 62 void EnableControls(); |
57 | 63 |
58 // Set sensitivity of cookie details. | 64 // Set sensitivity of cookie details. |
59 void SetCookieDetailsSensitivity(gboolean enabled); | 65 void SetCookieDetailsSensitivity(gboolean enabled); |
60 | 66 |
| 67 // Set sensitivity of local storage details. |
| 68 void SetLocalStorageDetailsSensitivity(gboolean enabled); |
| 69 |
61 // Show the details of the currently selected cookie. | 70 // Show the details of the currently selected cookie. |
62 void PopulateCookieDetails(const std::string& domain, | 71 void PopulateCookieDetails(const std::string& domain, |
63 const net::CookieMonster::CanonicalCookie& cookie); | 72 const net::CookieMonster::CanonicalCookie& cookie); |
64 | 73 |
| 74 // Show the details of the currently selected local storage. |
| 75 void PopulateLocalStorageDetails( |
| 76 const BrowsingDataLocalStorageHelper::LocalStorageInfo& |
| 77 local_storage_info); |
| 78 |
65 // Reset the cookie details display. | 79 // Reset the cookie details display. |
66 void ClearCookieDetails(); | 80 void ClearCookieDetails(); |
67 | 81 |
68 // Remove any cookies that are currently selected. | 82 // Remove any cookies that are currently selected. |
69 void RemoveSelectedItems(); | 83 void RemoveSelectedItems(); |
70 | 84 |
71 // Callback for dialog buttons. | 85 // Callback for dialog buttons. |
72 static void OnResponse(GtkDialog* dialog, int response_id, | 86 static void OnResponse(GtkDialog* dialog, int response_id, |
73 CookiesView* window); | 87 CookiesView* window); |
74 | 88 |
75 // Callback for window destruction. | 89 // Callback for window destruction. |
76 static void OnWindowDestroy(GtkWidget* widget, CookiesView* window); | 90 static void OnWindowDestroy(GtkWidget* widget, CookiesView* window); |
77 | 91 |
78 // Callback for when user selects something in the table. | 92 // Callback for when user selects something in the table. |
79 static void OnSelectionChanged(GtkTreeSelection *selection, | 93 static void OnSelectionChanged(GtkTreeSelection *selection, |
80 CookiesView* window); | 94 CookiesView* window); |
81 | 95 |
82 // Callback for when user presses a key with the table focused. | 96 // Callback for when user presses a key with the table focused. |
83 static gboolean OnTreeViewKeyPress(GtkWidget* tree_view, GdkEventKey* key, | 97 static gboolean OnTreeViewKeyPress(GtkWidget* tree_view, GdkEventKey* key, |
84 CookiesView* window); | 98 CookiesView* window); |
85 | 99 |
86 // Callback when user expands a row in the table. | 100 // Callback when user expands a row in the table. |
87 static void OnTreeViewRowExpanded(GtkTreeView* tree_view, GtkTreeIter* iter, | 101 static void OnTreeViewRowExpanded(GtkTreeView* tree_view, GtkTreeIter* iter, |
88 GtkTreePath* path, gpointer user_data); | 102 GtkTreePath* path, gpointer user_data); |
89 | 103 |
90 // Filter the list against the text in |filter_entry_|. | 104 // Filter the list against the text in |filter_entry_|. |
91 void UpdateFilterResults(); | 105 void UpdateFilterResults(); |
92 | 106 |
| 107 // Sets which of the detailed info table is visible. |
| 108 void UpdateVisibleDetailedInfo(GtkWidget* table); |
| 109 |
93 // Callbacks for user actions filtering the list. | 110 // Callbacks for user actions filtering the list. |
94 static void OnFilterEntryActivated(GtkEntry* entry, CookiesView* window); | 111 static void OnFilterEntryActivated(GtkEntry* entry, CookiesView* window); |
95 static void OnFilterEntryChanged(GtkEditable* editable, CookiesView* window); | 112 static void OnFilterEntryChanged(GtkEditable* editable, CookiesView* window); |
96 static void OnFilterClearButtonClicked(GtkButton* button, | 113 static void OnFilterClearButtonClicked(GtkButton* button, |
97 CookiesView* window); | 114 CookiesView* window); |
98 | 115 |
99 // The parent widget. | 116 // The parent widget. |
100 GtkWidget* dialog_; | 117 GtkWidget* dialog_; |
101 | 118 |
102 // Widgets of the dialog. | 119 // Widgets of the dialog. |
(...skipping 10 matching lines...) Expand all Loading... |
113 // The cookie details widgets. | 130 // The cookie details widgets. |
114 GtkWidget* cookie_details_table_; | 131 GtkWidget* cookie_details_table_; |
115 GtkWidget* cookie_name_entry_; | 132 GtkWidget* cookie_name_entry_; |
116 GtkWidget* cookie_content_entry_; | 133 GtkWidget* cookie_content_entry_; |
117 GtkWidget* cookie_domain_entry_; | 134 GtkWidget* cookie_domain_entry_; |
118 GtkWidget* cookie_path_entry_; | 135 GtkWidget* cookie_path_entry_; |
119 GtkWidget* cookie_send_for_entry_; | 136 GtkWidget* cookie_send_for_entry_; |
120 GtkWidget* cookie_created_entry_; | 137 GtkWidget* cookie_created_entry_; |
121 GtkWidget* cookie_expires_entry_; | 138 GtkWidget* cookie_expires_entry_; |
122 | 139 |
| 140 // The local storage details widgets. |
| 141 GtkWidget* local_storage_details_table_; |
| 142 GtkWidget* local_storage_origin_entry_; |
| 143 GtkWidget* local_storage_size_entry_; |
| 144 GtkWidget* local_storage_last_modified_entry_; |
| 145 |
123 // The profile. | 146 // The profile. |
124 Profile* profile_; | 147 Profile* profile_; |
125 | 148 |
| 149 // Local Storage Helper. |
| 150 scoped_refptr<BrowsingDataLocalStorageHelper> |
| 151 browsing_data_local_storage_helper_; |
| 152 |
126 // A factory to construct Runnable Methods so that we can be called back to | 153 // A factory to construct Runnable Methods so that we can be called back to |
127 // re-evaluate the model after the search query string changes. | 154 // re-evaluate the model after the search query string changes. |
128 ScopedRunnableMethodFactory<CookiesView> filter_update_factory_; | 155 ScopedRunnableMethodFactory<CookiesView> filter_update_factory_; |
129 | 156 |
130 // The Cookies Table model. | 157 // The Cookies Table model. |
131 scoped_ptr<CookiesTreeModel> cookies_tree_model_; | 158 scoped_ptr<CookiesTreeModel> cookies_tree_model_; |
132 scoped_ptr<gtk_tree::TreeAdapter> cookies_tree_adapter_; | 159 scoped_ptr<gtk_tree::TreeAdapter> cookies_tree_adapter_; |
133 | 160 |
134 friend class CookiesViewTest; | 161 friend class CookiesViewTest; |
135 FRIEND_TEST(CookiesViewTest, Empty); | 162 FRIEND_TEST(CookiesViewTest, Empty); |
136 FRIEND_TEST(CookiesViewTest, Noop); | 163 FRIEND_TEST(CookiesViewTest, Noop); |
137 FRIEND_TEST(CookiesViewTest, RemoveAll); | 164 FRIEND_TEST(CookiesViewTest, RemoveAll); |
138 FRIEND_TEST(CookiesViewTest, RemoveAllWithDefaultSelected); | 165 FRIEND_TEST(CookiesViewTest, RemoveAllWithDefaultSelected); |
139 FRIEND_TEST(CookiesViewTest, Remove); | 166 FRIEND_TEST(CookiesViewTest, Remove); |
140 FRIEND_TEST(CookiesViewTest, RemoveCookiesByDomain); | 167 FRIEND_TEST(CookiesViewTest, RemoveCookiesByDomain); |
141 FRIEND_TEST(CookiesViewTest, RemoveByDomain); | 168 FRIEND_TEST(CookiesViewTest, RemoveByDomain); |
142 FRIEND_TEST(CookiesViewTest, RemoveDefaultSelection); | 169 FRIEND_TEST(CookiesViewTest, RemoveDefaultSelection); |
143 FRIEND_TEST(CookiesViewTest, Filter); | 170 FRIEND_TEST(CookiesViewTest, Filter); |
144 FRIEND_TEST(CookiesViewTest, FilterRemoveAll); | 171 FRIEND_TEST(CookiesViewTest, FilterRemoveAll); |
145 FRIEND_TEST(CookiesViewTest, FilterRemove); | 172 FRIEND_TEST(CookiesViewTest, FilterRemove); |
146 | 173 |
147 DISALLOW_COPY_AND_ASSIGN(CookiesView); | 174 DISALLOW_COPY_AND_ASSIGN(CookiesView); |
148 }; | 175 }; |
149 | 176 |
150 #endif // CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ | 177 #endif // CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ |
OLD | NEW |