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: |
(...skipping 14 matching lines...) Expand all Loading... |
39 | 40 |
40 private: | 41 private: |
41 explicit CookiesView(Profile* profile); | 42 explicit CookiesView(Profile* profile); |
42 | 43 |
43 // Initialize the dialog contents and layout. | 44 // Initialize the dialog contents and layout. |
44 void Init(); | 45 void Init(); |
45 | 46 |
46 // Initialize the widget styles and display the dialog. | 47 // Initialize the widget styles and display the dialog. |
47 void InitStylesAndShow(); | 48 void InitStylesAndShow(); |
48 | 49 |
49 // Helper for initializing cookie details table. | 50 // Helper for initializing cookie / local storage details table. |
50 void InitCookieDetailRow(int row, int label_id, GtkWidget** display_label); | 51 void InitDetailRow(int row, int label_id, |
| 52 GtkWidget* details_table, GtkWidget** display_label); |
51 | 53 |
52 // Set the initial selection and tree expanded state. | 54 // Set the initial selection and tree expanded state. |
53 void SetInitialTreeState(); | 55 void SetInitialTreeState(); |
54 | 56 |
55 // Set sensitivity of buttons based on selection and filter state. | 57 // Set sensitivity of buttons based on selection and filter state. |
56 void EnableControls(); | 58 void EnableControls(); |
57 | 59 |
58 // Set sensitivity of cookie details. | 60 // Set sensitivity of cookie details. |
59 void SetCookieDetailsSensitivity(gboolean enabled); | 61 void SetCookieDetailsSensitivity(gboolean enabled); |
60 | 62 |
| 63 // Set sensitivity of local storage details. |
| 64 void SetLocalStorageDetailsSensitivity(gboolean enabled); |
| 65 |
61 // Show the details of the currently selected cookie. | 66 // Show the details of the currently selected cookie. |
62 void PopulateCookieDetails(const std::string& domain, | 67 void PopulateCookieDetails(const std::string& domain, |
63 const net::CookieMonster::CanonicalCookie& cookie); | 68 const net::CookieMonster::CanonicalCookie& cookie); |
64 | 69 |
| 70 // Show the details of the currently selected local storage. |
| 71 void PopulateLocalStorageDetails( |
| 72 const BrowsingDataLocalStorageHelper::LocalStorageInfo& |
| 73 local_storage_info); |
| 74 |
65 // Reset the cookie details display. | 75 // Reset the cookie details display. |
66 void ClearCookieDetails(); | 76 void ClearCookieDetails(); |
67 | 77 |
68 // Remove any cookies that are currently selected. | 78 // Remove any cookies that are currently selected. |
69 void RemoveSelectedItems(); | 79 void RemoveSelectedItems(); |
70 | 80 |
71 // Callback for dialog buttons. | 81 // Callback for dialog buttons. |
72 static void OnResponse(GtkDialog* dialog, int response_id, | 82 static void OnResponse(GtkDialog* dialog, int response_id, |
73 CookiesView* window); | 83 CookiesView* window); |
74 | 84 |
75 // Callback for window destruction. | 85 // Callback for window destruction. |
76 static void OnWindowDestroy(GtkWidget* widget, CookiesView* window); | 86 static void OnWindowDestroy(GtkWidget* widget, CookiesView* window); |
77 | 87 |
78 // Callback for when user selects something in the table. | 88 // Callback for when user selects something in the table. |
79 static void OnSelectionChanged(GtkTreeSelection *selection, | 89 static void OnSelectionChanged(GtkTreeSelection *selection, |
80 CookiesView* window); | 90 CookiesView* window); |
81 | 91 |
82 // Callback for when user presses a key with the table focused. | 92 // Callback for when user presses a key with the table focused. |
83 static gboolean OnTreeViewKeyPress(GtkWidget* tree_view, GdkEventKey* key, | 93 static gboolean OnTreeViewKeyPress(GtkWidget* tree_view, GdkEventKey* key, |
84 CookiesView* window); | 94 CookiesView* window); |
85 | 95 |
86 // Callback when user expands a row in the table. | 96 // Callback when user expands a row in the table. |
87 static void OnTreeViewRowExpanded(GtkTreeView* tree_view, GtkTreeIter* iter, | 97 static void OnTreeViewRowExpanded(GtkTreeView* tree_view, GtkTreeIter* iter, |
88 GtkTreePath* path, gpointer user_data); | 98 GtkTreePath* path, gpointer user_data); |
89 | 99 |
90 // Filter the list against the text in |filter_entry_|. | 100 // Filter the list against the text in |filter_entry_|. |
91 void UpdateFilterResults(); | 101 void UpdateFilterResults(); |
92 | 102 |
| 103 // Sets which of the detailed info table is visible. |
| 104 void UpdateVisibleDetailedInfo(GtkWidget* table); |
| 105 |
93 // Callbacks for user actions filtering the list. | 106 // Callbacks for user actions filtering the list. |
94 static void OnFilterEntryActivated(GtkEntry* entry, CookiesView* window); | 107 static void OnFilterEntryActivated(GtkEntry* entry, CookiesView* window); |
95 static void OnFilterEntryChanged(GtkEditable* editable, CookiesView* window); | 108 static void OnFilterEntryChanged(GtkEditable* editable, CookiesView* window); |
96 static void OnFilterClearButtonClicked(GtkButton* button, | 109 static void OnFilterClearButtonClicked(GtkButton* button, |
97 CookiesView* window); | 110 CookiesView* window); |
98 | 111 |
99 // The parent widget. | 112 // The parent widget. |
100 GtkWidget* dialog_; | 113 GtkWidget* dialog_; |
101 | 114 |
102 // Widgets of the dialog. | 115 // Widgets of the dialog. |
(...skipping 10 matching lines...) Expand all Loading... |
113 // The cookie details widgets. | 126 // The cookie details widgets. |
114 GtkWidget* cookie_details_table_; | 127 GtkWidget* cookie_details_table_; |
115 GtkWidget* cookie_name_entry_; | 128 GtkWidget* cookie_name_entry_; |
116 GtkWidget* cookie_content_entry_; | 129 GtkWidget* cookie_content_entry_; |
117 GtkWidget* cookie_domain_entry_; | 130 GtkWidget* cookie_domain_entry_; |
118 GtkWidget* cookie_path_entry_; | 131 GtkWidget* cookie_path_entry_; |
119 GtkWidget* cookie_send_for_entry_; | 132 GtkWidget* cookie_send_for_entry_; |
120 GtkWidget* cookie_created_entry_; | 133 GtkWidget* cookie_created_entry_; |
121 GtkWidget* cookie_expires_entry_; | 134 GtkWidget* cookie_expires_entry_; |
122 | 135 |
| 136 // The local storage details widgets. |
| 137 GtkWidget* local_storage_details_table_; |
| 138 GtkWidget* local_storage_origin_entry_; |
| 139 GtkWidget* local_storage_size_entry_; |
| 140 GtkWidget* local_storage_last_modified_entry_; |
| 141 |
123 // The profile. | 142 // The profile. |
124 Profile* profile_; | 143 Profile* profile_; |
125 | 144 |
126 // A factory to construct Runnable Methods so that we can be called back to | 145 // 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. | 146 // re-evaluate the model after the search query string changes. |
128 ScopedRunnableMethodFactory<CookiesView> filter_update_factory_; | 147 ScopedRunnableMethodFactory<CookiesView> filter_update_factory_; |
129 | 148 |
130 // The Cookies Table model. | 149 // The Cookies Table model. |
131 scoped_ptr<CookiesTreeModel> cookies_tree_model_; | 150 scoped_ptr<CookiesTreeModel> cookies_tree_model_; |
132 scoped_ptr<gtk_tree::TreeAdapter> cookies_tree_adapter_; | 151 scoped_ptr<gtk_tree::TreeAdapter> cookies_tree_adapter_; |
133 | 152 |
134 friend class CookiesViewTest; | 153 friend class CookiesViewTest; |
135 FRIEND_TEST(CookiesViewTest, Empty); | 154 FRIEND_TEST(CookiesViewTest, Empty); |
136 FRIEND_TEST(CookiesViewTest, Noop); | 155 FRIEND_TEST(CookiesViewTest, Noop); |
137 FRIEND_TEST(CookiesViewTest, RemoveAll); | 156 FRIEND_TEST(CookiesViewTest, RemoveAll); |
138 FRIEND_TEST(CookiesViewTest, RemoveAllWithDefaultSelected); | 157 FRIEND_TEST(CookiesViewTest, RemoveAllWithDefaultSelected); |
139 FRIEND_TEST(CookiesViewTest, Remove); | 158 FRIEND_TEST(CookiesViewTest, Remove); |
140 FRIEND_TEST(CookiesViewTest, RemoveCookiesByDomain); | 159 FRIEND_TEST(CookiesViewTest, RemoveCookiesByDomain); |
141 FRIEND_TEST(CookiesViewTest, RemoveByDomain); | 160 FRIEND_TEST(CookiesViewTest, RemoveByDomain); |
142 FRIEND_TEST(CookiesViewTest, RemoveDefaultSelection); | 161 FRIEND_TEST(CookiesViewTest, RemoveDefaultSelection); |
143 FRIEND_TEST(CookiesViewTest, Filter); | 162 FRIEND_TEST(CookiesViewTest, Filter); |
144 FRIEND_TEST(CookiesViewTest, FilterRemoveAll); | 163 FRIEND_TEST(CookiesViewTest, FilterRemoveAll); |
145 FRIEND_TEST(CookiesViewTest, FilterRemove); | 164 FRIEND_TEST(CookiesViewTest, FilterRemove); |
146 | 165 |
147 DISALLOW_COPY_AND_ASSIGN(CookiesView); | 166 DISALLOW_COPY_AND_ASSIGN(CookiesView); |
148 }; | 167 }; |
149 | 168 |
150 #endif // CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ | 169 #endif // CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ |
OLD | NEW |