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::LayoutDistanceType GetTreeviewToButtonsDistanceType() { | 74 LayoutDelegate::Metric GetTreeviewToButtonsMetric() { |
75 // Hack: in the Harmony specs, the buttons under the treeview are "unrelated" | 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. | 76 // to it (which looks better), but in the existing dialog they were related. |
77 return LayoutDelegate::Get()->IsHarmonyMode() | 77 return LayoutDelegate::Get()->IsHarmonyMode() |
78 ? LayoutDelegate::LayoutDistanceType:: | 78 ? LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING |
79 UNRELATED_CONTROL_VERTICAL_SPACING | 79 : LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING; |
80 : LayoutDelegate::LayoutDistanceType:: | |
81 RELATED_CONTROL_VERTICAL_SPACING; | |
82 } | 80 } |
83 | 81 |
84 } // namespace | 82 } // namespace |
85 | 83 |
86 // A custom view that conditionally displays an infobar. | 84 // A custom view that conditionally displays an infobar. |
87 class InfobarView : public views::View { | 85 class InfobarView : public views::View { |
88 public: | 86 public: |
89 InfobarView() { | 87 InfobarView() { |
90 content_ = new views::View; | 88 content_ = new views::View; |
91 SkColor border_color = SK_ColorGRAY; | 89 SkColor border_color = SK_ColorGRAY; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 /////////////////////////////////////////////////////////////////////////////// | 276 /////////////////////////////////////////////////////////////////////////////// |
279 // CollectedCookiesViews, views::View overrides: | 277 // CollectedCookiesViews, views::View overrides: |
280 | 278 |
281 gfx::Size CollectedCookiesViews::GetMinimumSize() const { | 279 gfx::Size CollectedCookiesViews::GetMinimumSize() const { |
282 // Allow UpdateWebContentsModalDialogPosition to clamp the dialog width. | 280 // Allow UpdateWebContentsModalDialogPosition to clamp the dialog width. |
283 return gfx::Size(0, View::GetMinimumSize().height()); | 281 return gfx::Size(0, View::GetMinimumSize().height()); |
284 } | 282 } |
285 | 283 |
286 gfx::Size CollectedCookiesViews::GetPreferredSize() const { | 284 gfx::Size CollectedCookiesViews::GetPreferredSize() const { |
287 int preferred = LayoutDelegate::Get()->GetDialogPreferredWidth( | 285 int preferred = LayoutDelegate::Get()->GetDialogPreferredWidth( |
288 LayoutDelegate::DialogWidthType::MEDIUM); | 286 LayoutDelegate::DialogWidth::MEDIUM); |
289 return gfx::Size(preferred ? preferred : View::GetPreferredSize().width(), | 287 return gfx::Size(preferred ? preferred : View::GetPreferredSize().width(), |
290 View::GetPreferredSize().height()); | 288 View::GetPreferredSize().height()); |
291 } | 289 } |
292 | 290 |
293 void CollectedCookiesViews::ViewHierarchyChanged( | 291 void CollectedCookiesViews::ViewHierarchyChanged( |
294 const ViewHierarchyChangedDetails& details) { | 292 const ViewHierarchyChangedDetails& details) { |
295 views::DialogDelegateView::ViewHierarchyChanged(details); | 293 views::DialogDelegateView::ViewHierarchyChanged(details); |
296 if (details.is_add && details.child == this) | 294 if (details.is_add && details.child == this) |
297 Init(); | 295 Init(); |
298 } | 296 } |
(...skipping 26 matching lines...) Expand all Loading... |
325 // NOTE: Panes must be added after |tabbed_pane| has been added to its parent. | 323 // NOTE: Panes must be added after |tabbed_pane| has been added to its parent. |
326 base::string16 label_allowed = l10n_util::GetStringUTF16( | 324 base::string16 label_allowed = l10n_util::GetStringUTF16( |
327 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL); | 325 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL); |
328 base::string16 label_blocked = l10n_util::GetStringUTF16( | 326 base::string16 label_blocked = l10n_util::GetStringUTF16( |
329 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL); | 327 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL); |
330 tabbed_pane->AddTab(label_allowed, CreateAllowedPane()); | 328 tabbed_pane->AddTab(label_allowed, CreateAllowedPane()); |
331 tabbed_pane->AddTab(label_blocked, CreateBlockedPane()); | 329 tabbed_pane->AddTab(label_blocked, CreateBlockedPane()); |
332 tabbed_pane->SelectTabAt(0); | 330 tabbed_pane->SelectTabAt(0); |
333 tabbed_pane->set_listener(this); | 331 tabbed_pane->set_listener(this); |
334 if (LayoutDelegate::Get()->UseExtraDialogPadding()) { | 332 if (LayoutDelegate::Get()->UseExtraDialogPadding()) { |
335 layout->AddPaddingRow(0, LayoutDelegate::Get()->GetLayoutDistance( | 333 layout->AddPaddingRow( |
336 LayoutDelegate::LayoutDistanceType:: | 334 0, |
337 RELATED_CONTROL_VERTICAL_SPACING)); | 335 LayoutDelegate::Get()->GetMetric( |
| 336 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); |
338 } | 337 } |
339 | 338 |
340 layout->StartRow(0, single_column_layout_id); | 339 layout->StartRow(0, single_column_layout_id); |
341 cookie_info_view_ = new CookieInfoView(); | 340 cookie_info_view_ = new CookieInfoView(); |
342 layout->AddView(cookie_info_view_); | 341 layout->AddView(cookie_info_view_); |
343 if (LayoutDelegate::Get()->UseExtraDialogPadding()) | 342 if (LayoutDelegate::Get()->UseExtraDialogPadding()) |
344 layout->AddPaddingRow(0, kCookieInfoBottomPadding); | 343 layout->AddPaddingRow(0, kCookieInfoBottomPadding); |
345 | 344 |
346 layout->StartRow(0, single_column_layout_id); | 345 layout->StartRow(0, single_column_layout_id); |
347 infobar_ = new InfobarView(); | 346 infobar_ = new InfobarView(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 383 |
385 const int single_column_layout_id = 0; | 384 const int single_column_layout_id = 0; |
386 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 385 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |
387 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 386 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
388 GridLayout::USE_PREF, 0, 0); | 387 GridLayout::USE_PREF, 0, 0); |
389 | 388 |
390 const int three_columns_layout_id = 1; | 389 const int three_columns_layout_id = 1; |
391 column_set = layout->AddColumnSet(three_columns_layout_id); | 390 column_set = layout->AddColumnSet(three_columns_layout_id); |
392 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 391 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
393 GridLayout::USE_PREF, 0, 0); | 392 GridLayout::USE_PREF, 0, 0); |
394 column_set->AddPaddingColumn(0, LayoutDelegate::Get()->GetLayoutDistance( | 393 column_set->AddPaddingColumn( |
395 LayoutDelegate::LayoutDistanceType:: | 394 0, |
396 RELATED_BUTTON_HORIZONTAL_SPACING)); | 395 LayoutDelegate::Get()->GetMetric( |
| 396 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING)); |
397 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 397 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
398 GridLayout::USE_PREF, 0, 0); | 398 GridLayout::USE_PREF, 0, 0); |
399 | 399 |
400 layout->StartRow(0, single_column_layout_id); | 400 layout->StartRow(0, single_column_layout_id); |
401 layout->AddView(allowed_label_); | 401 layout->AddView(allowed_label_); |
402 layout->AddPaddingRow(0, LayoutDelegate::Get()->GetLayoutDistance( | 402 layout->AddPaddingRow( |
403 LayoutDelegate::LayoutDistanceType:: | 403 0, |
404 UNRELATED_CONTROL_VERTICAL_SPACING)); | 404 LayoutDelegate::Get()->GetMetric( |
| 405 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
405 | 406 |
406 layout->StartRow(1, single_column_layout_id); | 407 layout->StartRow(1, single_column_layout_id); |
407 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, | 408 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, |
408 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, | 409 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, |
409 kTreeViewHeight); | 410 kTreeViewHeight); |
410 layout->AddPaddingRow(0, LayoutDelegate::Get()->GetLayoutDistance( | 411 layout->AddPaddingRow( |
411 GetTreeviewToButtonsDistanceType())); | 412 0, LayoutDelegate::Get()->GetMetric(GetTreeviewToButtonsMetric())); |
412 | 413 |
413 layout->StartRow(0, three_columns_layout_id); | 414 layout->StartRow(0, three_columns_layout_id); |
414 layout->AddView(block_allowed_button_); | 415 layout->AddView(block_allowed_button_); |
415 layout->AddView(delete_allowed_button_); | 416 layout->AddView(delete_allowed_button_); |
416 | 417 |
417 return pane; | 418 return pane; |
418 } | 419 } |
419 | 420 |
420 views::View* CollectedCookiesViews::CreateBlockedPane() { | 421 views::View* CollectedCookiesViews::CreateBlockedPane() { |
421 TabSpecificContentSettings* content_settings = | 422 TabSpecificContentSettings* content_settings = |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 | 459 |
459 const int single_column_layout_id = 0; | 460 const int single_column_layout_id = 0; |
460 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 461 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |
461 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, | 462 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, |
462 GridLayout::USE_PREF, 0, 0); | 463 GridLayout::USE_PREF, 0, 0); |
463 | 464 |
464 const int three_columns_layout_id = 1; | 465 const int three_columns_layout_id = 1; |
465 column_set = layout->AddColumnSet(three_columns_layout_id); | 466 column_set = layout->AddColumnSet(three_columns_layout_id); |
466 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 467 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
467 GridLayout::USE_PREF, 0, 0); | 468 GridLayout::USE_PREF, 0, 0); |
468 column_set->AddPaddingColumn(0, LayoutDelegate::Get()->GetLayoutDistance( | 469 column_set->AddPaddingColumn( |
469 LayoutDelegate::LayoutDistanceType:: | 470 0, |
470 RELATED_BUTTON_HORIZONTAL_SPACING)); | 471 LayoutDelegate::Get()->GetMetric( |
| 472 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING)); |
471 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, | 473 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, |
472 GridLayout::USE_PREF, 0, 0); | 474 GridLayout::USE_PREF, 0, 0); |
473 | 475 |
474 layout->StartRow(0, single_column_layout_id); | 476 layout->StartRow(0, single_column_layout_id); |
475 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); | 477 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); |
476 layout->AddPaddingRow(0, LayoutDelegate::Get()->GetLayoutDistance( | 478 layout->AddPaddingRow( |
477 LayoutDelegate::LayoutDistanceType:: | 479 0, |
478 UNRELATED_CONTROL_VERTICAL_SPACING)); | 480 LayoutDelegate::Get()->GetMetric( |
| 481 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); |
479 | 482 |
480 layout->StartRow(1, single_column_layout_id); | 483 layout->StartRow(1, single_column_layout_id); |
481 layout->AddView( | 484 layout->AddView( |
482 CreateScrollView(blocked_cookies_tree_), 1, 1, | 485 CreateScrollView(blocked_cookies_tree_), 1, 1, |
483 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); | 486 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); |
484 layout->AddPaddingRow(0, LayoutDelegate::Get()->GetLayoutDistance( | 487 layout->AddPaddingRow( |
485 GetTreeviewToButtonsDistanceType())); | 488 0, LayoutDelegate::Get()->GetMetric(GetTreeviewToButtonsMetric())); |
486 | 489 |
487 layout->StartRow(0, three_columns_layout_id); | 490 layout->StartRow(0, three_columns_layout_id); |
488 layout->AddView(allow_blocked_button_); | 491 layout->AddView(allow_blocked_button_); |
489 layout->AddView(for_session_blocked_button_); | 492 layout->AddView(for_session_blocked_button_); |
490 | 493 |
491 return pane; | 494 return pane; |
492 } | 495 } |
493 | 496 |
494 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { | 497 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { |
495 views::ScrollView* scroll_view = new views::ScrollView(); | 498 views::ScrollView* scroll_view = new views::ScrollView(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 /////////////////////////////////////////////////////////////////////////////// | 567 /////////////////////////////////////////////////////////////////////////////// |
565 // CollectedCookiesViews, content::NotificationObserver implementation: | 568 // CollectedCookiesViews, content::NotificationObserver implementation: |
566 | 569 |
567 void CollectedCookiesViews::Observe( | 570 void CollectedCookiesViews::Observe( |
568 int type, | 571 int type, |
569 const content::NotificationSource& source, | 572 const content::NotificationSource& source, |
570 const content::NotificationDetails& details) { | 573 const content::NotificationDetails& details) { |
571 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); | 574 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); |
572 GetWidget()->Close(); | 575 GetWidget()->Close(); |
573 } | 576 } |
OLD | NEW |