| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h" |
| 9 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" | 9 #include "chrome/browser/browsing_data/browsing_data_channel_id_helper.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 const int kTreeViewWidth = 400; | 64 const int kTreeViewWidth = 400; |
| 65 const int kTreeViewHeight = 125; | 65 const int kTreeViewHeight = 125; |
| 66 | 66 |
| 67 // The color of the border around the cookies tree view. | 67 // The color of the border around the cookies tree view. |
| 68 const SkColor kCookiesBorderColor = SkColorSetRGB(0xC8, 0xC8, 0xC8); | 68 const SkColor kCookiesBorderColor = SkColorSetRGB(0xC8, 0xC8, 0xC8); |
| 69 | 69 |
| 70 // Spacing constants used with non-Harmony dialogs. | 70 // Spacing constants used with non-Harmony dialogs. |
| 71 const int kTabbedPaneTopPadding = 14; | 71 const int kTabbedPaneTopPadding = 14; |
| 72 const int kCookieInfoBottomPadding = 4; | 72 const int kCookieInfoBottomPadding = 4; |
| 73 | 73 |
| 74 void AddButtonColumnSet(views::GridLayout* layout, const int column_layout_id) { |
| 75 using views::GridLayout; |
| 76 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); |
| 77 const int button_padding = layout_delegate->GetMetric( |
| 78 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING); |
| 79 const int button_size_limit = layout_delegate->GetMetric( |
| 80 LayoutDelegate::Metric::BUTTON_MAX_SHARED_WIDTH); |
| 81 |
| 82 views::ColumnSet* column_set = layout->AddColumnSet(column_layout_id); |
| 83 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, |
| 84 GridLayout::USE_PREF, 0, 0); |
| 85 column_set->AddPaddingColumn(0, button_padding); |
| 86 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, |
| 87 GridLayout::USE_PREF, 0, 0); |
| 88 column_set->LinkColumnSizes(0, 2, -1); |
| 89 column_set->set_linked_column_size_limit(button_size_limit); |
| 90 layout->StartRow(0, column_layout_id); |
| 91 } |
| 92 |
| 74 } // namespace | 93 } // namespace |
| 75 | 94 |
| 76 // A custom view that conditionally displays an infobar. | 95 // A custom view that conditionally displays an infobar. |
| 77 class InfobarView : public views::View { | 96 class InfobarView : public views::View { |
| 78 public: | 97 public: |
| 79 InfobarView() { | 98 InfobarView() { |
| 80 content_ = new views::View; | 99 content_ = new views::View; |
| 81 SkColor border_color = SK_ColorGRAY; | 100 SkColor border_color = SK_ColorGRAY; |
| 82 content_->SetBorder( | 101 content_->SetBorder( |
| 83 views::CreateSolidBorder(kInfobarBorderSize, border_color)); | 102 views::CreateSolidBorder(kInfobarBorderSize, border_color)); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 using views::GridLayout; | 390 using views::GridLayout; |
| 372 | 391 |
| 373 views::View* pane = new views::View(); | 392 views::View* pane = new views::View(); |
| 374 GridLayout* layout = layout_utils::CreatePanelLayout(pane); | 393 GridLayout* layout = layout_utils::CreatePanelLayout(pane); |
| 375 | 394 |
| 376 const int single_column_layout_id = 0; | 395 const int single_column_layout_id = 0; |
| 377 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 396 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |
| 378 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 397 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
| 379 GridLayout::USE_PREF, 0, 0); | 398 GridLayout::USE_PREF, 0, 0); |
| 380 | 399 |
| 381 const int three_columns_layout_id = 1; | |
| 382 column_set = layout->AddColumnSet(three_columns_layout_id); | |
| 383 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | |
| 384 GridLayout::USE_PREF, 0, 0); | |
| 385 column_set->AddPaddingColumn( | |
| 386 0, | |
| 387 LayoutDelegate::Get()->GetMetric( | |
| 388 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING)); | |
| 389 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | |
| 390 GridLayout::USE_PREF, 0, 0); | |
| 391 | |
| 392 layout->StartRow(0, single_column_layout_id); | 400 layout->StartRow(0, single_column_layout_id); |
| 393 layout->AddView(allowed_label_); | 401 layout->AddView(allowed_label_); |
| 394 layout->AddPaddingRow( | 402 layout->AddPaddingRow( |
| 395 0, | 403 0, |
| 396 LayoutDelegate::Get()->GetMetric( | 404 LayoutDelegate::Get()->GetMetric( |
| 397 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); | 405 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
| 398 | 406 |
| 399 layout->StartRow(1, single_column_layout_id); | 407 layout->StartRow(1, single_column_layout_id); |
| 400 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, | 408 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, |
| 401 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, | 409 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, |
| 402 kTreeViewHeight); | 410 kTreeViewHeight); |
| 403 layout->AddPaddingRow( | 411 layout->AddPaddingRow( |
| 404 0, LayoutDelegate::Get()->GetMetric( | 412 0, LayoutDelegate::Get()->GetMetric( |
| 405 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); | 413 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
| 406 | 414 |
| 407 layout->StartRow(0, three_columns_layout_id); | 415 AddButtonColumnSet(layout, single_column_layout_id + 1); |
| 408 layout->AddView(block_allowed_button_); | 416 layout->AddView(block_allowed_button_); |
| 409 layout->AddView(delete_allowed_button_); | 417 layout->AddView(delete_allowed_button_); |
| 410 | 418 |
| 411 return pane; | 419 return pane; |
| 412 } | 420 } |
| 413 | 421 |
| 414 views::View* CollectedCookiesViews::CreateBlockedPane() { | 422 views::View* CollectedCookiesViews::CreateBlockedPane() { |
| 415 TabSpecificContentSettings* content_settings = | 423 TabSpecificContentSettings* content_settings = |
| 416 TabSpecificContentSettings::FromWebContents(web_contents_); | 424 TabSpecificContentSettings::FromWebContents(web_contents_); |
| 417 | 425 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 448 using views::GridLayout; | 456 using views::GridLayout; |
| 449 | 457 |
| 450 views::View* pane = new views::View(); | 458 views::View* pane = new views::View(); |
| 451 GridLayout* layout = layout_utils::CreatePanelLayout(pane); | 459 GridLayout* layout = layout_utils::CreatePanelLayout(pane); |
| 452 | 460 |
| 453 const int single_column_layout_id = 0; | 461 const int single_column_layout_id = 0; |
| 454 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 462 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |
| 455 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 463 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
| 456 GridLayout::USE_PREF, 0, 0); | 464 GridLayout::USE_PREF, 0, 0); |
| 457 | 465 |
| 458 const int three_columns_layout_id = 1; | |
| 459 column_set = layout->AddColumnSet(three_columns_layout_id); | |
| 460 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | |
| 461 GridLayout::USE_PREF, 0, 0); | |
| 462 column_set->AddPaddingColumn( | |
| 463 0, | |
| 464 LayoutDelegate::Get()->GetMetric( | |
| 465 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING)); | |
| 466 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | |
| 467 GridLayout::USE_PREF, 0, 0); | |
| 468 | |
| 469 layout->StartRow(0, single_column_layout_id); | 466 layout->StartRow(0, single_column_layout_id); |
| 470 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); | 467 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); |
| 471 layout->AddPaddingRow( | 468 layout->AddPaddingRow( |
| 472 0, | 469 0, |
| 473 LayoutDelegate::Get()->GetMetric( | 470 LayoutDelegate::Get()->GetMetric( |
| 474 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); | 471 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
| 475 | 472 |
| 476 layout->StartRow(1, single_column_layout_id); | 473 layout->StartRow(1, single_column_layout_id); |
| 477 layout->AddView( | 474 layout->AddView( |
| 478 CreateScrollView(blocked_cookies_tree_), 1, 1, | 475 CreateScrollView(blocked_cookies_tree_), 1, 1, |
| 479 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); | 476 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); |
| 480 layout->AddPaddingRow( | 477 layout->AddPaddingRow( |
| 481 0, LayoutDelegate::Get()->GetMetric( | 478 0, LayoutDelegate::Get()->GetMetric( |
| 482 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); | 479 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
| 483 | 480 |
| 484 layout->StartRow(0, three_columns_layout_id); | 481 AddButtonColumnSet(layout, single_column_layout_id + 1); |
| 485 layout->AddView(allow_blocked_button_); | 482 layout->AddView(allow_blocked_button_); |
| 486 layout->AddView(for_session_blocked_button_); | 483 layout->AddView(for_session_blocked_button_); |
| 487 | 484 |
| 488 return pane; | 485 return pane; |
| 489 } | 486 } |
| 490 | 487 |
| 491 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { | 488 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { |
| 492 views::ScrollView* scroll_view = new views::ScrollView(); | 489 views::ScrollView* scroll_view = new views::ScrollView(); |
| 493 scroll_view->SetContents(pane); | 490 scroll_view->SetContents(pane); |
| 494 scroll_view->SetBorder(views::CreateSolidBorder(1, kCookiesBorderColor)); | 491 scroll_view->SetBorder(views::CreateSolidBorder(1, kCookiesBorderColor)); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 /////////////////////////////////////////////////////////////////////////////// | 558 /////////////////////////////////////////////////////////////////////////////// |
| 562 // CollectedCookiesViews, content::NotificationObserver implementation: | 559 // CollectedCookiesViews, content::NotificationObserver implementation: |
| 563 | 560 |
| 564 void CollectedCookiesViews::Observe( | 561 void CollectedCookiesViews::Observe( |
| 565 int type, | 562 int type, |
| 566 const content::NotificationSource& source, | 563 const content::NotificationSource& source, |
| 567 const content::NotificationDetails& details) { | 564 const content::NotificationDetails& details) { |
| 568 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); | 565 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); |
| 569 GetWidget()->Close(); | 566 GetWidget()->Close(); |
| 570 } | 567 } |
| OLD | NEW |