• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_UI_GTK_GTK_CHROME_COOKIE_VIEW_H_
6 #define CHROME_BROWSER_UI_GTK_GTK_CHROME_COOKIE_VIEW_H_
7 #pragma once
8 
9 #include <gtk/gtk.h>
10 
11 #include <string>
12 
13 #include "chrome/browser/browsing_data_appcache_helper.h"
14 #include "chrome/browser/browsing_data_database_helper.h"
15 #include "chrome/browser/browsing_data_indexed_db_helper.h"
16 #include "chrome/browser/browsing_data_local_storage_helper.h"
17 #include "net/base/cookie_monster.h"
18 
19 class GURL;
20 
21 G_BEGIN_DECLS
22 
23 #define GTK_TYPE_CHROME_COOKIE_VIEW gtk_chrome_cookie_view_get_type()
24 
25 #define GTK_CHROME_COOKIE_VIEW(obj) \
26   (G_TYPE_CHECK_INSTANCE_CAST((obj), \
27   GTK_TYPE_CHROME_COOKIE_VIEW, GtkChromeCookieView))
28 
29 #define GTK_CHROME_COOKIE_VIEW_CLASS(klass) \
30   (G_TYPE_CHECK_CLASS_CAST((klass), \
31   GTK_TYPE_CHROME_COOKIE_VIEW, GtkChromeCookieViewClass))
32 
33 #define GTK_IS_CHROME_COOKIE_VIEW(obj) \
34   (G_TYPE_CHECK_INSTANCE_TYPE((obj), \
35   GTK_TYPE_CHROME_COOKIE_VIEW))
36 
37 #define GTK_IS_CHROME_COOKIE_VIEW_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_TYPE((klass), \
39   GTK_TYPE_CHROME_COOKIE_VIEW))
40 
41 #define GTK_CHROME_COOKIE_VIEW_GET_CLASS(obj) \
42   (G_TYPE_INSTANCE_GET_CLASS((obj), \
43   GTK_TYPE_CHROME_COOKIE_VIEW, GtkChromeCookieViewClass))
44 
45 // TODO(erg): Refactor the following class. It's continuously grown as more
46 // things have been added to it and should probably become a general key/value
47 // table. The problem is that any implementation for that would be much more
48 // complicated and would require changing a whole lot of code.
49 typedef struct {
50   GtkFrame parent;
51 
52   // All public for testing since I don't think there's a "friend" mechanism in
53   // gobject.
54 
55   GtkWidget* table_box_;
56 
57   // A label we keep around so we can access its GtkStyle* once it is realized.
58   GtkWidget* first_label_;
59 
60   // The cookie details widgets.
61   GtkWidget* cookie_details_table_;
62   GtkWidget* cookie_name_entry_;
63   GtkWidget* cookie_content_entry_;
64   GtkWidget* cookie_domain_entry_;
65   GtkWidget* cookie_path_entry_;
66   GtkWidget* cookie_send_for_entry_;
67   GtkWidget* cookie_created_entry_;
68 
69   // Note: These two widgets are mutually exclusive based on what
70   // |editable_expiration| was when the cookie view was created. One of these
71   // variables will be NULL.
72   GtkWidget* cookie_expires_entry_;
73   GtkWidget* cookie_expires_combobox_;
74 
75   GtkListStore* cookie_expires_combobox_store_;
76 
77   // The database details widgets.
78   GtkWidget* database_details_table_;
79   GtkWidget* database_name_entry_;
80   GtkWidget* database_description_entry_;
81   GtkWidget* database_size_entry_;
82   GtkWidget* database_last_modified_entry_;
83 
84   // The local storage details widgets.
85   GtkWidget* local_storage_details_table_;
86   GtkWidget* local_storage_origin_entry_;
87   GtkWidget* local_storage_size_entry_;
88   GtkWidget* local_storage_last_modified_entry_;
89 
90   // The appcache details widgets.
91   GtkWidget* appcache_details_table_;
92   GtkWidget* appcache_manifest_entry_;
93   GtkWidget* appcache_size_entry_;
94   GtkWidget* appcache_created_entry_;
95   GtkWidget* appcache_last_accessed_entry_;
96 
97   // The IndexedDB details widgets.
98   GtkWidget* indexed_db_details_table_;
99   GtkWidget* indexed_db_origin_entry_;
100   GtkWidget* indexed_db_size_entry_;
101   GtkWidget* indexed_db_last_modified_entry_;
102 
103   // The local storage item widgets.
104   GtkWidget* local_storage_item_table_;
105   GtkWidget* local_storage_item_origin_entry_;
106   GtkWidget* local_storage_item_key_entry_;
107   GtkWidget* local_storage_item_value_entry_;
108 
109   // The database accessed widgets.
110   GtkWidget* database_accessed_table_;
111   GtkWidget* database_accessed_origin_entry_;
112   GtkWidget* database_accessed_name_entry_;
113   GtkWidget* database_accessed_description_entry_;
114   GtkWidget* database_accessed_size_entry_;
115 
116   // The appcache created widgets.
117   GtkWidget* appcache_created_table_;
118   GtkWidget* appcache_created_manifest_entry_;
119 } GtkChromeCookieView;
120 
121 typedef struct {
122   GtkFrameClass parent_class;
123 } GtkChromeCookieViewClass;
124 
125 GType gtk_chrome_cookie_view_get_type();
126 
127 // Builds a new cookie view.
128 GtkWidget* gtk_chrome_cookie_view_new(gboolean editable_expiration);
129 
130 // Clears the cookie view.
131 void gtk_chrome_cookie_view_clear(GtkChromeCookieView* widget);
132 
133 // NOTE: The G_END_DECLS ends here instead of at the end of the document
134 // because we want to define some methods on GtkChromeCookieView that take C++
135 // objects.
136 G_END_DECLS
137 // NOTE: ^^^^^^^^^^^^^^^^^^^^^^^
138 
139 // Switches the display to showing the passed in cookie.
140 void gtk_chrome_cookie_view_display_cookie(
141     GtkChromeCookieView* widget,
142     const std::string& domain,
143     const net::CookieMonster::CanonicalCookie& cookie);
144 
145 // Looks up the cookie_line in CookieMonster and displays that.
146 void gtk_chrome_cookie_view_display_cookie_string(
147     GtkChromeCookieView* widget,
148     const GURL& url,
149     const std::string& cookie_line);
150 
151 // Switches the display to showing the passed in database.
152 void gtk_chrome_cookie_view_display_database(
153     GtkChromeCookieView* widget,
154     const BrowsingDataDatabaseHelper::DatabaseInfo& database_info);
155 
156 // Switches the display to showing the passed in local storage data.
157 void gtk_chrome_cookie_view_display_local_storage(
158     GtkChromeCookieView* widget,
159     const BrowsingDataLocalStorageHelper::LocalStorageInfo&
160     local_storage_info);
161 
162 // Switches the display to showing the passed in app cache.
163 void gtk_chrome_cookie_view_display_app_cache(
164     GtkChromeCookieView* widget,
165     const appcache::AppCacheInfo& info);
166 
167 // Switches the display to showing the passed in IndexedDB data.
168 void gtk_chrome_cookie_view_display_indexed_db(
169     GtkChromeCookieView* widget,
170     const BrowsingDataIndexedDBHelper::IndexedDBInfo& info);
171 
172 // Switches the display to an individual storage item.
173 void gtk_chrome_cookie_view_display_local_storage_item(
174     GtkChromeCookieView* widget,
175     const std::string& host,
176     const string16& key,
177     const string16& value);
178 
179 void gtk_chrome_cookie_view_display_database_accessed(
180     GtkChromeCookieView* self,
181     const std::string& host,
182     const string16& database_name,
183     const string16& display_name,
184     unsigned long estimated_size);
185 
186 void gtk_chrome_cookie_view_display_appcache_created(
187     GtkChromeCookieView* self,
188     const GURL& manifest_url);
189 
190 // If |editable_expiration| was true at construction time, returns the value of
191 // the combo box. Otherwise, returns false.
192 bool gtk_chrome_cookie_view_session_expires(GtkChromeCookieView* self);
193 
194 #endif  // CHROME_BROWSER_UI_GTK_GTK_CHROME_COOKIE_VIEW_H_
195