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

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: Final feedback addressed 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 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
320 if (provider->UseExtraDialogPadding())
320 layout->SetInsets(gfx::Insets(kTabbedPaneTopPadding, 0, 0, 0)); 321 layout->SetInsets(gfx::Insets(kTabbedPaneTopPadding, 0, 0, 0));
321 SetLayoutManager(layout); 322 SetLayoutManager(layout);
322 323
323 const int single_column_layout_id = 0; 324 const int single_column_layout_id = 0;
324 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 325 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
325 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 326 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
326 GridLayout::USE_PREF, 0, 0); 327 GridLayout::USE_PREF, 0, 0);
327 328
328 layout->StartRow(0, single_column_layout_id); 329 layout->StartRow(0, single_column_layout_id);
329 views::TabbedPane* tabbed_pane = new views::TabbedPane(); 330 views::TabbedPane* tabbed_pane = new views::TabbedPane();
330 331
331 layout->AddView(tabbed_pane); 332 layout->AddView(tabbed_pane);
332 // NOTE: Panes must be added after |tabbed_pane| has been added to its parent. 333 // NOTE: Panes must be added after |tabbed_pane| has been added to its parent.
333 base::string16 label_allowed = l10n_util::GetStringUTF16( 334 base::string16 label_allowed = l10n_util::GetStringUTF16(
334 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL); 335 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL);
335 base::string16 label_blocked = l10n_util::GetStringUTF16( 336 base::string16 label_blocked = l10n_util::GetStringUTF16(
336 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL); 337 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL);
337 tabbed_pane->AddTab(label_allowed, CreateAllowedPane()); 338 tabbed_pane->AddTab(label_allowed, CreateAllowedPane());
338 tabbed_pane->AddTab(label_blocked, CreateBlockedPane()); 339 tabbed_pane->AddTab(label_blocked, CreateBlockedPane());
339 tabbed_pane->SelectTabAt(0); 340 tabbed_pane->SelectTabAt(0);
340 tabbed_pane->set_listener(this); 341 tabbed_pane->set_listener(this);
341 if (LayoutDelegate::Get()->UseExtraDialogPadding()) { 342 if (ChromeLayoutProvider::Get()->UseExtraDialogPadding()) {
342 layout->AddPaddingRow( 343 layout->AddPaddingRow(0, provider->GetDistanceMetric(
343 0, 344 views::DISTANCE_RELATED_CONTROL_VERTICAL));
344 LayoutDelegate::Get()->GetMetric(
345 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
346 } 345 }
347 346
348 layout->StartRow(0, single_column_layout_id); 347 layout->StartRow(0, single_column_layout_id);
349 cookie_info_view_ = new CookieInfoView(); 348 cookie_info_view_ = new CookieInfoView();
350 layout->AddView(cookie_info_view_); 349 layout->AddView(cookie_info_view_);
351 if (LayoutDelegate::Get()->UseExtraDialogPadding()) 350 if (provider->UseExtraDialogPadding())
352 layout->AddPaddingRow(0, kCookieInfoBottomPadding); 351 layout->AddPaddingRow(0, kCookieInfoBottomPadding);
353 352
354 layout->StartRow(0, single_column_layout_id); 353 layout->StartRow(0, single_column_layout_id);
355 infobar_ = new InfobarView(); 354 infobar_ = new InfobarView();
356 layout->AddView(infobar_); 355 layout->AddView(infobar_);
357 356
358 EnableControls(); 357 EnableControls();
359 ShowCookieInfo(); 358 ShowCookieInfo();
360 } 359 }
361 360
(...skipping 20 matching lines...) Expand all
382 381
383 delete_allowed_button_ = views::MdTextButton::CreateSecondaryUiButton(this, 382 delete_allowed_button_ = views::MdTextButton::CreateSecondaryUiButton(this,
384 l10n_util::GetStringUTF16(IDS_COOKIES_REMOVE_LABEL)); 383 l10n_util::GetStringUTF16(IDS_COOKIES_REMOVE_LABEL));
385 384
386 // Create the view that holds all the controls together. This will be the 385 // Create the view that holds all the controls together. This will be the
387 // pane added to the tabbed pane. 386 // pane added to the tabbed pane.
388 using views::GridLayout; 387 using views::GridLayout;
389 388
390 views::View* pane = new views::View(); 389 views::View* pane = new views::View();
391 GridLayout* layout = GridLayout::CreatePanel(pane); 390 GridLayout* layout = GridLayout::CreatePanel(pane);
391 int unrelated_vertical_distance =
392 ChromeLayoutProvider::Get()->GetDistanceMetric(
393 DISTANCE_UNRELATED_CONTROL_VERTICAL);
392 394
393 const int single_column_layout_id = 0; 395 const int single_column_layout_id = 0;
394 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 396 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
395 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 397 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
396 GridLayout::USE_PREF, 0, 0); 398 GridLayout::USE_PREF, 0, 0);
397 399
398 layout->StartRow(0, single_column_layout_id); 400 layout->StartRow(0, single_column_layout_id);
399 layout->AddView(allowed_label_); 401 layout->AddView(allowed_label_);
400 layout->AddPaddingRow( 402 layout->AddPaddingRow(0, unrelated_vertical_distance);
401 0,
402 LayoutDelegate::Get()->GetMetric(
403 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
404 403
405 layout->StartRow(1, single_column_layout_id); 404 layout->StartRow(1, single_column_layout_id);
406 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, 405 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1,
407 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, 406 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth,
408 kTreeViewHeight); 407 kTreeViewHeight);
409 layout->AddPaddingRow( 408 layout->AddPaddingRow(0, unrelated_vertical_distance);
410 0, LayoutDelegate::Get()->GetMetric(
411 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
412 409
413 StartNewButtonColumnSet(layout, single_column_layout_id + 1); 410 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
414 layout->AddView(block_allowed_button_); 411 layout->AddView(block_allowed_button_);
415 layout->AddView(delete_allowed_button_); 412 layout->AddView(delete_allowed_button_);
416 413
417 return pane; 414 return pane;
418 } 415 }
419 416
420 views::View* CollectedCookiesViews::CreateBlockedPane() { 417 views::View* CollectedCookiesViews::CreateBlockedPane() {
421 TabSpecificContentSettings* content_settings = 418 TabSpecificContentSettings* content_settings =
(...skipping 26 matching lines...) Expand all
448 for_session_blocked_button_ = views::MdTextButton::CreateSecondaryUiButton( 445 for_session_blocked_button_ = views::MdTextButton::CreateSecondaryUiButton(
449 this, 446 this,
450 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON)); 447 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON));
451 448
452 // Create the view that holds all the controls together. This will be the 449 // Create the view that holds all the controls together. This will be the
453 // pane added to the tabbed pane. 450 // pane added to the tabbed pane.
454 using views::GridLayout; 451 using views::GridLayout;
455 452
456 views::View* pane = new views::View(); 453 views::View* pane = new views::View();
457 GridLayout* layout = GridLayout::CreatePanel(pane); 454 GridLayout* layout = GridLayout::CreatePanel(pane);
455 int unrelated_vertical_distance =
456 ChromeLayoutProvider::Get()->GetDistanceMetric(
457 DISTANCE_UNRELATED_CONTROL_VERTICAL);
458 458
459 const int single_column_layout_id = 0; 459 const int single_column_layout_id = 0;
460 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 460 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
461 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 461 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
462 GridLayout::USE_PREF, 0, 0); 462 GridLayout::USE_PREF, 0, 0);
463 463
464 layout->StartRow(0, single_column_layout_id); 464 layout->StartRow(0, single_column_layout_id);
465 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); 465 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL);
466 layout->AddPaddingRow( 466 layout->AddPaddingRow(0, unrelated_vertical_distance);
467 0,
468 LayoutDelegate::Get()->GetMetric(
469 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
470 467
471 layout->StartRow(1, single_column_layout_id); 468 layout->StartRow(1, single_column_layout_id);
472 layout->AddView( 469 layout->AddView(
473 CreateScrollView(blocked_cookies_tree_), 1, 1, 470 CreateScrollView(blocked_cookies_tree_), 1, 1,
474 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); 471 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight);
475 layout->AddPaddingRow( 472 layout->AddPaddingRow(0, unrelated_vertical_distance);
476 0, LayoutDelegate::Get()->GetMetric(
477 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
478 473
479 StartNewButtonColumnSet(layout, single_column_layout_id + 1); 474 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
480 layout->AddView(allow_blocked_button_); 475 layout->AddView(allow_blocked_button_);
481 layout->AddView(for_session_blocked_button_); 476 layout->AddView(for_session_blocked_button_);
482 477
483 return pane; 478 return pane;
484 } 479 }
485 480
486 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { 481 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) {
487 views::ScrollView* scroll_view = 482 views::ScrollView* scroll_view =
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 /////////////////////////////////////////////////////////////////////////////// 551 ///////////////////////////////////////////////////////////////////////////////
557 // CollectedCookiesViews, content::NotificationObserver implementation: 552 // CollectedCookiesViews, content::NotificationObserver implementation:
558 553
559 void CollectedCookiesViews::Observe( 554 void CollectedCookiesViews::Observe(
560 int type, 555 int type,
561 const content::NotificationSource& source, 556 const content::NotificationSource& source,
562 const content::NotificationDetails& details) { 557 const content::NotificationDetails& details) {
563 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); 558 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type);
564 GetWidget()->Close(); 559 GetWidget()->Close();
565 } 560 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/chrome_views_delegate.cc ('k') | chrome/browser/ui/views/content_setting_bubble_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698