Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(871)

Side by Side Diff: chrome/browser/gtk/options/cookies_view.cc

Issue 523139: Adds local storage nodes to cookie tree model and cookies view. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "chrome/browser/gtk/options/cookies_view.h" 5 #include "chrome/browser/gtk/options/cookies_view.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 17 matching lines...) Expand all
28 28
29 // Response ids for our custom buttons. 29 // Response ids for our custom buttons.
30 enum { 30 enum {
31 RESPONSE_REMOVE = 1, 31 RESPONSE_REMOVE = 1,
32 RESPONSE_REMOVE_ALL 32 RESPONSE_REMOVE_ALL
33 }; 33 };
34 34
35 // The currently open cookie manager, if any. 35 // The currently open cookie manager, if any.
36 CookiesView* instance_ = NULL; 36 CookiesView* instance_ = NULL;
37 37
38 void InitCookieDetailStyle(GtkWidget* entry, GtkStyle* label_style, 38 void InitBrowserDetailStyle(GtkWidget* entry, GtkStyle* label_style,
39 GtkStyle* dialog_style) { 39 GtkStyle* dialog_style) {
40 gtk_widget_modify_fg(entry, GTK_STATE_NORMAL, 40 gtk_widget_modify_fg(entry, GTK_STATE_NORMAL,
41 &label_style->fg[GTK_STATE_NORMAL]); 41 &label_style->fg[GTK_STATE_NORMAL]);
42 gtk_widget_modify_fg(entry, GTK_STATE_INSENSITIVE, 42 gtk_widget_modify_fg(entry, GTK_STATE_INSENSITIVE,
43 &label_style->fg[GTK_STATE_INSENSITIVE]); 43 &label_style->fg[GTK_STATE_INSENSITIVE]);
44 // GTK_NO_WINDOW widgets like GtkLabel don't draw their own background, so we 44 // GTK_NO_WINDOW widgets like GtkLabel don't draw their own background, so we
45 // combine the normal or insensitive foreground of the label style with the 45 // combine the normal or insensitive foreground of the label style with the
46 // normal background of the window style to achieve the "normal label" and 46 // normal background of the window style to achieve the "normal label" and
47 // "insensitive label" colors. 47 // "insensitive label" colors.
48 gtk_widget_modify_base(entry, GTK_STATE_NORMAL, 48 gtk_widget_modify_base(entry, GTK_STATE_NORMAL,
49 &dialog_style->bg[GTK_STATE_NORMAL]); 49 &dialog_style->bg[GTK_STATE_NORMAL]);
50 gtk_widget_modify_base(entry, GTK_STATE_INSENSITIVE, 50 gtk_widget_modify_base(entry, GTK_STATE_INSENSITIVE,
51 &dialog_style->bg[GTK_STATE_NORMAL]); 51 &dialog_style->bg[GTK_STATE_NORMAL]);
52 } 52 }
53 53
54 } // namespace 54 } // namespace
55 55
56 CookiesView::~CookiesView() { 56 CookiesView::~CookiesView() {
57 } 57 }
58 58
59 // static 59 // static
60 void CookiesView::Show(Profile* profile) { 60 void CookiesView::Show(
61 Profile* profile,
62 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper) {
61 DCHECK(profile); 63 DCHECK(profile);
64 DCHECK(browsing_data_local_storage_helper);
62 65
63 // If there's already an existing editor window, activate it. 66 // If there's already an existing editor window, activate it.
64 if (instance_) { 67 if (instance_) {
65 gtk_window_present(GTK_WINDOW(instance_->dialog_)); 68 gtk_window_present(GTK_WINDOW(instance_->dialog_));
66 } else { 69 } else {
67 instance_ = new CookiesView(profile); 70 instance_ = new CookiesView(profile, browsing_data_local_storage_helper);
68 instance_->InitStylesAndShow(); 71 instance_->InitStylesAndShow();
69 } 72 }
70 } 73 }
71 74
72 CookiesView::CookiesView(Profile* profile) 75 CookiesView::CookiesView(
76 Profile* profile,
77 BrowsingDataLocalStorageHelper* browsing_data_local_storage_helper)
73 : profile_(profile), 78 : profile_(profile),
79 browsing_data_local_storage_helper_(browsing_data_local_storage_helper),
74 filter_update_factory_(this) { 80 filter_update_factory_(this) {
75 Init(); 81 Init();
76 } 82 }
77 83
78 void CookiesView::Init() { 84 void CookiesView::Init() {
79 dialog_ = gtk_dialog_new_with_buttons( 85 dialog_ = gtk_dialog_new_with_buttons(
80 l10n_util::GetStringUTF8( 86 l10n_util::GetStringUTF8(
81 IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE).c_str(), 87 IDS_COOKIES_WEBSITE_PERMISSIONS_WINDOW_TITLE).c_str(),
82 NULL, 88 NULL,
83 GTK_DIALOG_NO_SEPARATOR, 89 GTK_DIALOG_NO_SEPARATOR,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 FALSE, FALSE, 0); 159 FALSE, FALSE, 0);
154 160
155 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL); 161 GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL);
156 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), 162 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window),
157 GTK_POLICY_AUTOMATIC, 163 GTK_POLICY_AUTOMATIC,
158 GTK_POLICY_AUTOMATIC); 164 GTK_POLICY_AUTOMATIC);
159 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll_window), 165 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scroll_window),
160 GTK_SHADOW_ETCHED_IN); 166 GTK_SHADOW_ETCHED_IN);
161 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0); 167 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0);
162 168
163 cookies_tree_model_.reset(new CookiesTreeModel(profile_)); 169 cookies_tree_model_.reset(new CookiesTreeModel(
170 profile_, browsing_data_local_storage_helper_));
164 cookies_tree_adapter_.reset( 171 cookies_tree_adapter_.reset(
165 new gtk_tree::TreeAdapter(this, cookies_tree_model_.get())); 172 new gtk_tree::TreeAdapter(this, cookies_tree_model_.get()));
166 tree_ = gtk_tree_view_new_with_model( 173 tree_ = gtk_tree_view_new_with_model(
167 GTK_TREE_MODEL(cookies_tree_adapter_->tree_store())); 174 GTK_TREE_MODEL(cookies_tree_adapter_->tree_store()));
168 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_), FALSE); 175 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree_), FALSE);
169 gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(tree_), TRUE); 176 gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(tree_), TRUE);
170 gtk_container_add(GTK_CONTAINER(scroll_window), tree_); 177 gtk_container_add(GTK_CONTAINER(scroll_window), tree_);
171 178
172 GtkTreeViewColumn* title_column = gtk_tree_view_column_new(); 179 GtkTreeViewColumn* title_column = gtk_tree_view_column_new();
173 GtkCellRenderer* pixbuf_renderer = gtk_cell_renderer_pixbuf_new(); 180 GtkCellRenderer* pixbuf_renderer = gtk_cell_renderer_pixbuf_new();
(...skipping 12 matching lines...) Expand all
186 G_CALLBACK(OnTreeViewKeyPress), this); 193 G_CALLBACK(OnTreeViewKeyPress), this);
187 g_signal_connect(G_OBJECT(tree_), "row-expanded", 194 g_signal_connect(G_OBJECT(tree_), "row-expanded",
188 G_CALLBACK(OnTreeViewRowExpanded), this); 195 G_CALLBACK(OnTreeViewRowExpanded), this);
189 196
190 selection_ = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_)); 197 selection_ = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_));
191 gtk_tree_selection_set_mode(selection_, GTK_SELECTION_SINGLE); 198 gtk_tree_selection_set_mode(selection_, GTK_SELECTION_SINGLE);
192 g_signal_connect(G_OBJECT(selection_), "changed", 199 g_signal_connect(G_OBJECT(selection_), "changed",
193 G_CALLBACK(OnSelectionChanged), this); 200 G_CALLBACK(OnSelectionChanged), this);
194 201
195 // Cookie details. 202 // Cookie details.
196 GtkWidget* details_frame = gtk_frame_new(NULL); 203 GtkWidget* cookie_details_frame = gtk_frame_new(NULL);
197 gtk_frame_set_shadow_type(GTK_FRAME(details_frame), GTK_SHADOW_ETCHED_IN); 204 gtk_frame_set_shadow_type(GTK_FRAME(cookie_details_frame),
198 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), details_frame, 205 GTK_SHADOW_ETCHED_IN);
206 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), cookie_details_frame,
199 FALSE, FALSE, 0); 207 FALSE, FALSE, 0);
200 cookie_details_table_ = gtk_table_new(7, 2, FALSE); 208 cookie_details_table_ = gtk_table_new(7, 2, FALSE);
201 gtk_container_add(GTK_CONTAINER(details_frame), cookie_details_table_); 209 gtk_container_add(GTK_CONTAINER(cookie_details_frame), cookie_details_table_);
202 gtk_table_set_col_spacing(GTK_TABLE(cookie_details_table_), 0, 210 gtk_table_set_col_spacing(GTK_TABLE(cookie_details_table_), 0,
203 gtk_util::kLabelSpacing); 211 gtk_util::kLabelSpacing);
204 212
205 int row = 0; 213 int row = 0;
206 InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_NAME_LABEL, 214 InitDetailRow(row++, IDS_COOKIES_COOKIE_NAME_LABEL,
207 &cookie_name_entry_); 215 cookie_details_table_, &cookie_name_entry_);
208 InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_CONTENT_LABEL, 216 InitDetailRow(row++, IDS_COOKIES_COOKIE_CONTENT_LABEL,
209 &cookie_content_entry_); 217 cookie_details_table_, &cookie_content_entry_);
210 InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL, 218 InitDetailRow(row++, IDS_COOKIES_COOKIE_DOMAIN_LABEL,
211 &cookie_domain_entry_); 219 cookie_details_table_, &cookie_domain_entry_);
212 InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_PATH_LABEL, 220 InitDetailRow(row++, IDS_COOKIES_COOKIE_PATH_LABEL,
213 &cookie_path_entry_); 221 cookie_details_table_, &cookie_path_entry_);
214 InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_SENDFOR_LABEL, 222 InitDetailRow(row++, IDS_COOKIES_COOKIE_SENDFOR_LABEL,
215 &cookie_send_for_entry_); 223 cookie_details_table_, &cookie_send_for_entry_);
216 InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_CREATED_LABEL, 224 InitDetailRow(row++, IDS_COOKIES_COOKIE_CREATED_LABEL,
217 &cookie_created_entry_); 225 cookie_details_table_, &cookie_created_entry_);
218 InitCookieDetailRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL, 226 InitDetailRow(row++, IDS_COOKIES_COOKIE_EXPIRES_LABEL,
219 &cookie_expires_entry_); 227 cookie_details_table_, &cookie_expires_entry_);
220 228
229 // Local storage details.
230 GtkWidget* local_storage_details_frame = gtk_frame_new(NULL);
231 gtk_frame_set_shadow_type(GTK_FRAME(local_storage_details_frame),
232 GTK_SHADOW_ETCHED_IN);
233 gtk_box_pack_start(GTK_BOX(cookie_list_vbox), local_storage_details_frame,
234 FALSE, FALSE, 0);
235 local_storage_details_table_ = gtk_table_new(3, 2, FALSE);
236 gtk_container_add(GTK_CONTAINER(local_storage_details_frame),
237 local_storage_details_table_);
238 gtk_table_set_col_spacing(GTK_TABLE(local_storage_details_table_), 0,
239 gtk_util::kLabelSpacing);
240
241 row = 0;
242 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL,
243 local_storage_details_table_, &local_storage_origin_entry_);
244 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL,
245 local_storage_details_table_, &local_storage_size_entry_);
246 InitDetailRow(row++, IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL,
247 local_storage_details_table_,
248 &local_storage_last_modified_entry_);
249
250 UpdateVisibleDetailedInfo(cookie_details_table_);
221 // Populate the view. 251 // Populate the view.
222 cookies_tree_adapter_->Init(); 252 cookies_tree_adapter_->Init();
223 SetInitialTreeState(); 253 SetInitialTreeState();
224 EnableControls(); 254 EnableControls();
225 } 255 }
226 256
227 void CookiesView::InitStylesAndShow() { 257 void CookiesView::InitStylesAndShow() {
228 // Realize a label so that its style gets initialized. 258 // Realize a label so that its style gets initialized.
229 gtk_widget_realize(description_label_); 259 gtk_widget_realize(description_label_);
230 gtk_widget_realize(dialog_); 260 gtk_widget_realize(dialog_);
231 GtkStyle* label_style = gtk_widget_get_style(description_label_); 261 GtkStyle* label_style = gtk_widget_get_style(description_label_);
232 GtkStyle* dialog_style = gtk_widget_get_style(dialog_); 262 GtkStyle* dialog_style = gtk_widget_get_style(dialog_);
233 263
234 InitCookieDetailStyle(cookie_name_entry_, label_style, dialog_style); 264 // Cookie details.
235 InitCookieDetailStyle(cookie_content_entry_, label_style, dialog_style); 265 InitBrowserDetailStyle(cookie_name_entry_, label_style, dialog_style);
236 InitCookieDetailStyle(cookie_domain_entry_, label_style, dialog_style); 266 InitBrowserDetailStyle(cookie_content_entry_, label_style, dialog_style);
237 InitCookieDetailStyle(cookie_path_entry_, label_style, dialog_style); 267 InitBrowserDetailStyle(cookie_domain_entry_, label_style, dialog_style);
238 InitCookieDetailStyle(cookie_send_for_entry_, label_style, dialog_style); 268 InitBrowserDetailStyle(cookie_path_entry_, label_style, dialog_style);
239 InitCookieDetailStyle(cookie_created_entry_, label_style, dialog_style); 269 InitBrowserDetailStyle(cookie_send_for_entry_, label_style, dialog_style);
240 InitCookieDetailStyle(cookie_expires_entry_, label_style, dialog_style); 270 InitBrowserDetailStyle(cookie_created_entry_, label_style, dialog_style);
271 InitBrowserDetailStyle(cookie_expires_entry_, label_style, dialog_style);
272
273 // Local storage details.
274 InitBrowserDetailStyle(local_storage_origin_entry_, label_style,
275 dialog_style);
276 InitBrowserDetailStyle(local_storage_size_entry_, label_style, dialog_style);
277 InitBrowserDetailStyle(local_storage_last_modified_entry_, label_style,
278 dialog_style);
241 279
242 gtk_widget_show_all(dialog_); 280 gtk_widget_show_all(dialog_);
243 } 281 }
244 282
245 void CookiesView::InitCookieDetailRow(int row, int label_id, 283 void CookiesView::InitDetailRow(int row, int label_id,
246 GtkWidget** entry) { 284 GtkWidget* details_table, GtkWidget** entry) {
247 GtkWidget* name_label = gtk_label_new( 285 GtkWidget* name_label = gtk_label_new(
248 l10n_util::GetStringUTF8(label_id).c_str()); 286 l10n_util::GetStringUTF8(label_id).c_str());
249 gtk_misc_set_alignment(GTK_MISC(name_label), 1, 0.5); 287 gtk_misc_set_alignment(GTK_MISC(name_label), 1, 0.5);
250 gtk_table_attach(GTK_TABLE(cookie_details_table_), name_label, 288 gtk_table_attach(GTK_TABLE(details_table), name_label,
251 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0); 289 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
252 290
253 *entry = gtk_entry_new(); 291 *entry = gtk_entry_new();
254 292
255 gtk_entry_set_editable(GTK_ENTRY(*entry), FALSE); 293 gtk_entry_set_editable(GTK_ENTRY(*entry), FALSE);
256 gtk_entry_set_has_frame(GTK_ENTRY(*entry), FALSE); 294 gtk_entry_set_has_frame(GTK_ENTRY(*entry), FALSE);
257 gtk_table_attach_defaults(GTK_TABLE(cookie_details_table_), *entry, 295 gtk_table_attach_defaults(GTK_TABLE(details_table), *entry,
258 1, 2, row, row + 1); 296 1, 2, row, row + 1);
259 } 297 }
260 298
261 void CookiesView::SetInitialTreeState() { 299 void CookiesView::SetInitialTreeState() {
262 if (cookies_tree_model_->GetChildCount(cookies_tree_model_->GetRoot())) 300 if (cookies_tree_model_->GetChildCount(cookies_tree_model_->GetRoot()))
263 gtk_tree::SelectAndFocusRowNum(0, GTK_TREE_VIEW(tree_)); 301 gtk_tree::SelectAndFocusRowNum(0, GTK_TREE_VIEW(tree_));
264 } 302 }
265 303
266 void CookiesView::EnableControls() { 304 void CookiesView::EnableControls() {
267 GtkTreeIter iter; 305 GtkTreeIter iter;
268 bool selected = gtk_tree_selection_get_selected(selection_, NULL, &iter); 306 bool selected = gtk_tree_selection_get_selected(selection_, NULL, &iter);
269 gtk_widget_set_sensitive(remove_button_, selected); 307 gtk_widget_set_sensitive(remove_button_, selected);
270 gtk_widget_set_sensitive( 308 gtk_widget_set_sensitive(
271 remove_all_button_, 309 remove_all_button_,
272 cookies_tree_model_->GetChildCount(cookies_tree_model_->GetRoot())); 310 cookies_tree_model_->GetChildCount(cookies_tree_model_->GetRoot()));
273 311
274 const gchar* filter_text = gtk_entry_get_text(GTK_ENTRY(filter_entry_)); 312 const gchar* filter_text = gtk_entry_get_text(GTK_ENTRY(filter_entry_));
275 gtk_widget_set_sensitive(filter_clear_button_, filter_text && *filter_text); 313 gtk_widget_set_sensitive(filter_clear_button_, filter_text && *filter_text);
276 314
277 if (selected) { 315 if (selected) {
278 CookieTreeNode::DetailedInfo detailed_info = 316 CookieTreeNode::DetailedInfo detailed_info =
279 static_cast<CookieTreeNode*>( 317 static_cast<CookieTreeNode*>(
280 cookies_tree_adapter_->GetNode(&iter))->GetDetailedInfo(); 318 cookies_tree_adapter_->GetNode(&iter))->GetDetailedInfo();
281 if (detailed_info.node_type == CookieTreeNode::DetailedInfo::TYPE_COOKIE) { 319 if (detailed_info.node_type == CookieTreeNode::DetailedInfo::TYPE_COOKIE) {
320 UpdateVisibleDetailedInfo(cookie_details_table_);
282 PopulateCookieDetails(detailed_info.cookie->first, 321 PopulateCookieDetails(detailed_info.cookie->first,
283 detailed_info.cookie->second); 322 detailed_info.cookie->second);
323 } else if (detailed_info.node_type ==
324 CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE) {
325 UpdateVisibleDetailedInfo(local_storage_details_table_);
326 PopulateLocalStorageDetails(*detailed_info.local_storage_info);
284 } else { 327 } else {
328 UpdateVisibleDetailedInfo(cookie_details_table_);
285 ClearCookieDetails(); 329 ClearCookieDetails();
286 } 330 }
287 } else { 331 } else {
288 ClearCookieDetails(); 332 ClearCookieDetails();
289 } 333 }
290 } 334 }
291 335
292 void CookiesView::SetCookieDetailsSensitivity(gboolean enabled) { 336 void CookiesView::SetCookieDetailsSensitivity(gboolean enabled) {
293 gtk_widget_set_sensitive(cookie_name_entry_, enabled); 337 gtk_widget_set_sensitive(cookie_name_entry_, enabled);
294 gtk_widget_set_sensitive(cookie_content_entry_, enabled); 338 gtk_widget_set_sensitive(cookie_content_entry_, enabled);
295 gtk_widget_set_sensitive(cookie_domain_entry_, enabled); 339 gtk_widget_set_sensitive(cookie_domain_entry_, enabled);
296 gtk_widget_set_sensitive(cookie_path_entry_, enabled); 340 gtk_widget_set_sensitive(cookie_path_entry_, enabled);
297 gtk_widget_set_sensitive(cookie_send_for_entry_, enabled); 341 gtk_widget_set_sensitive(cookie_send_for_entry_, enabled);
298 gtk_widget_set_sensitive(cookie_created_entry_, enabled); 342 gtk_widget_set_sensitive(cookie_created_entry_, enabled);
299 gtk_widget_set_sensitive(cookie_expires_entry_, enabled); 343 gtk_widget_set_sensitive(cookie_expires_entry_, enabled);
300 } 344 }
301 345
346 void CookiesView::SetLocalStorageDetailsSensitivity(gboolean enabled) {
347 gtk_widget_set_sensitive(local_storage_origin_entry_, enabled);
348 gtk_widget_set_sensitive(local_storage_size_entry_, enabled);
349 gtk_widget_set_sensitive(local_storage_last_modified_entry_, enabled);
350 }
351
302 void CookiesView::PopulateCookieDetails( 352 void CookiesView::PopulateCookieDetails(
303 const std::string& domain, 353 const std::string& domain,
304 const net::CookieMonster::CanonicalCookie& cookie) { 354 const net::CookieMonster::CanonicalCookie& cookie) {
305 gtk_entry_set_text(GTK_ENTRY(cookie_name_entry_), cookie.Name().c_str()); 355 gtk_entry_set_text(GTK_ENTRY(cookie_name_entry_), cookie.Name().c_str());
306 gtk_entry_set_text(GTK_ENTRY(cookie_content_entry_), cookie.Value().c_str()); 356 gtk_entry_set_text(GTK_ENTRY(cookie_content_entry_), cookie.Value().c_str());
307 gtk_entry_set_text(GTK_ENTRY(cookie_domain_entry_), domain.c_str()); 357 gtk_entry_set_text(GTK_ENTRY(cookie_domain_entry_), domain.c_str());
308 gtk_entry_set_text(GTK_ENTRY(cookie_path_entry_), cookie.Path().c_str()); 358 gtk_entry_set_text(GTK_ENTRY(cookie_path_entry_), cookie.Path().c_str());
309 gtk_entry_set_text(GTK_ENTRY(cookie_created_entry_), 359 gtk_entry_set_text(GTK_ENTRY(cookie_created_entry_),
310 WideToUTF8(base::TimeFormatFriendlyDateAndTime( 360 WideToUTF8(base::TimeFormatFriendlyDateAndTime(
311 cookie.CreationDate())).c_str()); 361 cookie.CreationDate())).c_str());
312 if (cookie.DoesExpire()) { 362 if (cookie.DoesExpire()) {
313 gtk_entry_set_text(GTK_ENTRY(cookie_expires_entry_), 363 gtk_entry_set_text(GTK_ENTRY(cookie_expires_entry_),
314 WideToUTF8(base::TimeFormatFriendlyDateAndTime( 364 WideToUTF8(base::TimeFormatFriendlyDateAndTime(
315 cookie.ExpiryDate())).c_str()); 365 cookie.ExpiryDate())).c_str());
316 } else { 366 } else {
317 gtk_entry_set_text(GTK_ENTRY(cookie_expires_entry_), 367 gtk_entry_set_text(GTK_ENTRY(cookie_expires_entry_),
318 l10n_util::GetStringUTF8( 368 l10n_util::GetStringUTF8(
319 IDS_COOKIES_COOKIE_EXPIRES_SESSION).c_str()); 369 IDS_COOKIES_COOKIE_EXPIRES_SESSION).c_str());
320 } 370 }
321 gtk_entry_set_text( 371 gtk_entry_set_text(
322 GTK_ENTRY(cookie_send_for_entry_), 372 GTK_ENTRY(cookie_send_for_entry_),
323 l10n_util::GetStringUTF8(cookie.IsSecure() ? 373 l10n_util::GetStringUTF8(cookie.IsSecure() ?
324 IDS_COOKIES_COOKIE_SENDFOR_SECURE : 374 IDS_COOKIES_COOKIE_SENDFOR_SECURE :
325 IDS_COOKIES_COOKIE_SENDFOR_ANY).c_str()); 375 IDS_COOKIES_COOKIE_SENDFOR_ANY).c_str());
326 SetCookieDetailsSensitivity(TRUE); 376 SetCookieDetailsSensitivity(TRUE);
327 } 377 }
328 378
379 void CookiesView::PopulateLocalStorageDetails(
380 const BrowsingDataLocalStorageHelper::LocalStorageInfo&
381 local_storage_info) {
382 gtk_entry_set_text(GTK_ENTRY(local_storage_origin_entry_),
383 local_storage_info.origin.c_str());
384 gtk_entry_set_text(GTK_ENTRY(local_storage_size_entry_),
385 WideToUTF8(FormatBytes(
386 local_storage_info.size,
387 GetByteDisplayUnits(local_storage_info.size),
388 true)).c_str());
389 gtk_entry_set_text(GTK_ENTRY(local_storage_last_modified_entry_),
390 WideToUTF8(base::TimeFormatFriendlyDateAndTime(
391 local_storage_info.last_modified)).c_str());
392 SetLocalStorageDetailsSensitivity(TRUE);
393 }
394
329 void CookiesView::ClearCookieDetails() { 395 void CookiesView::ClearCookieDetails() {
330 std::string no_cookie = 396 std::string no_cookie =
331 l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_NONESELECTED); 397 l10n_util::GetStringUTF8(IDS_COOKIES_COOKIE_NONESELECTED);
332 gtk_entry_set_text(GTK_ENTRY(cookie_name_entry_), no_cookie.c_str()); 398 gtk_entry_set_text(GTK_ENTRY(cookie_name_entry_), no_cookie.c_str());
333 gtk_entry_set_text(GTK_ENTRY(cookie_content_entry_), no_cookie.c_str()); 399 gtk_entry_set_text(GTK_ENTRY(cookie_content_entry_), no_cookie.c_str());
334 gtk_entry_set_text(GTK_ENTRY(cookie_domain_entry_), no_cookie.c_str()); 400 gtk_entry_set_text(GTK_ENTRY(cookie_domain_entry_), no_cookie.c_str());
335 gtk_entry_set_text(GTK_ENTRY(cookie_path_entry_), no_cookie.c_str()); 401 gtk_entry_set_text(GTK_ENTRY(cookie_path_entry_), no_cookie.c_str());
336 gtk_entry_set_text(GTK_ENTRY(cookie_created_entry_), no_cookie.c_str()); 402 gtk_entry_set_text(GTK_ENTRY(cookie_created_entry_), no_cookie.c_str());
337 gtk_entry_set_text(GTK_ENTRY(cookie_expires_entry_), no_cookie.c_str()); 403 gtk_entry_set_text(GTK_ENTRY(cookie_expires_entry_), no_cookie.c_str());
338 gtk_entry_set_text(GTK_ENTRY(cookie_send_for_entry_), no_cookie.c_str()); 404 gtk_entry_set_text(GTK_ENTRY(cookie_send_for_entry_), no_cookie.c_str());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 EnableControls(); 446 EnableControls();
381 } 447 }
382 448
383 // static 449 // static
384 void CookiesView::OnResponse(GtkDialog* dialog, int response_id, 450 void CookiesView::OnResponse(GtkDialog* dialog, int response_id,
385 CookiesView* window) { 451 CookiesView* window) {
386 if (response_id == RESPONSE_REMOVE) { 452 if (response_id == RESPONSE_REMOVE) {
387 window->RemoveSelectedItems(); 453 window->RemoveSelectedItems();
388 } else if (response_id == RESPONSE_REMOVE_ALL) { 454 } else if (response_id == RESPONSE_REMOVE_ALL) {
389 window->cookies_tree_model_->DeleteAllCookies(); 455 window->cookies_tree_model_->DeleteAllCookies();
456 window->browsing_data_local_storage_helper_->DeleteAllLocalStorageFiles();
390 } else { 457 } else {
391 gtk_widget_destroy(window->dialog_); 458 gtk_widget_destroy(window->dialog_);
392 } 459 }
393 } 460 }
394 461
395 // static 462 // static
396 void CookiesView::OnWindowDestroy(GtkWidget* widget, CookiesView* window) { 463 void CookiesView::OnWindowDestroy(GtkWidget* widget, CookiesView* window) {
397 instance_ = NULL; 464 instance_ = NULL;
398 MessageLoop::current()->DeleteSoon(FROM_HERE, window); 465 MessageLoop::current()->DeleteSoon(FROM_HERE, window);
399 } 466 }
(...skipping 30 matching lines...) Expand all
430 } 497 }
431 498
432 void CookiesView::UpdateFilterResults() { 499 void CookiesView::UpdateFilterResults() {
433 const gchar* text = gtk_entry_get_text(GTK_ENTRY(filter_entry_)); 500 const gchar* text = gtk_entry_get_text(GTK_ENTRY(filter_entry_));
434 if (text) { 501 if (text) {
435 cookies_tree_model_->UpdateSearchResults(UTF8ToWide(text)); 502 cookies_tree_model_->UpdateSearchResults(UTF8ToWide(text));
436 SetInitialTreeState(); 503 SetInitialTreeState();
437 } 504 }
438 } 505 }
439 506
507 void CookiesView::UpdateVisibleDetailedInfo(GtkWidget* table) {
508 // Toggle the parent (the table frame) visibility and sensitivity.
509 gtk_widget_show(gtk_widget_get_parent(table));
510 // Toggle the other tables.
511 if (table == cookie_details_table_) {
512 SetCookieDetailsSensitivity(true);
513 SetLocalStorageDetailsSensitivity(false);
514 gtk_widget_hide(gtk_widget_get_parent(local_storage_details_table_));
515 } else if (table == local_storage_details_table_) {
516 SetCookieDetailsSensitivity(false);
517 SetLocalStorageDetailsSensitivity(true);
518 gtk_widget_hide(gtk_widget_get_parent(cookie_details_table_));
519 }
520 }
521
440 // static 522 // static
441 void CookiesView::OnFilterEntryActivated(GtkEntry* entry, CookiesView* window) { 523 void CookiesView::OnFilterEntryActivated(GtkEntry* entry, CookiesView* window) {
442 window->filter_update_factory_.RevokeAll(); 524 window->filter_update_factory_.RevokeAll();
443 window->UpdateFilterResults(); 525 window->UpdateFilterResults();
444 } 526 }
445 527
446 // static 528 // static
447 void CookiesView::OnFilterEntryChanged(GtkEditable* editable, 529 void CookiesView::OnFilterEntryChanged(GtkEditable* editable,
448 CookiesView* window) { 530 CookiesView* window) {
449 window->filter_update_factory_.RevokeAll(); 531 window->filter_update_factory_.RevokeAll();
450 MessageLoop::current()->PostDelayedTask(FROM_HERE, 532 MessageLoop::current()->PostDelayedTask(FROM_HERE,
451 window->filter_update_factory_.NewRunnableMethod( 533 window->filter_update_factory_.NewRunnableMethod(
452 &CookiesView::UpdateFilterResults), kSearchFilterDelayMs); 534 &CookiesView::UpdateFilterResults), kSearchFilterDelayMs);
453 window->EnableControls(); 535 window->EnableControls();
454 } 536 }
455 537
456 // static 538 // static
457 void CookiesView::OnFilterClearButtonClicked(GtkButton* button, 539 void CookiesView::OnFilterClearButtonClicked(GtkButton* button,
458 CookiesView* window) { 540 CookiesView* window) {
459 gtk_entry_set_text(GTK_ENTRY(window->filter_entry_), ""); 541 gtk_entry_set_text(GTK_ENTRY(window->filter_entry_), "");
460 window->filter_update_factory_.RevokeAll(); 542 window->filter_update_factory_.RevokeAll();
461 window->UpdateFilterResults(); 543 window->UpdateFilterResults();
462 } 544 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/options/cookies_view.h ('k') | chrome/browser/gtk/options/cookies_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698