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

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: respond to comments 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/harmony/harmony_layout_delegate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 LayoutDelegate* layout_delegate = LayoutDelegate::Get();
76 const int button_padding = layout_delegate->GetMetric(
77 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING);
78 const int button_size_limit = layout_delegate->GetMetric(
79 LayoutDelegate::Metric::BUTTON_MAX_LINKABLE_WIDTH);
80
81 views::ColumnSet* column_set = layout->AddColumnSet(column_layout_id);
82 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0,
83 views::GridLayout::USE_PREF, 0, 0);
84 column_set->AddPaddingColumn(0, button_padding);
85 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0,
86 views::GridLayout::USE_PREF, 0, 0);
87 column_set->LinkColumnSizes(0, 2, -1);
88 column_set->set_linked_column_size_limit(button_size_limit);
89 layout->StartRow(0, column_layout_id);
90 }
91
71 } // namespace 92 } // namespace
72 93
73 // A custom view that conditionally displays an infobar. 94 // A custom view that conditionally displays an infobar.
74 class InfobarView : public views::View { 95 class InfobarView : public views::View {
75 public: 96 public:
76 InfobarView() { 97 InfobarView() {
77 content_ = new views::View; 98 content_ = new views::View;
78 SkColor border_color = SK_ColorGRAY; 99 SkColor border_color = SK_ColorGRAY;
79 content_->SetBorder( 100 content_->SetBorder(
80 views::CreateSolidBorder(kInfobarBorderSize, border_color)); 101 views::CreateSolidBorder(kInfobarBorderSize, border_color));
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 using views::GridLayout; 389 using views::GridLayout;
369 390
370 views::View* pane = new views::View(); 391 views::View* pane = new views::View();
371 GridLayout* layout = layout_utils::CreatePanelLayout(pane); 392 GridLayout* layout = layout_utils::CreatePanelLayout(pane);
372 393
373 const int single_column_layout_id = 0; 394 const int single_column_layout_id = 0;
374 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 395 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
375 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 396 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
376 GridLayout::USE_PREF, 0, 0); 397 GridLayout::USE_PREF, 0, 0);
377 398
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); 399 layout->StartRow(0, single_column_layout_id);
390 layout->AddView(allowed_label_); 400 layout->AddView(allowed_label_);
391 layout->AddPaddingRow( 401 layout->AddPaddingRow(
392 0, 402 0,
393 LayoutDelegate::Get()->GetMetric( 403 LayoutDelegate::Get()->GetMetric(
394 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 404 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
395 405
396 layout->StartRow(1, single_column_layout_id); 406 layout->StartRow(1, single_column_layout_id);
397 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, 407 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1,
398 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, 408 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth,
399 kTreeViewHeight); 409 kTreeViewHeight);
400 layout->AddPaddingRow( 410 layout->AddPaddingRow(
401 0, LayoutDelegate::Get()->GetMetric( 411 0, LayoutDelegate::Get()->GetMetric(
402 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 412 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
403 413
404 layout->StartRow(0, three_columns_layout_id); 414 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
405 layout->AddView(block_allowed_button_); 415 layout->AddView(block_allowed_button_);
406 layout->AddView(delete_allowed_button_); 416 layout->AddView(delete_allowed_button_);
407 417
408 return pane; 418 return pane;
409 } 419 }
410 420
411 views::View* CollectedCookiesViews::CreateBlockedPane() { 421 views::View* CollectedCookiesViews::CreateBlockedPane() {
412 TabSpecificContentSettings* content_settings = 422 TabSpecificContentSettings* content_settings =
413 TabSpecificContentSettings::FromWebContents(web_contents_); 423 TabSpecificContentSettings::FromWebContents(web_contents_);
414 424
(...skipping 30 matching lines...) Expand all
445 using views::GridLayout; 455 using views::GridLayout;
446 456
447 views::View* pane = new views::View(); 457 views::View* pane = new views::View();
448 GridLayout* layout = layout_utils::CreatePanelLayout(pane); 458 GridLayout* layout = layout_utils::CreatePanelLayout(pane);
449 459
450 const int single_column_layout_id = 0; 460 const int single_column_layout_id = 0;
451 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 461 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
452 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 462 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
453 GridLayout::USE_PREF, 0, 0); 463 GridLayout::USE_PREF, 0, 0);
454 464
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); 465 layout->StartRow(0, single_column_layout_id);
467 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); 466 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL);
468 layout->AddPaddingRow( 467 layout->AddPaddingRow(
469 0, 468 0,
470 LayoutDelegate::Get()->GetMetric( 469 LayoutDelegate::Get()->GetMetric(
471 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 470 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
472 471
473 layout->StartRow(1, single_column_layout_id); 472 layout->StartRow(1, single_column_layout_id);
474 layout->AddView( 473 layout->AddView(
475 CreateScrollView(blocked_cookies_tree_), 1, 1, 474 CreateScrollView(blocked_cookies_tree_), 1, 1,
476 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); 475 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight);
477 layout->AddPaddingRow( 476 layout->AddPaddingRow(
478 0, LayoutDelegate::Get()->GetMetric( 477 0, LayoutDelegate::Get()->GetMetric(
479 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 478 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
480 479
481 layout->StartRow(0, three_columns_layout_id); 480 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
482 layout->AddView(allow_blocked_button_); 481 layout->AddView(allow_blocked_button_);
483 layout->AddView(for_session_blocked_button_); 482 layout->AddView(for_session_blocked_button_);
484 483
485 return pane; 484 return pane;
486 } 485 }
487 486
488 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { 487 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) {
489 views::ScrollView* scroll_view = 488 views::ScrollView* scroll_view =
490 views::ScrollView::CreateScrollViewWithBorder(); 489 views::ScrollView::CreateScrollViewWithBorder();
491 scroll_view->SetContents(pane); 490 scroll_view->SetContents(pane);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 /////////////////////////////////////////////////////////////////////////////// 557 ///////////////////////////////////////////////////////////////////////////////
559 // CollectedCookiesViews, content::NotificationObserver implementation: 558 // CollectedCookiesViews, content::NotificationObserver implementation:
560 559
561 void CollectedCookiesViews::Observe( 560 void CollectedCookiesViews::Observe(
562 int type, 561 int type,
563 const content::NotificationSource& source, 562 const content::NotificationSource& source,
564 const content::NotificationDetails& details) { 563 const content::NotificationDetails& details) {
565 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); 564 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type);
566 GetWidget()->Close(); 565 GetWidget()->Close();
567 } 566 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/harmony/harmony_layout_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698