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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: LayoutDelegate -> LayoutProvider Created 3 years, 8 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"
11 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" 11 #include "chrome/browser/browsing_data/browsing_data_database_helper.h"
12 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h" 12 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
13 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h" 13 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
14 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h" 14 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
15 #include "chrome/browser/browsing_data/cookies_tree_model.h" 15 #include "chrome/browser/browsing_data/cookies_tree_model.h"
16 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
17 #include "chrome/browser/content_settings/cookie_settings_factory.h" 17 #include "chrome/browser/content_settings/cookie_settings_factory.h"
18 #include "chrome/browser/content_settings/local_shared_objects_container.h" 18 #include "chrome/browser/content_settings/local_shared_objects_container.h"
19 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 19 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
20 #include "chrome/browser/infobars/infobar_service.h" 20 #include "chrome/browser/infobars/infobar_service.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" 22 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
23 #include "chrome/browser/ui/views/cookie_info_view.h" 23 #include "chrome/browser/ui/views/cookie_info_view.h"
24 #include "chrome/browser/ui/views/harmony/layout_delegate.h" 24 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "chrome/grit/generated_resources.h" 26 #include "chrome/grit/generated_resources.h"
27 #include "chrome/grit/locale_settings.h" 27 #include "chrome/grit/locale_settings.h"
28 #include "chrome/grit/theme_resources.h" 28 #include "chrome/grit/theme_resources.h"
29 #include "components/constrained_window/constrained_window_views.h" 29 #include "components/constrained_window/constrained_window_views.h"
30 #include "components/content_settings/core/browser/cookie_settings.h" 30 #include "components/content_settings/core/browser/cookie_settings.h"
31 #include "components/content_settings/core/common/pref_names.h" 31 #include "components/content_settings/core/common/pref_names.h"
32 #include "components/prefs/pref_service.h" 32 #include "components/prefs/pref_service.h"
33 #include "components/strings/grit/components_strings.h" 33 #include "components/strings/grit/components_strings.h"
34 #include "content/public/browser/notification_details.h" 34 #include "content/public/browser/notification_details.h"
(...skipping 29 matching lines...) Expand all
64 const int kTreeViewHeight = 125; 64 const int kTreeViewHeight = 125;
65 65
66 // Spacing constants used with non-Harmony dialogs. 66 // Spacing constants used with non-Harmony dialogs.
67 const int kTabbedPaneTopPadding = 14; 67 const int kTabbedPaneTopPadding = 14;
68 const int kCookieInfoBottomPadding = 4; 68 const int kCookieInfoBottomPadding = 4;
69 69
70 // Adds a ColumnSet to |layout| to hold two buttons with padding between. 70 // Adds a ColumnSet to |layout| to hold two buttons with padding between.
71 // Starts a new row with the added ColumnSet. 71 // Starts a new row with the added ColumnSet.
72 void StartNewButtonColumnSet(views::GridLayout* layout, 72 void StartNewButtonColumnSet(views::GridLayout* layout,
73 const int column_layout_id) { 73 const int column_layout_id) {
74 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); 74 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
75 const int button_padding = layout_delegate->GetMetric( 75 const int button_padding =
76 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING); 76 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
77 const int button_size_limit = layout_delegate->GetMetric( 77 const int button_size_limit =
78 LayoutDelegate::Metric::BUTTON_MAX_LINKABLE_WIDTH); 78 provider->GetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH);
79 79
80 views::ColumnSet* column_set = layout->AddColumnSet(column_layout_id); 80 views::ColumnSet* column_set = layout->AddColumnSet(column_layout_id);
81 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0, 81 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0,
82 views::GridLayout::USE_PREF, 0, 0); 82 views::GridLayout::USE_PREF, 0, 0);
83 column_set->AddPaddingColumn(0, button_padding); 83 column_set->AddPaddingColumn(0, button_padding);
84 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0, 84 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0,
85 views::GridLayout::USE_PREF, 0, 0); 85 views::GridLayout::USE_PREF, 0, 0);
86 column_set->LinkColumnSizes(0, 2, -1); 86 column_set->LinkColumnSizes(0, 2, -1);
87 column_set->set_linked_column_size_limit(button_size_limit); 87 column_set->set_linked_column_size_limit(button_size_limit);
88 layout->StartRow(0, column_layout_id); 88 layout->StartRow(0, column_layout_id);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 284
285 /////////////////////////////////////////////////////////////////////////////// 285 ///////////////////////////////////////////////////////////////////////////////
286 // CollectedCookiesViews, views::View overrides: 286 // CollectedCookiesViews, views::View overrides:
287 287
288 gfx::Size CollectedCookiesViews::GetMinimumSize() const { 288 gfx::Size CollectedCookiesViews::GetMinimumSize() const {
289 // Allow UpdateWebContentsModalDialogPosition to clamp the dialog width. 289 // Allow UpdateWebContentsModalDialogPosition to clamp the dialog width.
290 return gfx::Size(0, View::GetMinimumSize().height()); 290 return gfx::Size(0, View::GetMinimumSize().height());
291 } 291 }
292 292
293 gfx::Size CollectedCookiesViews::GetPreferredSize() const { 293 gfx::Size CollectedCookiesViews::GetPreferredSize() const {
294 int preferred = LayoutDelegate::Get()->GetDialogPreferredWidth( 294 int preferred =
295 LayoutDelegate::DialogWidth::MEDIUM); 295 ChromeLayoutProvider::Get()->GetDialogPreferredWidth(DialogWidth::MEDIUM);
296 return gfx::Size(preferred ? preferred : View::GetPreferredSize().width(), 296 return gfx::Size(preferred ? preferred : View::GetPreferredSize().width(),
297 View::GetPreferredSize().height()); 297 View::GetPreferredSize().height());
298 } 298 }
299 299
300 void CollectedCookiesViews::ViewHierarchyChanged( 300 void CollectedCookiesViews::ViewHierarchyChanged(
301 const ViewHierarchyChangedDetails& details) { 301 const ViewHierarchyChangedDetails& details) {
302 views::DialogDelegateView::ViewHierarchyChanged(details); 302 views::DialogDelegateView::ViewHierarchyChanged(details);
303 if (details.is_add && details.child == this) 303 if (details.is_add && details.child == this)
304 Init(); 304 Init();
305 } 305 }
306 306
307 //////////////////////////////////////////////////////////////////////////////// 307 ////////////////////////////////////////////////////////////////////////////////
308 // CollectedCookiesViews, private: 308 // CollectedCookiesViews, private:
309 309
310 CollectedCookiesViews::~CollectedCookiesViews() { 310 CollectedCookiesViews::~CollectedCookiesViews() {
311 allowed_cookies_tree_->SetModel(NULL); 311 allowed_cookies_tree_->SetModel(NULL);
312 blocked_cookies_tree_->SetModel(NULL); 312 blocked_cookies_tree_->SetModel(NULL);
313 } 313 }
314 314
315 void CollectedCookiesViews::Init() { 315 void CollectedCookiesViews::Init() {
316 using views::GridLayout; 316 using views::GridLayout;
317 317
318 GridLayout* layout = new GridLayout(this); 318 GridLayout* layout = new GridLayout(this);
319 if (LayoutDelegate::Get()->UseExtraDialogPadding()) 319 if (ChromeLayoutProvider::Get()->UseExtraDialogPadding())
Peter Kasting 2017/04/12 21:37:43 Nit: Pull layout provider out to a temp for reuse?
kylix_rd 2017/04/13 16:45:42 Done.
320 layout->SetInsets(gfx::Insets(kTabbedPaneTopPadding, 0, 0, 0)); 320 layout->SetInsets(gfx::Insets(kTabbedPaneTopPadding, 0, 0, 0));
321 SetLayoutManager(layout); 321 SetLayoutManager(layout);
322 322
323 const int single_column_layout_id = 0; 323 const int single_column_layout_id = 0;
324 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 324 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
325 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 325 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
326 GridLayout::USE_PREF, 0, 0); 326 GridLayout::USE_PREF, 0, 0);
327 327
328 layout->StartRow(0, single_column_layout_id); 328 layout->StartRow(0, single_column_layout_id);
329 views::TabbedPane* tabbed_pane = new views::TabbedPane(); 329 views::TabbedPane* tabbed_pane = new views::TabbedPane();
330 330
331 layout->AddView(tabbed_pane); 331 layout->AddView(tabbed_pane);
332 // NOTE: Panes must be added after |tabbed_pane| has been added to its parent. 332 // NOTE: Panes must be added after |tabbed_pane| has been added to its parent.
333 base::string16 label_allowed = l10n_util::GetStringUTF16( 333 base::string16 label_allowed = l10n_util::GetStringUTF16(
334 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL); 334 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL);
335 base::string16 label_blocked = l10n_util::GetStringUTF16( 335 base::string16 label_blocked = l10n_util::GetStringUTF16(
336 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL); 336 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL);
337 tabbed_pane->AddTab(label_allowed, CreateAllowedPane()); 337 tabbed_pane->AddTab(label_allowed, CreateAllowedPane());
338 tabbed_pane->AddTab(label_blocked, CreateBlockedPane()); 338 tabbed_pane->AddTab(label_blocked, CreateBlockedPane());
339 tabbed_pane->SelectTabAt(0); 339 tabbed_pane->SelectTabAt(0);
340 tabbed_pane->set_listener(this); 340 tabbed_pane->set_listener(this);
341 if (LayoutDelegate::Get()->UseExtraDialogPadding()) { 341 if (ChromeLayoutProvider::Get()->UseExtraDialogPadding()) {
342 layout->AddPaddingRow( 342 layout->AddPaddingRow(0, ChromeLayoutProvider::Get()->GetDistanceMetric(
343 0, 343 views::DISTANCE_RELATED_CONTROL_VERTICAL));
344 LayoutDelegate::Get()->GetMetric(
345 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
346 } 344 }
347 345
348 layout->StartRow(0, single_column_layout_id); 346 layout->StartRow(0, single_column_layout_id);
349 cookie_info_view_ = new CookieInfoView(); 347 cookie_info_view_ = new CookieInfoView();
350 layout->AddView(cookie_info_view_); 348 layout->AddView(cookie_info_view_);
351 if (LayoutDelegate::Get()->UseExtraDialogPadding()) 349 if (ChromeLayoutProvider::Get()->UseExtraDialogPadding())
352 layout->AddPaddingRow(0, kCookieInfoBottomPadding); 350 layout->AddPaddingRow(0, kCookieInfoBottomPadding);
353 351
354 layout->StartRow(0, single_column_layout_id); 352 layout->StartRow(0, single_column_layout_id);
355 infobar_ = new InfobarView(); 353 infobar_ = new InfobarView();
356 layout->AddView(infobar_); 354 layout->AddView(infobar_);
357 355
358 EnableControls(); 356 EnableControls();
359 ShowCookieInfo(); 357 ShowCookieInfo();
360 } 358 }
361 359
(...skipping 28 matching lines...) Expand all
390 views::View* pane = new views::View(); 388 views::View* pane = new views::View();
391 GridLayout* layout = GridLayout::CreatePanel(pane); 389 GridLayout* layout = GridLayout::CreatePanel(pane);
392 390
393 const int single_column_layout_id = 0; 391 const int single_column_layout_id = 0;
394 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 392 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
395 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 393 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
396 GridLayout::USE_PREF, 0, 0); 394 GridLayout::USE_PREF, 0, 0);
397 395
398 layout->StartRow(0, single_column_layout_id); 396 layout->StartRow(0, single_column_layout_id);
399 layout->AddView(allowed_label_); 397 layout->AddView(allowed_label_);
400 layout->AddPaddingRow( 398 layout->AddPaddingRow(0, ChromeLayoutProvider::Get()->GetDistanceMetric(
401 0, 399 DISTANCE_UNRELATED_CONTROL_VERTICAL));
Peter Kasting 2017/04/12 21:37:43 Nit: Pull vertical distance out to a temp for reus
kylix_rd 2017/04/13 16:45:42 Done.
402 LayoutDelegate::Get()->GetMetric(
403 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
404 400
405 layout->StartRow(1, single_column_layout_id); 401 layout->StartRow(1, single_column_layout_id);
406 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, 402 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1,
407 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, 403 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth,
408 kTreeViewHeight); 404 kTreeViewHeight);
409 layout->AddPaddingRow( 405 layout->AddPaddingRow(0, ChromeLayoutProvider::Get()->GetDistanceMetric(
410 0, LayoutDelegate::Get()->GetMetric( 406 DISTANCE_UNRELATED_CONTROL_VERTICAL));
411 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
412 407
413 StartNewButtonColumnSet(layout, single_column_layout_id + 1); 408 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
414 layout->AddView(block_allowed_button_); 409 layout->AddView(block_allowed_button_);
415 layout->AddView(delete_allowed_button_); 410 layout->AddView(delete_allowed_button_);
416 411
417 return pane; 412 return pane;
418 } 413 }
419 414
420 views::View* CollectedCookiesViews::CreateBlockedPane() { 415 views::View* CollectedCookiesViews::CreateBlockedPane() {
421 TabSpecificContentSettings* content_settings = 416 TabSpecificContentSettings* content_settings =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 views::View* pane = new views::View(); 451 views::View* pane = new views::View();
457 GridLayout* layout = GridLayout::CreatePanel(pane); 452 GridLayout* layout = GridLayout::CreatePanel(pane);
458 453
459 const int single_column_layout_id = 0; 454 const int single_column_layout_id = 0;
460 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 455 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
461 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 456 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
462 GridLayout::USE_PREF, 0, 0); 457 GridLayout::USE_PREF, 0, 0);
463 458
464 layout->StartRow(0, single_column_layout_id); 459 layout->StartRow(0, single_column_layout_id);
465 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); 460 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL);
466 layout->AddPaddingRow( 461 layout->AddPaddingRow(0, ChromeLayoutProvider::Get()->GetDistanceMetric(
467 0, 462 DISTANCE_UNRELATED_CONTROL_VERTICAL));
Peter Kasting 2017/04/12 21:37:43 Nit: Pull vertical distance out to a temp for reus
kylix_rd 2017/04/13 16:45:42 Done.
468 LayoutDelegate::Get()->GetMetric(
469 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
470 463
471 layout->StartRow(1, single_column_layout_id); 464 layout->StartRow(1, single_column_layout_id);
472 layout->AddView( 465 layout->AddView(
473 CreateScrollView(blocked_cookies_tree_), 1, 1, 466 CreateScrollView(blocked_cookies_tree_), 1, 1,
474 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); 467 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight);
475 layout->AddPaddingRow( 468 layout->AddPaddingRow(0, ChromeLayoutProvider::Get()->GetDistanceMetric(
476 0, LayoutDelegate::Get()->GetMetric( 469 DISTANCE_UNRELATED_CONTROL_VERTICAL));
477 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
478 470
479 StartNewButtonColumnSet(layout, single_column_layout_id + 1); 471 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
480 layout->AddView(allow_blocked_button_); 472 layout->AddView(allow_blocked_button_);
481 layout->AddView(for_session_blocked_button_); 473 layout->AddView(for_session_blocked_button_);
482 474
483 return pane; 475 return pane;
484 } 476 }
485 477
486 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { 478 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) {
487 views::ScrollView* scroll_view = 479 views::ScrollView* scroll_view =
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 /////////////////////////////////////////////////////////////////////////////// 548 ///////////////////////////////////////////////////////////////////////////////
557 // CollectedCookiesViews, content::NotificationObserver implementation: 549 // CollectedCookiesViews, content::NotificationObserver implementation:
558 550
559 void CollectedCookiesViews::Observe( 551 void CollectedCookiesViews::Observe(
560 int type, 552 int type,
561 const content::NotificationSource& source, 553 const content::NotificationSource& source,
562 const content::NotificationDetails& details) { 554 const content::NotificationDetails& details) {
563 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); 555 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type);
564 GetWidget()->Close(); 556 GetWidget()->Close();
565 } 557 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698