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/views/collected_cookies_views.h" | 5 #include "chrome/browser/ui/views/collected_cookies_views.h" |
6 | 6 |
7 #include "chrome/browser/browsing_data_appcache_helper.h" | 7 #include "chrome/browser/browsing_data_appcache_helper.h" |
8 #include "chrome/browser/browsing_data_cookie_helper.h" | 8 #include "chrome/browser/browsing_data_cookie_helper.h" |
9 #include "chrome/browser/browsing_data_database_helper.h" | 9 #include "chrome/browser/browsing_data_database_helper.h" |
10 #include "chrome/browser/browsing_data_file_system_helper.h" | 10 #include "chrome/browser/browsing_data_file_system_helper.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 allowed_cookies_tree_model_.reset( | 335 allowed_cookies_tree_model_.reset( |
336 new CookiesTreeModel(allowed_lsos.cookies()->Clone(), | 336 new CookiesTreeModel(allowed_lsos.cookies()->Clone(), |
337 allowed_lsos.databases()->Clone(), | 337 allowed_lsos.databases()->Clone(), |
338 allowed_lsos.local_storages()->Clone(), | 338 allowed_lsos.local_storages()->Clone(), |
339 allowed_lsos.session_storages()->Clone(), | 339 allowed_lsos.session_storages()->Clone(), |
340 allowed_lsos.appcaches()->Clone(), | 340 allowed_lsos.appcaches()->Clone(), |
341 allowed_lsos.indexed_dbs()->Clone(), | 341 allowed_lsos.indexed_dbs()->Clone(), |
342 allowed_lsos.file_systems()->Clone(), | 342 allowed_lsos.file_systems()->Clone(), |
343 NULL, | 343 NULL, |
344 allowed_lsos.server_bound_certs()->Clone(), | 344 allowed_lsos.server_bound_certs()->Clone(), |
| 345 NULL, |
345 true)); | 346 true)); |
346 allowed_cookies_tree_ = new views::TreeView(); | 347 allowed_cookies_tree_ = new views::TreeView(); |
347 allowed_cookies_tree_->SetModel(allowed_cookies_tree_model_.get()); | 348 allowed_cookies_tree_->SetModel(allowed_cookies_tree_model_.get()); |
348 allowed_cookies_tree_->SetRootShown(false); | 349 allowed_cookies_tree_->SetRootShown(false); |
349 allowed_cookies_tree_->SetEditable(false); | 350 allowed_cookies_tree_->SetEditable(false); |
350 allowed_cookies_tree_->set_lines_at_root(true); | 351 allowed_cookies_tree_->set_lines_at_root(true); |
351 allowed_cookies_tree_->set_auto_expand_children(true); | 352 allowed_cookies_tree_->set_auto_expand_children(true); |
352 allowed_cookies_tree_->SetController(this); | 353 allowed_cookies_tree_->SetController(this); |
353 | 354 |
354 block_allowed_button_ = new views::NativeTextButton(this, | 355 block_allowed_button_ = new views::NativeTextButton(this, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 blocked_cookies_tree_model_.reset( | 404 blocked_cookies_tree_model_.reset( |
404 new CookiesTreeModel(blocked_lsos.cookies()->Clone(), | 405 new CookiesTreeModel(blocked_lsos.cookies()->Clone(), |
405 blocked_lsos.databases()->Clone(), | 406 blocked_lsos.databases()->Clone(), |
406 blocked_lsos.local_storages()->Clone(), | 407 blocked_lsos.local_storages()->Clone(), |
407 blocked_lsos.session_storages()->Clone(), | 408 blocked_lsos.session_storages()->Clone(), |
408 blocked_lsos.appcaches()->Clone(), | 409 blocked_lsos.appcaches()->Clone(), |
409 blocked_lsos.indexed_dbs()->Clone(), | 410 blocked_lsos.indexed_dbs()->Clone(), |
410 blocked_lsos.file_systems()->Clone(), | 411 blocked_lsos.file_systems()->Clone(), |
411 NULL, | 412 NULL, |
412 blocked_lsos.server_bound_certs()->Clone(), | 413 blocked_lsos.server_bound_certs()->Clone(), |
| 414 NULL, |
413 true)); | 415 true)); |
414 blocked_cookies_tree_ = new views::TreeView(); | 416 blocked_cookies_tree_ = new views::TreeView(); |
415 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); | 417 blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get()); |
416 blocked_cookies_tree_->SetRootShown(false); | 418 blocked_cookies_tree_->SetRootShown(false); |
417 blocked_cookies_tree_->SetEditable(false); | 419 blocked_cookies_tree_->SetEditable(false); |
418 blocked_cookies_tree_->set_lines_at_root(true); | 420 blocked_cookies_tree_->set_lines_at_root(true); |
419 blocked_cookies_tree_->set_auto_expand_children(true); | 421 blocked_cookies_tree_->set_auto_expand_children(true); |
420 blocked_cookies_tree_->SetController(this); | 422 blocked_cookies_tree_->SetController(this); |
421 | 423 |
422 allow_blocked_button_ = new views::NativeTextButton(this, | 424 allow_blocked_button_ = new views::NativeTextButton(this, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 463 |
462 return pane; | 464 return pane; |
463 } | 465 } |
464 | 466 |
465 void CollectedCookiesViews::EnableControls() { | 467 void CollectedCookiesViews::EnableControls() { |
466 bool enable_allowed_buttons = false; | 468 bool enable_allowed_buttons = false; |
467 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode(); | 469 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode(); |
468 if (node) { | 470 if (node) { |
469 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); | 471 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); |
470 if (cookie_node->GetDetailedInfo().node_type == | 472 if (cookie_node->GetDetailedInfo().node_type == |
471 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) { | 473 CookieTreeNode::DetailedInfo::TYPE_HOST) { |
472 enable_allowed_buttons = static_cast<CookieTreeOriginNode*>( | 474 enable_allowed_buttons = static_cast<CookieTreeHostNode*>( |
473 cookie_node)->CanCreateContentException(); | 475 cookie_node)->CanCreateContentException(); |
474 } | 476 } |
475 } | 477 } |
476 block_allowed_button_->SetEnabled(enable_allowed_buttons); | 478 block_allowed_button_->SetEnabled(enable_allowed_buttons); |
477 | 479 |
478 bool enable_blocked_buttons = false; | 480 bool enable_blocked_buttons = false; |
479 node = blocked_cookies_tree_->GetSelectedNode(); | 481 node = blocked_cookies_tree_->GetSelectedNode(); |
480 if (node) { | 482 if (node) { |
481 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); | 483 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); |
482 if (cookie_node->GetDetailedInfo().node_type == | 484 if (cookie_node->GetDetailedInfo().node_type == |
483 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) { | 485 CookieTreeNode::DetailedInfo::TYPE_HOST) { |
484 enable_blocked_buttons = static_cast<CookieTreeOriginNode*>( | 486 enable_blocked_buttons = static_cast<CookieTreeHostNode*>( |
485 cookie_node)->CanCreateContentException(); | 487 cookie_node)->CanCreateContentException(); |
486 } | 488 } |
487 } | 489 } |
488 allow_blocked_button_->SetEnabled(enable_blocked_buttons); | 490 allow_blocked_button_->SetEnabled(enable_blocked_buttons); |
489 for_session_blocked_button_->SetEnabled(enable_blocked_buttons); | 491 for_session_blocked_button_->SetEnabled(enable_blocked_buttons); |
490 } | 492 } |
491 | 493 |
492 void CollectedCookiesViews::ShowCookieInfo() { | 494 void CollectedCookiesViews::ShowCookieInfo() { |
493 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode(); | 495 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode(); |
494 if (!node) | 496 if (!node) |
(...skipping 10 matching lines...) Expand all Loading... |
505 } else { | 507 } else { |
506 cookie_info_view_->ClearCookieDisplay(); | 508 cookie_info_view_->ClearCookieDisplay(); |
507 } | 509 } |
508 } else { | 510 } else { |
509 cookie_info_view_->ClearCookieDisplay(); | 511 cookie_info_view_->ClearCookieDisplay(); |
510 } | 512 } |
511 } | 513 } |
512 | 514 |
513 void CollectedCookiesViews::AddContentException(views::TreeView* tree_view, | 515 void CollectedCookiesViews::AddContentException(views::TreeView* tree_view, |
514 ContentSetting setting) { | 516 ContentSetting setting) { |
515 CookieTreeOriginNode* origin_node = | 517 CookieTreeHostNode* host_node = |
516 static_cast<CookieTreeOriginNode*>(tree_view->GetSelectedNode()); | 518 static_cast<CookieTreeHostNode*>(tree_view->GetSelectedNode()); |
517 Profile* profile = tab_contents_->profile(); | 519 Profile* profile = tab_contents_->profile(); |
518 origin_node->CreateContentException( | 520 host_node->CreateContentException( |
519 CookieSettings::Factory::GetForProfile(profile), setting); | 521 CookieSettings::Factory::GetForProfile(profile), setting); |
520 infobar_->UpdateVisibility(true, setting, origin_node->GetTitle()); | 522 infobar_->UpdateVisibility(true, setting, host_node->GetTitle()); |
521 status_changed_ = true; | 523 status_changed_ = true; |
522 } | 524 } |
523 | 525 |
524 /////////////////////////////////////////////////////////////////////////////// | 526 /////////////////////////////////////////////////////////////////////////////// |
525 // CollectedCookiesViews, content::NotificationObserver implementation: | 527 // CollectedCookiesViews, content::NotificationObserver implementation: |
526 | 528 |
527 void CollectedCookiesViews::Observe( | 529 void CollectedCookiesViews::Observe( |
528 int type, | 530 int type, |
529 const content::NotificationSource& source, | 531 const content::NotificationSource& source, |
530 const content::NotificationDetails& details) { | 532 const content::NotificationDetails& details) { |
531 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); | 533 DCHECK(type == chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN); |
532 window_->CloseConstrainedWindow(); | 534 window_->CloseConstrainedWindow(); |
533 } | 535 } |
OLD | NEW |