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