Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: chrome/browser/ui/views/collected_cookies_views.cc

Issue 2625083003: Implement Harmony-style consistent button widths for Collected Cookies. (Closed)
Patch Set: selfnits Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 const int kInfobarBorderSize = 1; 61 const int kInfobarBorderSize = 1;
62 62
63 // Dimensions of the tree views. 63 // Dimensions of the tree views.
64 const int kTreeViewWidth = 400; 64 const int kTreeViewWidth = 400;
65 const int kTreeViewHeight = 125; 65 const int kTreeViewHeight = 125;
66 66
67 // Spacing constants used with non-Harmony dialogs. 67 // Spacing constants used with non-Harmony dialogs.
68 const int kTabbedPaneTopPadding = 14; 68 const int kTabbedPaneTopPadding = 14;
69 const int kCookieInfoBottomPadding = 4; 69 const int kCookieInfoBottomPadding = 4;
70 70
71 // Adds a ColumnSet to |layout| to hold two buttons with padding between.
72 // Starts a new row with the added ColumnSet.
73 void StartNewButtonColumnSet(views::GridLayout* layout,
74 const int column_layout_id) {
75 using views::GridLayout;
Peter Kasting 2017/03/07 02:50:37 Nit: I don't think this saves a single line in thi
tapted 2017/03/07 12:06:41 Done.
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
71 } // namespace 93 } // namespace
72 94
73 // A custom view that conditionally displays an infobar. 95 // A custom view that conditionally displays an infobar.
74 class InfobarView : public views::View { 96 class InfobarView : public views::View {
75 public: 97 public:
76 InfobarView() { 98 InfobarView() {
77 content_ = new views::View; 99 content_ = new views::View;
78 SkColor border_color = SK_ColorGRAY; 100 SkColor border_color = SK_ColorGRAY;
79 content_->SetBorder( 101 content_->SetBorder(
80 views::CreateSolidBorder(kInfobarBorderSize, border_color)); 102 views::CreateSolidBorder(kInfobarBorderSize, border_color));
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 using views::GridLayout; 390 using views::GridLayout;
369 391
370 views::View* pane = new views::View(); 392 views::View* pane = new views::View();
371 GridLayout* layout = layout_utils::CreatePanelLayout(pane); 393 GridLayout* layout = layout_utils::CreatePanelLayout(pane);
372 394
373 const int single_column_layout_id = 0; 395 const int single_column_layout_id = 0;
374 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 396 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
375 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 397 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
376 GridLayout::USE_PREF, 0, 0); 398 GridLayout::USE_PREF, 0, 0);
377 399
378 const int three_columns_layout_id = 1;
379 column_set = layout->AddColumnSet(three_columns_layout_id);
380 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
381 GridLayout::USE_PREF, 0, 0);
382 column_set->AddPaddingColumn(
383 0,
384 LayoutDelegate::Get()->GetMetric(
385 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING));
386 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
387 GridLayout::USE_PREF, 0, 0);
388
389 layout->StartRow(0, single_column_layout_id); 400 layout->StartRow(0, single_column_layout_id);
390 layout->AddView(allowed_label_); 401 layout->AddView(allowed_label_);
391 layout->AddPaddingRow( 402 layout->AddPaddingRow(
392 0, 403 0,
393 LayoutDelegate::Get()->GetMetric( 404 LayoutDelegate::Get()->GetMetric(
394 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 405 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
395 406
396 layout->StartRow(1, single_column_layout_id); 407 layout->StartRow(1, single_column_layout_id);
397 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, 408 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1,
398 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, 409 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth,
399 kTreeViewHeight); 410 kTreeViewHeight);
400 layout->AddPaddingRow( 411 layout->AddPaddingRow(
401 0, LayoutDelegate::Get()->GetMetric( 412 0, LayoutDelegate::Get()->GetMetric(
402 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 413 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
403 414
404 layout->StartRow(0, three_columns_layout_id); 415 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
405 layout->AddView(block_allowed_button_); 416 layout->AddView(block_allowed_button_);
406 layout->AddView(delete_allowed_button_); 417 layout->AddView(delete_allowed_button_);
407 418
408 return pane; 419 return pane;
409 } 420 }
410 421
411 views::View* CollectedCookiesViews::CreateBlockedPane() { 422 views::View* CollectedCookiesViews::CreateBlockedPane() {
412 TabSpecificContentSettings* content_settings = 423 TabSpecificContentSettings* content_settings =
413 TabSpecificContentSettings::FromWebContents(web_contents_); 424 TabSpecificContentSettings::FromWebContents(web_contents_);
414 425
(...skipping 30 matching lines...) Expand all
445 using views::GridLayout; 456 using views::GridLayout;
446 457
447 views::View* pane = new views::View(); 458 views::View* pane = new views::View();
448 GridLayout* layout = layout_utils::CreatePanelLayout(pane); 459 GridLayout* layout = layout_utils::CreatePanelLayout(pane);
449 460
450 const int single_column_layout_id = 0; 461 const int single_column_layout_id = 0;
451 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 462 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
452 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 463 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
453 GridLayout::USE_PREF, 0, 0); 464 GridLayout::USE_PREF, 0, 0);
454 465
455 const int three_columns_layout_id = 1;
456 column_set = layout->AddColumnSet(three_columns_layout_id);
457 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
458 GridLayout::USE_PREF, 0, 0);
459 column_set->AddPaddingColumn(
460 0,
461 LayoutDelegate::Get()->GetMetric(
462 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING));
463 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
464 GridLayout::USE_PREF, 0, 0);
465
466 layout->StartRow(0, single_column_layout_id); 466 layout->StartRow(0, single_column_layout_id);
467 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); 467 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL);
468 layout->AddPaddingRow( 468 layout->AddPaddingRow(
469 0, 469 0,
470 LayoutDelegate::Get()->GetMetric( 470 LayoutDelegate::Get()->GetMetric(
471 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 471 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
472 472
473 layout->StartRow(1, single_column_layout_id); 473 layout->StartRow(1, single_column_layout_id);
474 layout->AddView( 474 layout->AddView(
475 CreateScrollView(blocked_cookies_tree_), 1, 1, 475 CreateScrollView(blocked_cookies_tree_), 1, 1,
476 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); 476 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight);
477 layout->AddPaddingRow( 477 layout->AddPaddingRow(
478 0, LayoutDelegate::Get()->GetMetric( 478 0, LayoutDelegate::Get()->GetMetric(
479 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 479 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
480 480
481 layout->StartRow(0, three_columns_layout_id); 481 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
482 layout->AddView(allow_blocked_button_); 482 layout->AddView(allow_blocked_button_);
483 layout->AddView(for_session_blocked_button_); 483 layout->AddView(for_session_blocked_button_);
484 484
485 return pane; 485 return pane;
486 } 486 }
487 487
488 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { 488 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) {
489 views::ScrollView* scroll_view = 489 views::ScrollView* scroll_view =
490 views::ScrollView::CreateScrollViewWithBorder(); 490 views::ScrollView::CreateScrollViewWithBorder();
491 scroll_view->SetContents(pane); 491 scroll_view->SetContents(pane);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 /////////////////////////////////////////////////////////////////////////////// 558 ///////////////////////////////////////////////////////////////////////////////
559 // CollectedCookiesViews, content::NotificationObserver implementation: 559 // CollectedCookiesViews, content::NotificationObserver implementation:
560 560
561 void CollectedCookiesViews::Observe( 561 void CollectedCookiesViews::Observe(
562 int type, 562 int type,
563 const content::NotificationSource& source, 563 const content::NotificationSource& source,
564 const content::NotificationDetails& details) { 564 const content::NotificationDetails& details) {
565 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); 565 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type);
566 GetWidget()->Close(); 566 GetWidget()->Close();
567 } 567 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698