| 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 LayoutDelegate::Metric GetTreeviewToButtonsMetric() { | |
| 75 // Hack: in the Harmony specs, the buttons under the treeview are "unrelated" | |
| 76 // to it (which looks better), but in the existing dialog they were related. | |
| 77 return LayoutDelegate::Get()->IsHarmonyMode() | |
| 78 ? LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING | |
| 79 : LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING; | |
| 80 } | |
| 81 | |
| 82 } // namespace | 74 } // namespace |
| 83 | 75 |
| 84 // A custom view that conditionally displays an infobar. | 76 // A custom view that conditionally displays an infobar. |
| 85 class InfobarView : public views::View { | 77 class InfobarView : public views::View { |
| 86 public: | 78 public: |
| 87 InfobarView() { | 79 InfobarView() { |
| 88 content_ = new views::View; | 80 content_ = new views::View; |
| 89 SkColor border_color = SK_ColorGRAY; | 81 SkColor border_color = SK_ColorGRAY; |
| 90 content_->SetBorder( | 82 content_->SetBorder( |
| 91 views::CreateSolidBorder(kInfobarBorderSize, border_color)); | 83 views::CreateSolidBorder(kInfobarBorderSize, border_color)); |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 layout->AddPaddingRow( | 394 layout->AddPaddingRow( |
| 403 0, | 395 0, |
| 404 LayoutDelegate::Get()->GetMetric( | 396 LayoutDelegate::Get()->GetMetric( |
| 405 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); | 397 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
| 406 | 398 |
| 407 layout->StartRow(1, single_column_layout_id); | 399 layout->StartRow(1, single_column_layout_id); |
| 408 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, | 400 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, |
| 409 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, | 401 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, |
| 410 kTreeViewHeight); | 402 kTreeViewHeight); |
| 411 layout->AddPaddingRow( | 403 layout->AddPaddingRow( |
| 412 0, LayoutDelegate::Get()->GetMetric(GetTreeviewToButtonsMetric())); | 404 0, LayoutDelegate::Get()->GetMetric( |
| 405 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
| 413 | 406 |
| 414 layout->StartRow(0, three_columns_layout_id); | 407 layout->StartRow(0, three_columns_layout_id); |
| 415 layout->AddView(block_allowed_button_); | 408 layout->AddView(block_allowed_button_); |
| 416 layout->AddView(delete_allowed_button_); | 409 layout->AddView(delete_allowed_button_); |
| 417 | 410 |
| 418 return pane; | 411 return pane; |
| 419 } | 412 } |
| 420 | 413 |
| 421 views::View* CollectedCookiesViews::CreateBlockedPane() { | 414 views::View* CollectedCookiesViews::CreateBlockedPane() { |
| 422 TabSpecificContentSettings* content_settings = | 415 TabSpecificContentSettings* content_settings = |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 layout->AddPaddingRow( | 471 layout->AddPaddingRow( |
| 479 0, | 472 0, |
| 480 LayoutDelegate::Get()->GetMetric( | 473 LayoutDelegate::Get()->GetMetric( |
| 481 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); | 474 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
| 482 | 475 |
| 483 layout->StartRow(1, single_column_layout_id); | 476 layout->StartRow(1, single_column_layout_id); |
| 484 layout->AddView( | 477 layout->AddView( |
| 485 CreateScrollView(blocked_cookies_tree_), 1, 1, | 478 CreateScrollView(blocked_cookies_tree_), 1, 1, |
| 486 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); | 479 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); |
| 487 layout->AddPaddingRow( | 480 layout->AddPaddingRow( |
| 488 0, LayoutDelegate::Get()->GetMetric(GetTreeviewToButtonsMetric())); | 481 0, LayoutDelegate::Get()->GetMetric( |
| 482 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
| 489 | 483 |
| 490 layout->StartRow(0, three_columns_layout_id); | 484 layout->StartRow(0, three_columns_layout_id); |
| 491 layout->AddView(allow_blocked_button_); | 485 layout->AddView(allow_blocked_button_); |
| 492 layout->AddView(for_session_blocked_button_); | 486 layout->AddView(for_session_blocked_button_); |
| 493 | 487 |
| 494 return pane; | 488 return pane; |
| 495 } | 489 } |
| 496 | 490 |
| 497 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { | 491 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { |
| 498 views::ScrollView* scroll_view = new views::ScrollView(); | 492 views::ScrollView* scroll_view = new views::ScrollView(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 /////////////////////////////////////////////////////////////////////////////// | 561 /////////////////////////////////////////////////////////////////////////////// |
| 568 // CollectedCookiesViews, content::NotificationObserver implementation: | 562 // CollectedCookiesViews, content::NotificationObserver implementation: |
| 569 | 563 |
| 570 void CollectedCookiesViews::Observe( | 564 void CollectedCookiesViews::Observe( |
| 571 int type, | 565 int type, |
| 572 const content::NotificationSource& source, | 566 const content::NotificationSource& source, |
| 573 const content::NotificationDetails& details) { | 567 const content::NotificationDetails& details) { |
| 574 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); | 568 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); |
| 575 GetWidget()->Close(); | 569 GetWidget()->Close(); |
| 576 } | 570 } |
| OLD | NEW |