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

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

Issue 63343004: Remove DialogDelegate::UseNewStyle and unused code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Additional cleanup; sync and rebase. Created 7 years, 1 month 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 | Annotate | Revision Log
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/prefs/pref_service.h" 7 #include "base/prefs/pref_service.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_cookie_helper.h" 9 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
10 #include "chrome/browser/browsing_data/browsing_data_database_helper.h" 10 #include "chrome/browser/browsing_data/browsing_data_database_helper.h"
(...skipping 11 matching lines...) Expand all
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/constrained_window_views.h" 23 #include "chrome/browser/ui/views/constrained_window_views.h"
24 #include "chrome/browser/ui/views/cookie_info_view.h" 24 #include "chrome/browser/ui/views/cookie_info_view.h"
25 #include "chrome/common/pref_names.h" 25 #include "chrome/common/pref_names.h"
26 #include "components/web_modal/web_contents_modal_dialog_host.h" 26 #include "components/web_modal/web_contents_modal_dialog_host.h"
27 #include "components/web_modal/web_contents_modal_dialog_manager.h" 27 #include "components/web_modal/web_contents_modal_dialog_manager.h"
28 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 28 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
29 #include "content/public/browser/notification_details.h" 29 #include "content/public/browser/notification_details.h"
30 #include "content/public/browser/notification_source.h" 30 #include "content/public/browser/notification_source.h"
31 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
32 #include "content/public/browser/web_contents_view.h"
33 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
34 #include "grit/locale_settings.h" 33 #include "grit/locale_settings.h"
35 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
36 #include "net/cookies/canonical_cookie.h" 35 #include "net/cookies/canonical_cookie.h"
37 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
39 #include "ui/gfx/color_utils.h" 38 #include "ui/gfx/color_utils.h"
40 #include "ui/views/border.h" 39 #include "ui/views/border.h"
41 #include "ui/views/controls/button/label_button.h" 40 #include "ui/views/controls/button/label_button.h"
42 #include "ui/views/controls/image_view.h" 41 #include "ui/views/controls/image_view.h"
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 infobar_(NULL), 205 infobar_(NULL),
207 status_changed_(false) { 206 status_changed_(false) {
208 TabSpecificContentSettings* content_settings = 207 TabSpecificContentSettings* content_settings =
209 TabSpecificContentSettings::FromWebContents(web_contents); 208 TabSpecificContentSettings::FromWebContents(web_contents);
210 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, 209 registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
211 content::Source<TabSpecificContentSettings>(content_settings)); 210 content::Source<TabSpecificContentSettings>(content_settings));
212 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 211 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
213 WebContentsModalDialogManager::FromWebContents(web_contents); 212 WebContentsModalDialogManager::FromWebContents(web_contents);
214 WebContentsModalDialogManagerDelegate* modal_delegate = 213 WebContentsModalDialogManagerDelegate* modal_delegate =
215 web_contents_modal_dialog_manager->delegate(); 214 web_contents_modal_dialog_manager->delegate();
216 DCHECK(modal_delegate);
sky 2013/11/16 03:03:16 And here.
msw 2013/11/16 04:15:44 Done.
217 window_ = views::Widget::CreateWindowAsFramelessChild( 215 window_ = views::Widget::CreateWindowAsFramelessChild(
218 this, 216 this, modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
219 web_contents->GetView()->GetNativeView(),
220 modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
221 web_contents_modal_dialog_manager->ShowDialog(window_->GetNativeView()); 217 web_contents_modal_dialog_manager->ShowDialog(window_->GetNativeView());
222 } 218 }
223 219
224 /////////////////////////////////////////////////////////////////////////////// 220 ///////////////////////////////////////////////////////////////////////////////
225 // CollectedCookiesViews, views::DialogDelegate implementation: 221 // CollectedCookiesViews, views::DialogDelegate implementation:
226 222
227 string16 CollectedCookiesViews::GetWindowTitle() const { 223 string16 CollectedCookiesViews::GetWindowTitle() const {
228 return l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_DIALOG_TITLE); 224 return l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_DIALOG_TITLE);
229 } 225 }
230 226
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 320
325 GridLayout* layout = GridLayout::CreatePanel(this); 321 GridLayout* layout = GridLayout::CreatePanel(this);
326 SetLayoutManager(layout); 322 SetLayoutManager(layout);
327 323
328 const int single_column_layout_id = 0; 324 const int single_column_layout_id = 0;
329 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 325 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
330 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 326 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
331 GridLayout::USE_PREF, 0, 0); 327 GridLayout::USE_PREF, 0, 0);
332 328
333 layout->StartRow(0, single_column_layout_id); 329 layout->StartRow(0, single_column_layout_id);
334 views::TabbedPane* tabbed_pane = NULL; 330 views::TabbedPane* tabbed_pane = new views::TabbedPane();
335 if (DialogDelegate::UseNewStyle()) { 331 layout->SetInsets(gfx::Insets(kTabbedPaneTopPadding, 0, 0, 0));
336 tabbed_pane = new views::TabbedPane(false);
337 layout->SetInsets(gfx::Insets(kTabbedPaneTopPadding, 0, 0, 0));
338 } else {
339 tabbed_pane = new views::TabbedPane(true);
340 }
341 332
342 layout->AddView(tabbed_pane); 333 layout->AddView(tabbed_pane);
343 // NOTE: Panes must be added after |tabbed_pane| has been added to its parent. 334 // NOTE: Panes must be added after |tabbed_pane| has been added to its parent.
344 string16 label_allowed = l10n_util::GetStringUTF16( 335 string16 label_allowed = l10n_util::GetStringUTF16(
345 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL); 336 IDS_COLLECTED_COOKIES_ALLOWED_COOKIES_TAB_LABEL);
346 string16 label_blocked = l10n_util::GetStringUTF16( 337 string16 label_blocked = l10n_util::GetStringUTF16(
347 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL); 338 IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_TAB_LABEL);
348 tabbed_pane->AddTab(label_allowed, CreateAllowedPane()); 339 tabbed_pane->AddTab(label_allowed, CreateAllowedPane());
349 tabbed_pane->AddTab(label_blocked, CreateBlockedPane()); 340 tabbed_pane->AddTab(label_blocked, CreateBlockedPane());
350 tabbed_pane->SelectTabAt(0); 341 tabbed_pane->SelectTabAt(0);
351 tabbed_pane->set_listener(this); 342 tabbed_pane->set_listener(this);
352 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 343 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
353 344
354 layout->StartRow(0, single_column_layout_id); 345 layout->StartRow(0, single_column_layout_id);
355 cookie_info_view_ = new CookieInfoView(); 346 cookie_info_view_ = new CookieInfoView();
356 layout->AddView(cookie_info_view_); 347 layout->AddView(cookie_info_view_);
357 layout->AddPaddingRow(0, DialogDelegate::UseNewStyle() ? 348 layout->AddPaddingRow(0, kCookieInfoBottomPadding);
358 kCookieInfoBottomPadding :
359 views::kRelatedControlVerticalSpacing);
360 349
361 layout->StartRow(0, single_column_layout_id); 350 layout->StartRow(0, single_column_layout_id);
362 infobar_ = new InfobarView(); 351 infobar_ = new InfobarView();
363 layout->AddView(infobar_); 352 layout->AddView(infobar_);
364 353
365 EnableControls(); 354 EnableControls();
366 ShowCookieInfo(); 355 ShowCookieInfo();
367 } 356 }
368 357
369 views::View* CollectedCookiesViews::CreateAllowedPane() { 358 views::View* CollectedCookiesViews::CreateAllowedPane() {
(...skipping 17 matching lines...) Expand all
387 block_allowed_button_ = new views::LabelButton(this, 376 block_allowed_button_ = new views::LabelButton(this,
388 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_BLOCK_BUTTON)); 377 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_BLOCK_BUTTON));
389 block_allowed_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); 378 block_allowed_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
390 379
391 // Create the view that holds all the controls together. This will be the 380 // Create the view that holds all the controls together. This will be the
392 // pane added to the tabbed pane. 381 // pane added to the tabbed pane.
393 using views::GridLayout; 382 using views::GridLayout;
394 383
395 views::View* pane = new views::View(); 384 views::View* pane = new views::View();
396 GridLayout* layout = GridLayout::CreatePanel(pane); 385 GridLayout* layout = GridLayout::CreatePanel(pane);
397 if (DialogDelegate::UseNewStyle()) { 386 layout->SetInsets(kVPanelPadding, views::kButtonHEdgeMarginNew,
398 layout->SetInsets(kVPanelPadding, views::kButtonHEdgeMarginNew, 387 kVPanelPadding, views::kButtonHEdgeMarginNew);
399 kVPanelPadding, views::kButtonHEdgeMarginNew);
400 }
401 pane->SetLayoutManager(layout); 388 pane->SetLayoutManager(layout);
402 389
403 const int single_column_layout_id = 0; 390 const int single_column_layout_id = 0;
404 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 391 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
405 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 392 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
406 GridLayout::USE_PREF, 0, 0); 393 GridLayout::USE_PREF, 0, 0);
407 394
408 layout->StartRow(0, single_column_layout_id); 395 layout->StartRow(0, single_column_layout_id);
409 layout->AddView(allowed_label_); 396 layout->AddView(allowed_label_);
410 layout->AddPaddingRow(0, DialogDelegate::UseNewStyle() ? 397 layout->AddPaddingRow(0, kLabelBottomPadding);
411 kLabelBottomPadding :
412 views::kRelatedControlVerticalSpacing);
413 398
414 layout->StartRow(1, single_column_layout_id); 399 layout->StartRow(1, single_column_layout_id);
415 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1, 400 layout->AddView(CreateScrollView(allowed_cookies_tree_), 1, 1,
416 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, 401 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth,
417 kTreeViewHeight); 402 kTreeViewHeight);
418 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 403 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
419 404
420 layout->StartRow(0, single_column_layout_id); 405 layout->StartRow(0, single_column_layout_id);
421 layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING, 406 layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING,
422 GridLayout::CENTER); 407 GridLayout::CENTER);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 for_session_blocked_button_ = new views::LabelButton(this, 441 for_session_blocked_button_ = new views::LabelButton(this,
457 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON)); 442 l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON));
458 for_session_blocked_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); 443 for_session_blocked_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
459 444
460 // Create the view that holds all the controls together. This will be the 445 // Create the view that holds all the controls together. This will be the
461 // pane added to the tabbed pane. 446 // pane added to the tabbed pane.
462 using views::GridLayout; 447 using views::GridLayout;
463 448
464 views::View* pane = new views::View(); 449 views::View* pane = new views::View();
465 GridLayout* layout = GridLayout::CreatePanel(pane); 450 GridLayout* layout = GridLayout::CreatePanel(pane);
466 if (DialogDelegate::UseNewStyle()) { 451 layout->SetInsets(kVPanelPadding, views::kButtonHEdgeMarginNew,
467 layout->SetInsets(kVPanelPadding, views::kButtonHEdgeMarginNew, 452 kVPanelPadding, views::kButtonHEdgeMarginNew);
468 kVPanelPadding, views::kButtonHEdgeMarginNew);
469 }
470 pane->SetLayoutManager(layout); 453 pane->SetLayoutManager(layout);
471 454
472 const int single_column_layout_id = 0; 455 const int single_column_layout_id = 0;
473 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); 456 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id);
474 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, 457 column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
475 GridLayout::USE_PREF, 0, 0); 458 GridLayout::USE_PREF, 0, 0);
476 459
477 const int three_columns_layout_id = 1; 460 const int three_columns_layout_id = 1;
478 column_set = layout->AddColumnSet(three_columns_layout_id); 461 column_set = layout->AddColumnSet(three_columns_layout_id);
479 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 462 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
480 GridLayout::USE_PREF, 0, 0); 463 GridLayout::USE_PREF, 0, 0);
481 column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); 464 column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
482 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 465 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
483 GridLayout::USE_PREF, 0, 0); 466 GridLayout::USE_PREF, 0, 0);
484 467
485 layout->StartRow(0, single_column_layout_id); 468 layout->StartRow(0, single_column_layout_id);
486 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL); 469 layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL);
487 layout->AddPaddingRow(0, DialogDelegate::UseNewStyle() ? 470 layout->AddPaddingRow(0, kLabelBottomPadding);
488 kLabelBottomPadding :
489 views::kRelatedControlVerticalSpacing);
490 471
491 layout->StartRow(1, single_column_layout_id); 472 layout->StartRow(1, single_column_layout_id);
492 layout->AddView( 473 layout->AddView(
493 CreateScrollView(blocked_cookies_tree_), 1, 1, 474 CreateScrollView(blocked_cookies_tree_), 1, 1,
494 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight); 475 GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight);
495 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 476 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
496 477
497 layout->StartRow(0, three_columns_layout_id); 478 layout->StartRow(0, three_columns_layout_id);
498 layout->AddView(allow_blocked_button_); 479 layout->AddView(allow_blocked_button_);
499 layout->AddView(for_session_blocked_button_); 480 layout->AddView(for_session_blocked_button_);
500 481
501 return pane; 482 return pane;
502 } 483 }
503 484
504 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) { 485 views::View* CollectedCookiesViews::CreateScrollView(views::TreeView* pane) {
505 if (DialogDelegate::UseNewStyle()) { 486 views::ScrollView* scroll_view = new views::ScrollView();
506 views::ScrollView* scroll_view = new views::ScrollView(); 487 scroll_view->SetContents(pane);
507 scroll_view->SetContents(pane); 488 scroll_view->set_border(
508 scroll_view->set_border( 489 views::Border::CreateSolidBorder(1, kCookiesBorderColor));
509 views::Border::CreateSolidBorder(1, kCookiesBorderColor)); 490 return scroll_view;
510 return scroll_view;
511 } else {
512 return pane->CreateParentIfNecessary();
513 }
514 } 491 }
515 492
516 void CollectedCookiesViews::EnableControls() { 493 void CollectedCookiesViews::EnableControls() {
517 bool enable_allowed_buttons = false; 494 bool enable_allowed_buttons = false;
518 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode(); 495 ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode();
519 if (node) { 496 if (node) {
520 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); 497 CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node);
521 if (cookie_node->GetDetailedInfo().node_type == 498 if (cookie_node->GetDetailedInfo().node_type ==
522 CookieTreeNode::DetailedInfo::TYPE_HOST) { 499 CookieTreeNode::DetailedInfo::TYPE_HOST) {
523 enable_allowed_buttons = static_cast<CookieTreeHostNode*>( 500 enable_allowed_buttons = static_cast<CookieTreeHostNode*>(
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 /////////////////////////////////////////////////////////////////////////////// 553 ///////////////////////////////////////////////////////////////////////////////
577 // CollectedCookiesViews, content::NotificationObserver implementation: 554 // CollectedCookiesViews, content::NotificationObserver implementation:
578 555
579 void CollectedCookiesViews::Observe( 556 void CollectedCookiesViews::Observe(
580 int type, 557 int type,
581 const content::NotificationSource& source, 558 const content::NotificationSource& source,
582 const content::NotificationDetails& details) { 559 const content::NotificationDetails& details) {
583 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type); 560 DCHECK_EQ(chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN, type);
584 window_->Close(); 561 window_->Close();
585 } 562 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698