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

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: Deleted LayoutDelegate and HarmonyLayoutDelegate. 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_views_layout_delegate.h"
25 #include "chrome/browser/ui/views/layout_utils.h" 25 #include "chrome/browser/ui/views/layout_utils.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "chrome/grit/generated_resources.h" 27 #include "chrome/grit/generated_resources.h"
28 #include "chrome/grit/locale_settings.h" 28 #include "chrome/grit/locale_settings.h"
29 #include "chrome/grit/theme_resources.h" 29 #include "chrome/grit/theme_resources.h"
30 #include "components/constrained_window/constrained_window_views.h" 30 #include "components/constrained_window/constrained_window_views.h"
31 #include "components/content_settings/core/browser/cookie_settings.h" 31 #include "components/content_settings/core/browser/cookie_settings.h"
32 #include "components/content_settings/core/common/pref_names.h" 32 #include "components/content_settings/core/common/pref_names.h"
33 #include "components/prefs/pref_service.h" 33 #include "components/prefs/pref_service.h"
34 #include "components/strings/grit/components_strings.h" 34 #include "components/strings/grit/components_strings.h"
(...skipping 30 matching lines...) Expand all
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. 71 // Adds a ColumnSet to |layout| to hold two buttons with padding between.
72 // Starts a new row with the added ColumnSet. 72 // Starts a new row with the added ColumnSet.
73 void StartNewButtonColumnSet(views::GridLayout* layout, 73 void StartNewButtonColumnSet(views::GridLayout* layout,
74 const int column_layout_id) { 74 const int column_layout_id) {
75 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); 75 ChromeViewsLayoutDelegate* layout_delegate = ChromeViewsLayoutDelegate::Get();
76 const int button_padding = layout_delegate->GetMetric( 76 const int button_padding = layout_delegate->GetDistanceMetric(
77 LayoutDelegate::Metric::RELATED_BUTTON_HORIZONTAL_SPACING); 77 ChromeDistanceMetric::RELATED_BUTTON_HORIZONTAL);
78 const int button_size_limit = layout_delegate->GetMetric( 78 const int button_size_limit = layout_delegate->GetDistanceMetric(
79 LayoutDelegate::Metric::BUTTON_MAX_LINKABLE_WIDTH); 79 ChromeDistanceMetric::BUTTON_MAX_LINKABLE_WIDTH);
80 80
81 views::ColumnSet* column_set = layout->AddColumnSet(column_layout_id); 81 views::ColumnSet* column_set = layout->AddColumnSet(column_layout_id);
82 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0, 82 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0,
83 views::GridLayout::USE_PREF, 0, 0); 83 views::GridLayout::USE_PREF, 0, 0);
84 column_set->AddPaddingColumn(0, button_padding); 84 column_set->AddPaddingColumn(0, button_padding);
85 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0, 85 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 0,
86 views::GridLayout::USE_PREF, 0, 0); 86 views::GridLayout::USE_PREF, 0, 0);
87 column_set->LinkColumnSizes(0, 2, -1); 87 column_set->LinkColumnSizes(0, 2, -1);
88 column_set->set_linked_column_size_limit(button_size_limit); 88 column_set->set_linked_column_size_limit(button_size_limit);
89 layout->StartRow(0, column_layout_id); 89 layout->StartRow(0, column_layout_id);
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 285
286 /////////////////////////////////////////////////////////////////////////////// 286 ///////////////////////////////////////////////////////////////////////////////
287 // CollectedCookiesViews, views::View overrides: 287 // CollectedCookiesViews, views::View overrides:
288 288
289 gfx::Size CollectedCookiesViews::GetMinimumSize() const { 289 gfx::Size CollectedCookiesViews::GetMinimumSize() const {
290 // Allow UpdateWebContentsModalDialogPosition to clamp the dialog width. 290 // Allow UpdateWebContentsModalDialogPosition to clamp the dialog width.
291 return gfx::Size(0, View::GetMinimumSize().height()); 291 return gfx::Size(0, View::GetMinimumSize().height());
292 } 292 }
293 293
294 gfx::Size CollectedCookiesViews::GetPreferredSize() const { 294 gfx::Size CollectedCookiesViews::GetPreferredSize() const {
295 int preferred = LayoutDelegate::Get()->GetDialogPreferredWidth( 295 int preferred = ChromeViewsLayoutDelegate::Get()->GetDialogPreferredWidth(
296 LayoutDelegate::DialogWidth::MEDIUM); 296 DialogWidth::MEDIUM);
297 return gfx::Size(preferred ? preferred : View::GetPreferredSize().width(), 297 return gfx::Size(preferred ? preferred : View::GetPreferredSize().width(),
298 View::GetPreferredSize().height()); 298 View::GetPreferredSize().height());
299 } 299 }
300 300
301 void CollectedCookiesViews::ViewHierarchyChanged( 301 void CollectedCookiesViews::ViewHierarchyChanged(
302 const ViewHierarchyChangedDetails& details) { 302 const ViewHierarchyChangedDetails& details) {
303 views::DialogDelegateView::ViewHierarchyChanged(details); 303 views::DialogDelegateView::ViewHierarchyChanged(details);
304 if (details.is_add && details.child == this) 304 if (details.is_add && details.child == this)
305 Init(); 305 Init();
306 } 306 }
307 307
308 //////////////////////////////////////////////////////////////////////////////// 308 ////////////////////////////////////////////////////////////////////////////////
309 // CollectedCookiesViews, private: 309 // CollectedCookiesViews, private:
310 310
311 CollectedCookiesViews::~CollectedCookiesViews() { 311 CollectedCookiesViews::~CollectedCookiesViews() {
312 allowed_cookies_tree_->SetModel(NULL); 312 allowed_cookies_tree_->SetModel(NULL);
313 blocked_cookies_tree_->SetModel(NULL); 313 blocked_cookies_tree_->SetModel(NULL);
314 } 314 }
315 315
316 void CollectedCookiesViews::Init() { 316 void CollectedCookiesViews::Init() {
317 using views::GridLayout; 317 using views::GridLayout;
318 318
319 GridLayout* layout = new GridLayout(this); 319 GridLayout* layout = new GridLayout(this);
320 if (LayoutDelegate::Get()->UseExtraDialogPadding()) 320 if (ChromeViewsLayoutDelegate::Get()->UseExtraDialogPadding())
321 layout->SetInsets(gfx::Insets(kTabbedPaneTopPadding, 0, 0, 0)); 321 layout->SetInsets(gfx::Insets(kTabbedPaneTopPadding, 0, 0, 0));
322 SetLayoutManager(layout); 322 SetLayoutManager(layout);
323 323
324 const int single_column_layout_id = 0; 324 const int single_column_layout_id = 0;
325 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 325 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
326 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 326 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
327 GridLayout::USE_PREF, 0, 0); 327 GridLayout::USE_PREF, 0, 0);
328 328
329 layout->StartRow(0, single_column_layout_id); 329 layout->StartRow(0, single_column_layout_id);
330 views::TabbedPane* tabbed_pane = new views::TabbedPane(); 330 views::TabbedPane* tabbed_pane = new views::TabbedPane();
331 331
332 layout->AddView(tabbed_pane); 332 layout->AddView(tabbed_pane);
333 // 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.
334 base::string16 label_allowed = l10n_util::GetStringUTF16( 334 base::string16 label_allowed = l10n_util::GetStringUTF16(
335 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL); 335 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL);
336 base::string16 label_blocked = l10n_util::GetStringUTF16( 336 base::string16 label_blocked = l10n_util::GetStringUTF16(
337 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL); 337 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL);
338 tabbed_pane->AddTab(label_allowed, CreateAllowedPane()); 338 tabbed_pane->AddTab(label_allowed, CreateAllowedPane());
339 tabbed_pane->AddTab(label_blocked, CreateBlockedPane()); 339 tabbed_pane->AddTab(label_blocked, CreateBlockedPane());
340 tabbed_pane->SelectTabAt(0); 340 tabbed_pane->SelectTabAt(0);
341 tabbed_pane->set_listener(this); 341 tabbed_pane->set_listener(this);
342 if (LayoutDelegate::Get()->UseExtraDialogPadding()) { 342 if (ChromeViewsLayoutDelegate::Get()->UseExtraDialogPadding()) {
343 layout->AddPaddingRow( 343 layout->AddPaddingRow(0,
344 0, 344 ChromeViewsLayoutDelegate::Get()->GetDistanceMetric(
345 LayoutDelegate::Get()->GetMetric( 345 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
346 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
347 } 346 }
348 347
349 layout->StartRow(0, single_column_layout_id); 348 layout->StartRow(0, single_column_layout_id);
350 cookie_info_view_ = new CookieInfoView(); 349 cookie_info_view_ = new CookieInfoView();
351 layout->AddView(cookie_info_view_); 350 layout->AddView(cookie_info_view_);
352 if (LayoutDelegate::Get()->UseExtraDialogPadding()) 351 if (ChromeViewsLayoutDelegate::Get()->UseExtraDialogPadding())
353 layout->AddPaddingRow(0, kCookieInfoBottomPadding); 352 layout->AddPaddingRow(0, kCookieInfoBottomPadding);
354 353
355 layout->StartRow(0, single_column_layout_id); 354 layout->StartRow(0, single_column_layout_id);
356 infobar_ = new InfobarView(); 355 infobar_ = new InfobarView();
357 layout->AddView(infobar_); 356 layout->AddView(infobar_);
358 357
359 EnableControls(); 358 EnableControls();
360 ShowCookieInfo(); 359 ShowCookieInfo();
361 } 360 }
362 361
(...skipping 28 matching lines...) Expand all
391 views::View* pane = new views::View(); 390 views::View* pane = new views::View();
392 GridLayout* layout = layout_utils::CreatePanelLayout(pane); 391 GridLayout* layout = layout_utils::CreatePanelLayout(pane);
393 392
394 const int single_column_layout_id = 0; 393 const int single_column_layout_id = 0;
395 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 394 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
396 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 395 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
397 GridLayout::USE_PREF, 0, 0); 396 GridLayout::USE_PREF, 0, 0);
398 397
399 layout->StartRow(0, single_column_layout_id); 398 layout->StartRow(0, single_column_layout_id);
400 layout->AddView(allowed_label_); 399 layout->AddView(allowed_label_);
401 layout->AddPaddingRow( 400 layout->AddPaddingRow(0,
402 0, 401 ChromeViewsLayoutDelegate::Get()->GetDistanceMetric(
403 LayoutDelegate::Get()->GetMetric( 402 ChromeDistanceMetric::UNRELATED_CONTROL_VERTICAL));
404 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
405 403
406 layout->StartRow(1, single_column_layout_id); 404 layout->StartRow(1, single_column_layout_id);
407 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, 405 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1,
408 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, 406 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth,
409 kTreeViewHeight); 407 kTreeViewHeight);
410 layout->AddPaddingRow( 408 layout->AddPaddingRow(0,
411 0, LayoutDelegate::Get()->GetMetric( 409 ChromeViewsLayoutDelegate::Get()->GetDistanceMetric(
412 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 410 ChromeDistanceMetric::UNRELATED_CONTROL_VERTICAL));
413 411
414 StartNewButtonColumnSet(layout, single_column_layout_id + 1); 412 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
415 layout->AddView(block_allowed_button_); 413 layout->AddView(block_allowed_button_);
416 layout->AddView(delete_allowed_button_); 414 layout->AddView(delete_allowed_button_);
417 415
418 return pane; 416 return pane;
419 } 417 }
420 418
421 views::View* CollectedCookiesViews::CreateBlockedPane() { 419 views::View* CollectedCookiesViews::CreateBlockedPane() {
422 TabSpecificContentSettings* content_settings = 420 TabSpecificContentSettings* content_settings =
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 views::View* pane = new views::View(); 455 views::View* pane = new views::View();
458 GridLayout* layout = layout_utils::CreatePanelLayout(pane); 456 GridLayout* layout = layout_utils::CreatePanelLayout(pane);
459 457
460 const int single_column_layout_id = 0; 458 const int single_column_layout_id = 0;
461 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 459 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
462 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 460 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
463 GridLayout::USE_PREF, 0, 0); 461 GridLayout::USE_PREF, 0, 0);
464 462
465 layout->StartRow(0, single_column_layout_id); 463 layout->StartRow(0, single_column_layout_id);
466 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); 464 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL);
467 layout->AddPaddingRow( 465 layout->AddPaddingRow(0,
468 0, 466 ChromeViewsLayoutDelegate::Get()->GetDistanceMetric(
469 LayoutDelegate::Get()->GetMetric( 467 ChromeDistanceMetric::UNRELATED_CONTROL_VERTICAL));
470 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING));
471 468
472 layout->StartRow(1, single_column_layout_id); 469 layout->StartRow(1, single_column_layout_id);
473 layout->AddView( 470 layout->AddView(
474 CreateScrollView(blocked_cookies_tree_), 1, 1, 471 CreateScrollView(blocked_cookies_tree_), 1, 1,
475 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); 472 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight);
476 layout->AddPaddingRow( 473 layout->AddPaddingRow(0,
477 0, LayoutDelegate::Get()->GetMetric( 474 ChromeViewsLayoutDelegate::Get()->GetDistanceMetric(
478 LayoutDelegate::Metric::UNRELATED_CONTROL_VERTICAL_SPACING)); 475 ChromeDistanceMetric::UNRELATED_CONTROL_VERTICAL));
479 476
480 StartNewButtonColumnSet(layout, single_column_layout_id + 1); 477 StartNewButtonColumnSet(layout, single_column_layout_id + 1);
481 layout->AddView(allow_blocked_button_); 478 layout->AddView(allow_blocked_button_);
482 layout->AddView(for_session_blocked_button_); 479 layout->AddView(for_session_blocked_button_);
483 480
484 return pane; 481 return pane;
485 } 482 }
486 483
487 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { 484 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) {
488 views::ScrollView* scroll_view = 485 views::ScrollView* scroll_view =
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 /////////////////////////////////////////////////////////////////////////////// 554 ///////////////////////////////////////////////////////////////////////////////
558 // CollectedCookiesViews, content::NotificationObserver implementation: 555 // CollectedCookiesViews, content::NotificationObserver implementation:
559 556
560 void CollectedCookiesViews::Observe( 557 void CollectedCookiesViews::Observe(
561 int type, 558 int type,
562 const content::NotificationSource& source, 559 const content::NotificationSource& source,
563 const content::NotificationDetails& details) { 560 const content::NotificationDetails& details) {
564 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); 561 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type);
565 GetWidget()->Close(); 562 GetWidget()->Close();
566 } 563 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698