OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/ui/gtk/collected_cookies_gtk.h" | 5 #include "chrome/browser/ui/gtk/collected_cookies_gtk.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include "chrome/browser/browsing_data_appcache_helper.h" | 8 #include "chrome/browser/browsing_data_appcache_helper.h" |
9 #include "chrome/browser/browsing_data_cookie_helper.h" | 9 #include "chrome/browser/browsing_data_cookie_helper.h" |
10 #include "chrome/browser/browsing_data_database_helper.h" | 10 #include "chrome/browser/browsing_data_database_helper.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 allowed_cookies_tree_model_.reset( | 216 allowed_cookies_tree_model_.reset( |
217 new CookiesTreeModel(allowed_lsos.cookies()->Clone(), | 217 new CookiesTreeModel(allowed_lsos.cookies()->Clone(), |
218 allowed_lsos.databases()->Clone(), | 218 allowed_lsos.databases()->Clone(), |
219 allowed_lsos.local_storages()->Clone(), | 219 allowed_lsos.local_storages()->Clone(), |
220 allowed_lsos.session_storages()->Clone(), | 220 allowed_lsos.session_storages()->Clone(), |
221 allowed_lsos.appcaches()->Clone(), | 221 allowed_lsos.appcaches()->Clone(), |
222 allowed_lsos.indexed_dbs()->Clone(), | 222 allowed_lsos.indexed_dbs()->Clone(), |
223 allowed_lsos.file_systems()->Clone(), | 223 allowed_lsos.file_systems()->Clone(), |
224 NULL, | 224 NULL, |
225 allowed_lsos.server_bound_certs()->Clone(), | 225 allowed_lsos.server_bound_certs()->Clone(), |
| 226 NULL, |
226 true)); | 227 true)); |
227 allowed_cookies_tree_adapter_.reset( | 228 allowed_cookies_tree_adapter_.reset( |
228 new gtk_tree::TreeAdapter(this, allowed_cookies_tree_model_.get())); | 229 new gtk_tree::TreeAdapter(this, allowed_cookies_tree_model_.get())); |
229 allowed_tree_ = gtk_tree_view_new_with_model( | 230 allowed_tree_ = gtk_tree_view_new_with_model( |
230 GTK_TREE_MODEL(allowed_cookies_tree_adapter_->tree_store())); | 231 GTK_TREE_MODEL(allowed_cookies_tree_adapter_->tree_store())); |
231 gtk_widget_set_size_request(allowed_tree_, kTreeViewWidth, kTreeViewHeight); | 232 gtk_widget_set_size_request(allowed_tree_, kTreeViewWidth, kTreeViewHeight); |
232 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(allowed_tree_), FALSE); | 233 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(allowed_tree_), FALSE); |
233 gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(allowed_tree_), TRUE); | 234 gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(allowed_tree_), TRUE); |
234 gtk_container_add(GTK_CONTAINER(scroll_window), allowed_tree_); | 235 gtk_container_add(GTK_CONTAINER(scroll_window), allowed_tree_); |
235 | 236 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 blocked_cookies_tree_model_.reset( | 306 blocked_cookies_tree_model_.reset( |
306 new CookiesTreeModel(blocked_lsos.cookies()->Clone(), | 307 new CookiesTreeModel(blocked_lsos.cookies()->Clone(), |
307 blocked_lsos.databases()->Clone(), | 308 blocked_lsos.databases()->Clone(), |
308 blocked_lsos.local_storages()->Clone(), | 309 blocked_lsos.local_storages()->Clone(), |
309 blocked_lsos.session_storages()->Clone(), | 310 blocked_lsos.session_storages()->Clone(), |
310 blocked_lsos.appcaches()->Clone(), | 311 blocked_lsos.appcaches()->Clone(), |
311 blocked_lsos.indexed_dbs()->Clone(), | 312 blocked_lsos.indexed_dbs()->Clone(), |
312 blocked_lsos.file_systems()->Clone(), | 313 blocked_lsos.file_systems()->Clone(), |
313 NULL, | 314 NULL, |
314 blocked_lsos.server_bound_certs()->Clone(), | 315 blocked_lsos.server_bound_certs()->Clone(), |
| 316 NULL, |
315 true)); | 317 true)); |
316 blocked_cookies_tree_adapter_.reset( | 318 blocked_cookies_tree_adapter_.reset( |
317 new gtk_tree::TreeAdapter(this, blocked_cookies_tree_model_.get())); | 319 new gtk_tree::TreeAdapter(this, blocked_cookies_tree_model_.get())); |
318 blocked_tree_ = gtk_tree_view_new_with_model( | 320 blocked_tree_ = gtk_tree_view_new_with_model( |
319 GTK_TREE_MODEL(blocked_cookies_tree_adapter_->tree_store())); | 321 GTK_TREE_MODEL(blocked_cookies_tree_adapter_->tree_store())); |
320 gtk_widget_set_size_request(blocked_tree_, kTreeViewWidth, kTreeViewHeight); | 322 gtk_widget_set_size_request(blocked_tree_, kTreeViewWidth, kTreeViewHeight); |
321 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(blocked_tree_), FALSE); | 323 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(blocked_tree_), FALSE); |
322 gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(blocked_tree_), TRUE); | 324 gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(blocked_tree_), TRUE); |
323 gtk_container_add(GTK_CONTAINER(scroll_window), blocked_tree_); | 325 gtk_container_add(GTK_CONTAINER(scroll_window), blocked_tree_); |
324 | 326 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 } | 417 } |
416 | 418 |
417 GtkWidget* CollectedCookiesGtk::GetFocusWidget() { | 419 GtkWidget* CollectedCookiesGtk::GetFocusWidget() { |
418 return close_button_; | 420 return close_button_; |
419 } | 421 } |
420 | 422 |
421 void CollectedCookiesGtk::DeleteDelegate() { | 423 void CollectedCookiesGtk::DeleteDelegate() { |
422 delete this; | 424 delete this; |
423 } | 425 } |
424 | 426 |
425 bool CollectedCookiesGtk::SelectionContainsOriginNode( | 427 bool CollectedCookiesGtk::SelectionContainsHostNode( |
426 GtkTreeSelection* selection, gtk_tree::TreeAdapter* adapter) { | 428 GtkTreeSelection* selection, gtk_tree::TreeAdapter* adapter) { |
427 // Check whether at least one "origin" node is selected. | 429 // Check whether at least one "origin" node is selected. |
428 GtkTreeModel* model; | 430 GtkTreeModel* model; |
429 GList* paths = | 431 GList* paths = |
430 gtk_tree_selection_get_selected_rows(selection, &model); | 432 gtk_tree_selection_get_selected_rows(selection, &model); |
431 bool contains_origin_node = false; | 433 bool contains_host_node = false; |
432 for (GList* item = paths; item; item = item->next) { | 434 for (GList* item = paths; item; item = item->next) { |
433 GtkTreeIter iter; | 435 GtkTreeIter iter; |
434 gtk_tree_model_get_iter( | 436 gtk_tree_model_get_iter( |
435 model, &iter, reinterpret_cast<GtkTreePath*>(item->data)); | 437 model, &iter, reinterpret_cast<GtkTreePath*>(item->data)); |
436 CookieTreeNode* node = | 438 CookieTreeNode* node = |
437 static_cast<CookieTreeNode*>(adapter->GetNode(&iter)); | 439 static_cast<CookieTreeNode*>(adapter->GetNode(&iter)); |
438 if (node->GetDetailedInfo().node_type != | 440 if (node->GetDetailedInfo().node_type != |
439 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) | 441 CookieTreeNode::DetailedInfo::TYPE_HOST) |
440 continue; | 442 continue; |
441 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( | 443 CookieTreeHostNode* host_node = static_cast<CookieTreeHostNode*>( |
442 node); | 444 node); |
443 if (!origin_node->CanCreateContentException()) | 445 if (!host_node->CanCreateContentException()) |
444 continue; | 446 continue; |
445 contains_origin_node = true; | 447 contains_host_node = true; |
446 } | 448 } |
447 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); | 449 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
448 g_list_free(paths); | 450 g_list_free(paths); |
449 return contains_origin_node; | 451 return contains_host_node; |
450 } | 452 } |
451 | 453 |
452 void CollectedCookiesGtk::EnableControls() { | 454 void CollectedCookiesGtk::EnableControls() { |
453 // Update button states. | 455 // Update button states. |
454 bool enable_for_allowed_cookies = | 456 bool enable_for_allowed_cookies = |
455 SelectionContainsOriginNode(allowed_selection_, | 457 SelectionContainsHostNode(allowed_selection_, |
456 allowed_cookies_tree_adapter_.get()); | 458 allowed_cookies_tree_adapter_.get()); |
457 gtk_widget_set_sensitive(block_allowed_cookie_button_, | 459 gtk_widget_set_sensitive(block_allowed_cookie_button_, |
458 enable_for_allowed_cookies); | 460 enable_for_allowed_cookies); |
459 | 461 |
460 bool enable_for_blocked_cookies = | 462 bool enable_for_blocked_cookies = |
461 SelectionContainsOriginNode(blocked_selection_, | 463 SelectionContainsHostNode(blocked_selection_, |
462 blocked_cookies_tree_adapter_.get()); | 464 blocked_cookies_tree_adapter_.get()); |
463 gtk_widget_set_sensitive(allow_blocked_cookie_button_, | 465 gtk_widget_set_sensitive(allow_blocked_cookie_button_, |
464 enable_for_blocked_cookies); | 466 enable_for_blocked_cookies); |
465 gtk_widget_set_sensitive(for_session_blocked_cookie_button_, | 467 gtk_widget_set_sensitive(for_session_blocked_cookie_button_, |
466 enable_for_blocked_cookies); | 468 enable_for_blocked_cookies); |
467 } | 469 } |
468 | 470 |
469 void CollectedCookiesGtk::Observe(int type, | 471 void CollectedCookiesGtk::Observe(int type, |
470 const content::NotificationSource& source, | 472 const content::NotificationSource& source, |
471 const content::NotificationDetails& details) { | 473 const content::NotificationDetails& details) { |
(...skipping 18 matching lines...) Expand all Loading... |
490 gtk_tree_selection_get_selected_rows(selection, &model); | 492 gtk_tree_selection_get_selected_rows(selection, &model); |
491 string16 last_domain_name; | 493 string16 last_domain_name; |
492 bool multiple_domains_added = false; | 494 bool multiple_domains_added = false; |
493 for (GList* item = paths; item; item = item->next) { | 495 for (GList* item = paths; item; item = item->next) { |
494 GtkTreeIter iter; | 496 GtkTreeIter iter; |
495 gtk_tree_model_get_iter( | 497 gtk_tree_model_get_iter( |
496 model, &iter, reinterpret_cast<GtkTreePath*>(item->data)); | 498 model, &iter, reinterpret_cast<GtkTreePath*>(item->data)); |
497 CookieTreeNode* node = | 499 CookieTreeNode* node = |
498 static_cast<CookieTreeNode*>(adapter->GetNode(&iter)); | 500 static_cast<CookieTreeNode*>(adapter->GetNode(&iter)); |
499 if (node->GetDetailedInfo().node_type != | 501 if (node->GetDetailedInfo().node_type != |
500 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) | 502 CookieTreeNode::DetailedInfo::TYPE_HOST) |
501 continue; | 503 continue; |
502 CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( | 504 CookieTreeHostNode* host_node = static_cast<CookieTreeHostNode*>( |
503 node); | 505 node); |
504 if (origin_node->CanCreateContentException()) { | 506 if (host_node->CanCreateContentException()) { |
505 if (!last_domain_name.empty()) | 507 if (!last_domain_name.empty()) |
506 multiple_domains_added = true; | 508 multiple_domains_added = true; |
507 last_domain_name = origin_node->GetTitle(); | 509 last_domain_name = host_node->GetTitle(); |
508 Profile* profile = tab_contents_->profile(); | 510 Profile* profile = tab_contents_->profile(); |
509 origin_node->CreateContentException( | 511 host_node->CreateContentException( |
510 CookieSettings::Factory::GetForProfile(profile), setting); | 512 CookieSettings::Factory::GetForProfile(profile), setting); |
511 } | 513 } |
512 } | 514 } |
513 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); | 515 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
514 g_list_free(paths); | 516 g_list_free(paths); |
515 if (last_domain_name.empty()) { | 517 if (last_domain_name.empty()) { |
516 gtk_widget_hide(infobar_); | 518 gtk_widget_hide(infobar_); |
517 } else { | 519 } else { |
518 gtk_label_set_text( | 520 gtk_label_set_text( |
519 GTK_LABEL(infobar_label_), GetInfobarLabel( | 521 GTK_LABEL(infobar_label_), GetInfobarLabel( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 555 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
554 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); | 556 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree_view), path, TRUE); |
555 g_signal_handlers_unblock_by_func( | 557 g_signal_handlers_unblock_by_func( |
556 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); | 558 tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this); |
557 } | 559 } |
558 | 560 |
559 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { | 561 void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) { |
560 EnableControls(); | 562 EnableControls(); |
561 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); | 563 ShowCookieInfo(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook_))); |
562 } | 564 } |
OLD | NEW |