| 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 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_appcache_helper.h" |
| 15 #include "chrome/browser/browsing_data_database_helper.h" | 16 #include "chrome/browser/browsing_data_database_helper.h" |
| 16 #include "chrome/browser/browsing_data_local_storage_helper.h" | 17 #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 17 #include "chrome/common/gtk_tree.h" | 18 #include "chrome/common/gtk_tree.h" |
| 18 #include "net/base/cookie_monster.h" | 19 #include "net/base/cookie_monster.h" |
| 19 #include "testing/gtest/include/gtest/gtest_prod.h" | 20 #include "testing/gtest/include/gtest/gtest_prod.h" |
| 20 | 21 |
| 21 class CookiesTreeModel; | 22 class CookiesTreeModel; |
| 22 class CookiesViewTest; | 23 class CookiesViewTest; |
| 23 class Profile; | 24 class Profile; |
| 24 | 25 |
| 25 // CookiesView is thread-hostile, and should only be called on the UI thread. | 26 // CookiesView is thread-hostile, and should only be called on the UI thread. |
| 26 // Usage: | 27 // Usage: |
| 27 // CookiesView::Show(profile); | 28 // CookiesView::Show(profile); |
| 28 // Once the CookiesView is shown, it is responsible for deleting itself when the | 29 // Once the CookiesView is shown, it is responsible for deleting itself when the |
| 29 // user closes the dialog. | 30 // user closes the dialog. |
| 30 | 31 |
| 31 class CookiesView : public gtk_tree::TreeAdapter::Delegate { | 32 class CookiesView : public gtk_tree::TreeAdapter::Delegate { |
| 32 public: | 33 public: |
| 33 virtual ~CookiesView(); | 34 virtual ~CookiesView(); |
| 34 | 35 |
| 35 // Create (if necessary) and show the cookie manager window. | 36 // Create (if necessary) and show the cookie manager window. |
| 36 static void Show( | 37 static void Show( |
| 37 GtkWindow* parent, | 38 GtkWindow* parent, |
| 38 Profile* profile, | 39 Profile* profile, |
| 39 BrowsingDataDatabaseHelper* browsing_data_database_helper, | 40 BrowsingDataDatabaseHelper* browsing_data_database_helper, |
| 40 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper); | 41 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper, |
| 42 BrowsingDataAppCacheHelper* browsing_data_appcache_helper); |
| 41 | 43 |
| 42 // gtk_tree::TreeAdapter::Delegate implementation. | 44 // gtk_tree::TreeAdapter::Delegate implementation. |
| 43 virtual void OnAnyModelUpdateStart(); | 45 virtual void OnAnyModelUpdateStart(); |
| 44 virtual void OnAnyModelUpdate(); | 46 virtual void OnAnyModelUpdate(); |
| 45 | 47 |
| 46 private: | 48 private: |
| 47 CookiesView( | 49 CookiesView( |
| 48 GtkWindow* parent, | 50 GtkWindow* parent, |
| 49 Profile* profile, | 51 Profile* profile, |
| 50 BrowsingDataDatabaseHelper* browsing_data_database_helper, | 52 BrowsingDataDatabaseHelper* browsing_data_database_helper, |
| 51 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper); | 53 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper, |
| 54 BrowsingDataAppCacheHelper* browsing_data_appcache_helper); |
| 52 | 55 |
| 53 // Initialize the dialog contents and layout. | 56 // Initialize the dialog contents and layout. |
| 54 void Init(GtkWindow* parent); | 57 void Init(GtkWindow* parent); |
| 55 | 58 |
| 56 // Initialize the widget styles and display the dialog. | 59 // Initialize the widget styles and display the dialog. |
| 57 void InitStylesAndShow(); | 60 void InitStylesAndShow(); |
| 58 | 61 |
| 59 // Helper for initializing cookie / local storage details table. | 62 // Helper for initializing cookie / local storage details table. |
| 60 void InitDetailRow(int row, int label_id, | 63 void InitDetailRow(int row, int label_id, |
| 61 GtkWidget* details_table, GtkWidget** display_label); | 64 GtkWidget* details_table, GtkWidget** display_label); |
| 62 | 65 |
| 63 // Set the initial selection and tree expanded state. | 66 // Set the initial selection and tree expanded state. |
| 64 void SetInitialTreeState(); | 67 void SetInitialTreeState(); |
| 65 | 68 |
| 66 // Set sensitivity of buttons based on selection and filter state. | 69 // Set sensitivity of buttons based on selection and filter state. |
| 67 void EnableControls(); | 70 void EnableControls(); |
| 68 | 71 |
| 69 // Set sensitivity of cookie details. | 72 // Set sensitivity of cookie details. |
| 70 void SetCookieDetailsSensitivity(gboolean enabled); | 73 void SetCookieDetailsSensitivity(gboolean enabled); |
| 71 | 74 |
| 72 // Set sensitivity of database details. | 75 // Set sensitivity of database details. |
| 73 void SetDatabaseDetailsSensitivity(gboolean enabled); | 76 void SetDatabaseDetailsSensitivity(gboolean enabled); |
| 74 | 77 |
| 75 // Set sensitivity of local storage details. | 78 // Set sensitivity of local storage details. |
| 76 void SetLocalStorageDetailsSensitivity(gboolean enabled); | 79 void SetLocalStorageDetailsSensitivity(gboolean enabled); |
| 77 | 80 |
| 81 // Set sensitivity of appcache details. |
| 82 void SetAppCacheDetailsSensitivity(gboolean enabled); |
| 83 |
| 78 // Show the details of the currently selected cookie. | 84 // Show the details of the currently selected cookie. |
| 79 void PopulateCookieDetails(const std::string& domain, | 85 void PopulateCookieDetails(const std::string& domain, |
| 80 const net::CookieMonster::CanonicalCookie& cookie); | 86 const net::CookieMonster::CanonicalCookie& cookie); |
| 81 | 87 |
| 82 // Show the details of the currently selected database. | 88 // Show the details of the currently selected database. |
| 83 void PopulateDatabaseDetails( | 89 void PopulateDatabaseDetails( |
| 84 const BrowsingDataDatabaseHelper::DatabaseInfo& database_info); | 90 const BrowsingDataDatabaseHelper::DatabaseInfo& database_info); |
| 85 | 91 |
| 86 // Show the details of the currently selected local storage. | 92 // Show the details of the currently selected local storage. |
| 87 void PopulateLocalStorageDetails( | 93 void PopulateLocalStorageDetails( |
| 88 const BrowsingDataLocalStorageHelper::LocalStorageInfo& | 94 const BrowsingDataLocalStorageHelper::LocalStorageInfo& |
| 89 local_storage_info); | 95 local_storage_info); |
| 90 | 96 |
| 97 // Show the details of the currently selected appcache. |
| 98 void PopulateAppCacheDetails( |
| 99 const BrowsingDataAppCacheHelper::AppCacheInfo& info); |
| 100 |
| 91 // Reset the cookie details display. | 101 // Reset the cookie details display. |
| 92 void ClearCookieDetails(); | 102 void ClearCookieDetails(); |
| 93 | 103 |
| 94 // Remove any cookies that are currently selected. | 104 // Remove any cookies that are currently selected. |
| 95 void RemoveSelectedItems(); | 105 void RemoveSelectedItems(); |
| 96 | 106 |
| 97 // Callback for dialog buttons. | 107 // Callback for dialog buttons. |
| 98 static void OnResponse(GtkDialog* dialog, int response_id, | 108 static void OnResponse(GtkDialog* dialog, int response_id, |
| 99 CookiesView* window); | 109 CookiesView* window); |
| 100 | 110 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 GtkWidget* cookie_name_entry_; | 154 GtkWidget* cookie_name_entry_; |
| 145 GtkWidget* cookie_content_entry_; | 155 GtkWidget* cookie_content_entry_; |
| 146 GtkWidget* cookie_domain_entry_; | 156 GtkWidget* cookie_domain_entry_; |
| 147 GtkWidget* cookie_path_entry_; | 157 GtkWidget* cookie_path_entry_; |
| 148 GtkWidget* cookie_send_for_entry_; | 158 GtkWidget* cookie_send_for_entry_; |
| 149 GtkWidget* cookie_created_entry_; | 159 GtkWidget* cookie_created_entry_; |
| 150 GtkWidget* cookie_expires_entry_; | 160 GtkWidget* cookie_expires_entry_; |
| 151 | 161 |
| 152 // The database details widgets. | 162 // The database details widgets. |
| 153 GtkWidget* database_details_table_; | 163 GtkWidget* database_details_table_; |
| 164 GtkWidget* database_name_entry_; |
| 154 GtkWidget* database_description_entry_; | 165 GtkWidget* database_description_entry_; |
| 155 GtkWidget* database_size_entry_; | 166 GtkWidget* database_size_entry_; |
| 156 GtkWidget* database_last_modified_entry_; | 167 GtkWidget* database_last_modified_entry_; |
| 157 | 168 |
| 158 // The local storage details widgets. | 169 // The local storage details widgets. |
| 159 GtkWidget* local_storage_details_table_; | 170 GtkWidget* local_storage_details_table_; |
| 160 GtkWidget* local_storage_origin_entry_; | 171 GtkWidget* local_storage_origin_entry_; |
| 161 GtkWidget* local_storage_size_entry_; | 172 GtkWidget* local_storage_size_entry_; |
| 162 GtkWidget* local_storage_last_modified_entry_; | 173 GtkWidget* local_storage_last_modified_entry_; |
| 163 | 174 |
| 164 // The profile. | 175 // The appcache details widgets. |
| 176 GtkWidget* appcache_details_table_; |
| 177 GtkWidget* appcache_manifest_entry_; |
| 178 GtkWidget* appcache_size_entry_; |
| 179 GtkWidget* appcache_created_entry_; |
| 180 GtkWidget* appcache_last_accessed_entry_; |
| 181 |
| 182 // The profile and related helpers. |
| 165 Profile* profile_; | 183 Profile* profile_; |
| 166 | |
| 167 // Database Helper. | |
| 168 scoped_refptr<BrowsingDataDatabaseHelper> browsing_data_database_helper_; | 184 scoped_refptr<BrowsingDataDatabaseHelper> browsing_data_database_helper_; |
| 169 | |
| 170 // Local Storage Helper. | |
| 171 scoped_refptr<BrowsingDataLocalStorageHelper> | 185 scoped_refptr<BrowsingDataLocalStorageHelper> |
| 172 browsing_data_local_storage_helper_; | 186 browsing_data_local_storage_helper_; |
| 187 scoped_refptr<BrowsingDataAppCacheHelper> browsing_data_appcache_helper_; |
| 173 | 188 |
| 174 // A factory to construct Runnable Methods so that we can be called back to | 189 // A factory to construct Runnable Methods so that we can be called back to |
| 175 // re-evaluate the model after the search query string changes. | 190 // re-evaluate the model after the search query string changes. |
| 176 ScopedRunnableMethodFactory<CookiesView> filter_update_factory_; | 191 ScopedRunnableMethodFactory<CookiesView> filter_update_factory_; |
| 177 | 192 |
| 178 // The Cookies Table model. | 193 // The Cookies Table model. |
| 179 scoped_ptr<CookiesTreeModel> cookies_tree_model_; | 194 scoped_ptr<CookiesTreeModel> cookies_tree_model_; |
| 180 scoped_ptr<gtk_tree::TreeAdapter> cookies_tree_adapter_; | 195 scoped_ptr<gtk_tree::TreeAdapter> cookies_tree_adapter_; |
| 181 | 196 |
| 182 friend class CookiesViewTest; | 197 friend class CookiesViewTest; |
| 183 FRIEND_TEST(CookiesViewTest, Empty); | 198 FRIEND_TEST(CookiesViewTest, Empty); |
| 184 FRIEND_TEST(CookiesViewTest, Noop); | 199 FRIEND_TEST(CookiesViewTest, Noop); |
| 185 FRIEND_TEST(CookiesViewTest, RemoveAll); | 200 FRIEND_TEST(CookiesViewTest, RemoveAll); |
| 186 FRIEND_TEST(CookiesViewTest, RemoveAllWithDefaultSelected); | 201 FRIEND_TEST(CookiesViewTest, RemoveAllWithDefaultSelected); |
| 187 FRIEND_TEST(CookiesViewTest, Remove); | 202 FRIEND_TEST(CookiesViewTest, Remove); |
| 188 FRIEND_TEST(CookiesViewTest, RemoveCookiesByType); | 203 FRIEND_TEST(CookiesViewTest, RemoveCookiesByType); |
| 189 FRIEND_TEST(CookiesViewTest, RemoveByDomain); | 204 FRIEND_TEST(CookiesViewTest, RemoveByDomain); |
| 190 FRIEND_TEST(CookiesViewTest, RemoveDefaultSelection); | 205 FRIEND_TEST(CookiesViewTest, RemoveDefaultSelection); |
| 191 FRIEND_TEST(CookiesViewTest, Filter); | 206 FRIEND_TEST(CookiesViewTest, Filter); |
| 192 FRIEND_TEST(CookiesViewTest, FilterRemoveAll); | 207 FRIEND_TEST(CookiesViewTest, FilterRemoveAll); |
| 193 FRIEND_TEST(CookiesViewTest, FilterRemove); | 208 FRIEND_TEST(CookiesViewTest, FilterRemove); |
| 194 | 209 |
| 195 DISALLOW_COPY_AND_ASSIGN(CookiesView); | 210 DISALLOW_COPY_AND_ASSIGN(CookiesView); |
| 196 }; | 211 }; |
| 197 | 212 |
| 198 #endif // CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ | 213 #endif // CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ |
| OLD | NEW |