| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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. | |
| 6 | |
| 7 #ifndef CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ | 5 #ifndef CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ |
| 8 #define CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ | 6 #define CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ |
| 9 #pragma once | 7 #pragma once |
| 10 | 8 |
| 11 #include <gtk/gtk.h> | 9 #include "chrome/browser/ui/gtk/options/cookies_view.h" |
| 12 | 10 // TODO(msw): remove this file once all includes have been updated. |
| 13 #include "app/gtk_signal.h" | |
| 14 #include "base/basictypes.h" | |
| 15 #include "base/gtest_prod_util.h" | |
| 16 #include "base/scoped_ptr.h" | |
| 17 #include "base/task.h" | |
| 18 #include "chrome/browser/browsing_data_appcache_helper.h" | |
| 19 #include "chrome/browser/browsing_data_database_helper.h" | |
| 20 #include "chrome/browser/browsing_data_indexed_db_helper.h" | |
| 21 #include "chrome/browser/browsing_data_local_storage_helper.h" | |
| 22 #include "chrome/browser/gtk/gtk_chrome_cookie_view.h" | |
| 23 #include "chrome/browser/gtk/gtk_tree.h" | |
| 24 #include "net/base/cookie_monster.h" | |
| 25 | |
| 26 class CookieDisplayGtk; | |
| 27 class CookiesTreeModel; | |
| 28 class CookiesViewTest; | |
| 29 class Profile; | |
| 30 | |
| 31 // CookiesView is thread-hostile, and should only be called on the UI thread. | |
| 32 // Usage: | |
| 33 // CookiesView::Show(profile); | |
| 34 // Once the CookiesView is shown, it is responsible for deleting itself when the | |
| 35 // user closes the dialog. | |
| 36 | |
| 37 class CookiesView : public gtk_tree::TreeAdapter::Delegate { | |
| 38 public: | |
| 39 virtual ~CookiesView(); | |
| 40 | |
| 41 // Create (if necessary) and show the cookie manager window. | |
| 42 static void Show( | |
| 43 GtkWindow* parent, | |
| 44 Profile* profile, | |
| 45 BrowsingDataDatabaseHelper* browsing_data_database_helper, | |
| 46 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper, | |
| 47 BrowsingDataAppCacheHelper* browsing_data_appcache_helper, | |
| 48 BrowsingDataIndexedDBHelper* browsing_data_indexed_db_helper); | |
| 49 | |
| 50 // gtk_tree::TreeAdapter::Delegate implementation. | |
| 51 virtual void OnAnyModelUpdateStart(); | |
| 52 virtual void OnAnyModelUpdate(); | |
| 53 | |
| 54 private: | |
| 55 CookiesView( | |
| 56 GtkWindow* parent, | |
| 57 Profile* profile, | |
| 58 BrowsingDataDatabaseHelper* browsing_data_database_helper, | |
| 59 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper, | |
| 60 BrowsingDataAppCacheHelper* browsing_data_appcache_helper, | |
| 61 BrowsingDataIndexedDBHelper* browsing_data_indexed_db_helper); | |
| 62 | |
| 63 // A method only used in unit tests that sets a bit inside this class that | |
| 64 // lets it be stack allocated. | |
| 65 void TestDestroySynchronously(); | |
| 66 | |
| 67 // Initialize the dialog contents and layout. | |
| 68 void Init(GtkWindow* parent); | |
| 69 | |
| 70 // Set the initial selection and tree expanded state. | |
| 71 void SetInitialTreeState(); | |
| 72 | |
| 73 // Set sensitivity of buttons based on selection and filter state. | |
| 74 void EnableControls(); | |
| 75 | |
| 76 // Remove any cookies that are currently selected. | |
| 77 void RemoveSelectedItems(); | |
| 78 | |
| 79 CHROMEGTK_CALLBACK_1(CookiesView, void, OnResponse, int); | |
| 80 CHROMEGTK_CALLBACK_0(CookiesView, void, OnWindowDestroy); | |
| 81 // Callback for the table. | |
| 82 CHROMEGTK_CALLBACK_0(CookiesView, void, OnTreeViewSelectionChange); | |
| 83 CHROMEGTK_CALLBACK_1(CookiesView, gboolean, OnTreeViewKeyPress, | |
| 84 GdkEventKey*); | |
| 85 CHROMEGTK_CALLBACK_2(CookiesView, void, OnTreeViewRowExpanded, | |
| 86 GtkTreeIter*, GtkTreePath*); | |
| 87 // Callbacks for user actions filtering the list. | |
| 88 CHROMEGTK_CALLBACK_0(CookiesView, void, OnFilterEntryActivated); | |
| 89 CHROMEGTK_CALLBACK_0(CookiesView, void, OnFilterEntryChanged); | |
| 90 CHROMEGTK_CALLBACK_0(CookiesView, void, OnFilterClearButtonClicked); | |
| 91 | |
| 92 // Filter the list against the text in |filter_entry_|. | |
| 93 void UpdateFilterResults(); | |
| 94 | |
| 95 | |
| 96 // The parent widget. | |
| 97 GtkWidget* dialog_; | |
| 98 | |
| 99 // Widgets of the dialog. | |
| 100 GtkWidget* description_label_; | |
| 101 GtkWidget* filter_entry_; | |
| 102 GtkWidget* filter_clear_button_; | |
| 103 GtkWidget* remove_button_; | |
| 104 GtkWidget* remove_all_button_; | |
| 105 | |
| 106 // The table listing the cookies. | |
| 107 GtkWidget* tree_; | |
| 108 GtkTreeSelection* selection_; | |
| 109 | |
| 110 GtkWidget* cookie_display_; | |
| 111 | |
| 112 // The profile and related helpers. | |
| 113 Profile* profile_; | |
| 114 scoped_refptr<BrowsingDataDatabaseHelper> browsing_data_database_helper_; | |
| 115 scoped_refptr<BrowsingDataLocalStorageHelper> | |
| 116 browsing_data_local_storage_helper_; | |
| 117 scoped_refptr<BrowsingDataAppCacheHelper> browsing_data_appcache_helper_; | |
| 118 scoped_refptr<BrowsingDataIndexedDBHelper> browsing_data_indexed_db_helper_; | |
| 119 | |
| 120 // A factory to construct Runnable Methods so that we can be called back to | |
| 121 // re-evaluate the model after the search query string changes. | |
| 122 ScopedRunnableMethodFactory<CookiesView> filter_update_factory_; | |
| 123 | |
| 124 // The Cookies Table model. | |
| 125 scoped_ptr<CookiesTreeModel> cookies_tree_model_; | |
| 126 scoped_ptr<gtk_tree::TreeAdapter> cookies_tree_adapter_; | |
| 127 | |
| 128 // A reference to the "destroy" signal handler for this object. We disconnect | |
| 129 // from this signal if we need to be destroyed synchronously. | |
| 130 gulong destroy_handler_; | |
| 131 | |
| 132 // Whether we own |dialog_| or the other way around. | |
| 133 bool destroy_dialog_in_destructor_; | |
| 134 | |
| 135 friend class CookiesViewTest; | |
| 136 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, Empty); | |
| 137 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, Noop); | |
| 138 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, RemoveAll); | |
| 139 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, RemoveAllWithDefaultSelected); | |
| 140 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, Remove); | |
| 141 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, RemoveCookiesByType); | |
| 142 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, RemoveByDomain); | |
| 143 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, RemoveDefaultSelection); | |
| 144 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, Filter); | |
| 145 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, FilterRemoveAll); | |
| 146 FRIEND_TEST_ALL_PREFIXES(CookiesViewTest, FilterRemove); | |
| 147 | |
| 148 DISALLOW_COPY_AND_ASSIGN(CookiesView); | |
| 149 }; | |
| 150 | 11 |
| 151 #endif // CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ | 12 #endif // CHROME_BROWSER_GTK_OPTIONS_COOKIES_VIEW_H_ |
| OLD | NEW |