Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/website_settings/website_settings_popup_view.h " | 5 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h " |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/certificate_viewer.h" | 11 #include "chrome/browser/certificate_viewer.h" |
| 12 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_dialogs.h" | 15 #include "chrome/browser/ui/browser_dialogs.h" |
| 16 #include "chrome/browser/ui/views/collected_cookies_views.h" | 16 #include "chrome/browser/ui/views/collected_cookies_views.h" |
| 17 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" | 17 #include "chrome/browser/ui/views/website_settings/permission_selector_view.h" |
| 18 #include "chrome/browser/ui/website_settings/website_settings.h" | 18 #include "chrome/browser/ui/website_settings/website_settings.h" |
| 19 #include "chrome/browser/ui/website_settings/website_settings_utils.h" | 19 #include "chrome/browser/ui/website_settings/website_settings_utils.h" |
| 20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 21 #include "components/content_settings/core/common/content_settings_types.h" | 21 #include "components/content_settings/core/common/content_settings_types.h" |
| 22 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/cert_store.h" | 23 #include "content/public/browser/cert_store.h" |
| 24 #include "content/public/browser/ssl_host_state.h" | |
| 24 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
| 25 #include "grit/chromium_strings.h" | 26 #include "grit/chromium_strings.h" |
| 26 #include "grit/generated_resources.h" | 27 #include "grit/generated_resources.h" |
| 27 #include "grit/theme_resources.h" | 28 #include "grit/theme_resources.h" |
| 28 #include "grit/ui_resources.h" | 29 #include "grit/ui_resources.h" |
| 29 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/models/simple_menu_model.h" | 31 #include "ui/base/models/simple_menu_model.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
| 33 #include "ui/gfx/font_list.h" | 34 #include "ui/gfx/font_list.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 browser_(browser), | 304 browser_(browser), |
| 304 header_(NULL), | 305 header_(NULL), |
| 305 tabbed_pane_(NULL), | 306 tabbed_pane_(NULL), |
| 306 site_data_content_(NULL), | 307 site_data_content_(NULL), |
| 307 cookie_dialog_link_(NULL), | 308 cookie_dialog_link_(NULL), |
| 308 permissions_content_(NULL), | 309 permissions_content_(NULL), |
| 309 connection_tab_(NULL), | 310 connection_tab_(NULL), |
| 310 identity_info_content_(NULL), | 311 identity_info_content_(NULL), |
| 311 certificate_dialog_link_(NULL), | 312 certificate_dialog_link_(NULL), |
| 312 signed_certificate_timestamps_link_(NULL), | 313 signed_certificate_timestamps_link_(NULL), |
| 314 reset_decisions_button_(NULL), | |
| 313 cert_id_(0), | 315 cert_id_(0), |
| 314 help_center_link_(NULL), | 316 help_center_link_(NULL), |
| 315 connection_info_content_(NULL), | 317 connection_info_content_(NULL), |
| 316 page_info_content_(NULL), | 318 page_info_content_(NULL), |
| 317 weak_factory_(this) { | 319 weak_factory_(this) { |
| 318 // Compensate for built-in vertical padding in the anchor view's image. | 320 // Compensate for built-in vertical padding in the anchor view's image. |
| 319 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, | 321 set_anchor_view_insets(gfx::Insets(kLocationIconVerticalMargin, 0, |
| 320 kLocationIconVerticalMargin, 0)); | 322 kLocationIconVerticalMargin, 0)); |
| 321 | 323 |
| 322 views::GridLayout* layout = new views::GridLayout(this); | 324 views::GridLayout* layout = new views::GridLayout(this); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 void WebsiteSettingsPopupView::OnPermissionChanged( | 373 void WebsiteSettingsPopupView::OnPermissionChanged( |
| 372 const WebsiteSettingsUI::PermissionInfo& permission) { | 374 const WebsiteSettingsUI::PermissionInfo& permission) { |
| 373 presenter_->OnSitePermissionChanged(permission.type, permission.setting); | 375 presenter_->OnSitePermissionChanged(permission.type, permission.setting); |
| 374 } | 376 } |
| 375 | 377 |
| 376 void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) { | 378 void WebsiteSettingsPopupView::OnWidgetDestroying(views::Widget* widget) { |
| 377 is_popup_showing = false; | 379 is_popup_showing = false; |
| 378 presenter_->OnUIClosing(); | 380 presenter_->OnUIClosing(); |
| 379 } | 381 } |
| 380 | 382 |
| 381 void WebsiteSettingsPopupView::ButtonPressed( | |
| 382 views::Button* button, | |
| 383 const ui::Event& event) { | |
| 384 GetWidget()->Close(); | |
| 385 } | |
| 386 | |
| 387 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, | 383 void WebsiteSettingsPopupView::LinkClicked(views::Link* source, |
| 388 int event_flags) { | 384 int event_flags) { |
| 389 // The popup closes automatically when the collected cookies dialog or the | 385 // The popup closes automatically when the collected cookies dialog or the |
| 390 // certificate viewer opens. So delay handling of the link clicked to avoid | 386 // certificate viewer opens. So delay handling of the link clicked to avoid |
| 391 // a crash in the base class which needs to complete the mouse event handling. | 387 // a crash in the base class which needs to complete the mouse event handling. |
| 392 content::BrowserThread::PostTask( | 388 content::BrowserThread::PostTask( |
| 393 content::BrowserThread::UI, FROM_HERE, | 389 content::BrowserThread::UI, FROM_HERE, |
| 394 base::Bind(&WebsiteSettingsPopupView::HandleLinkClickedAsync, | 390 base::Bind(&WebsiteSettingsPopupView::HandleLinkClickedAsync, |
| 395 weak_factory_.GetWeakPtr(), source)); | 391 weak_factory_.GetWeakPtr(), source)); |
| 396 } | 392 } |
| 397 | 393 |
| 394 void WebsiteSettingsPopupView::ButtonPressed(views::Button* button, | |
| 395 const ui::Event& event) { | |
| 396 content::BrowserThread::PostTask( | |
| 397 content::BrowserThread::UI, | |
| 398 FROM_HERE, | |
| 399 base::Bind(&WebsiteSettingsPopupView::HandleButtonPressedAsync, | |
|
Peter Kasting
2014/08/06 01:19:07
Do you really need to do this asynchronously? The
jww
2014/08/06 17:58:18
This UI stuff is a bit of a mystery to me, and I w
| |
| 400 weak_factory_.GetWeakPtr(), | |
| 401 button)); | |
| 402 } | |
| 403 | |
| 398 void WebsiteSettingsPopupView::TabSelectedAt(int index) { | 404 void WebsiteSettingsPopupView::TabSelectedAt(int index) { |
| 399 tabbed_pane_->GetSelectedTab()->Layout(); | 405 tabbed_pane_->GetSelectedTab()->Layout(); |
| 400 SizeToContents(); | 406 SizeToContents(); |
| 401 } | 407 } |
| 402 | 408 |
| 403 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() const { | 409 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() const { |
| 404 if (header_ == NULL && tabbed_pane_ == NULL) | 410 if (header_ == NULL && tabbed_pane_ == NULL) |
| 405 return views::View::GetPreferredSize(); | 411 return views::View::GetPreferredSize(); |
| 406 | 412 |
| 407 int height = 0; | 413 int height = 0; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 549 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON)); | 555 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON)); |
| 550 certificate_dialog_link_->set_listener(this); | 556 certificate_dialog_link_->set_listener(this); |
| 551 | 557 |
| 552 if (!signed_certificate_timestamp_ids_.empty()) { | 558 if (!signed_certificate_timestamp_ids_.empty()) { |
| 553 signed_certificate_timestamps_link_ = | 559 signed_certificate_timestamps_link_ = |
| 554 new views::Link(l10n_util::GetStringUTF16( | 560 new views::Link(l10n_util::GetStringUTF16( |
| 555 IDS_PAGEINFO_CERT_TRANSPARENCY_INFO_BUTTON)); | 561 IDS_PAGEINFO_CERT_TRANSPARENCY_INFO_BUTTON)); |
| 556 signed_certificate_timestamps_link_->set_listener(this); | 562 signed_certificate_timestamps_link_->set_listener(this); |
| 557 } | 563 } |
| 558 | 564 |
| 565 if (identity_info.certificate_decision_made) { | |
| 566 reset_decisions_button_ = new views::LabelButton( | |
| 567 this, | |
| 568 l10n_util::GetStringUTF16( | |
| 569 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)); | |
| 570 reset_decisions_button_->SetStyle(views::Button::STYLE_BUTTON); | |
| 571 } | |
| 572 | |
| 559 headline = base::UTF8ToUTF16(identity_info.site_identity); | 573 headline = base::UTF8ToUTF16(identity_info.site_identity); |
| 560 } | 574 } |
| 561 ResetConnectionSection( | 575 ResetConnectionSection( |
| 562 identity_info_content_, | 576 identity_info_content_, |
| 563 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status), | 577 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status), |
| 564 base::string16(), // The identity section has no headline. | 578 base::string16(), // The identity section has no headline. |
| 565 base::UTF8ToUTF16(identity_info.identity_status_description), | 579 base::UTF8ToUTF16(identity_info.identity_status_description), |
| 566 certificate_dialog_link_, | 580 certificate_dialog_link_, |
| 567 signed_certificate_timestamps_link_); | 581 signed_certificate_timestamps_link_, |
| 582 reset_decisions_button_); | |
| 568 | 583 |
| 569 ResetConnectionSection( | 584 ResetConnectionSection( |
| 570 connection_info_content_, | 585 connection_info_content_, |
| 571 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status), | 586 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status), |
| 572 base::string16(), // The connection section has no headline. | 587 base::string16(), // The connection section has no headline. |
| 573 base::UTF8ToUTF16(identity_info.connection_status_description), | 588 base::UTF8ToUTF16(identity_info.connection_status_description), |
| 574 NULL, | 589 NULL, |
| 590 NULL, | |
| 575 NULL); | 591 NULL); |
| 576 | 592 |
| 577 connection_tab_->InvalidateLayout(); | 593 connection_tab_->InvalidateLayout(); |
| 578 Layout(); | 594 Layout(); |
| 579 SizeToContents(); | 595 SizeToContents(); |
| 580 } | 596 } |
| 581 | 597 |
| 582 void WebsiteSettingsPopupView::SetFirstVisit( | 598 void WebsiteSettingsPopupView::SetFirstVisit( |
| 583 const base::string16& first_visit) { | 599 const base::string16& first_visit) { |
| 584 ResetConnectionSection( | 600 ResetConnectionSection( |
| 585 page_info_content_, | 601 page_info_content_, |
| 586 WebsiteSettingsUI::GetFirstVisitIcon(first_visit), | 602 WebsiteSettingsUI::GetFirstVisitIcon(first_visit), |
| 587 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE), | 603 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE), |
| 588 first_visit, | 604 first_visit, |
| 589 NULL, | 605 NULL, |
| 606 NULL, | |
| 590 NULL); | 607 NULL); |
| 591 connection_tab_->InvalidateLayout(); | 608 connection_tab_->InvalidateLayout(); |
| 592 Layout(); | 609 Layout(); |
| 593 SizeToContents(); | 610 SizeToContents(); |
| 594 } | 611 } |
| 595 | 612 |
| 596 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { | 613 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { |
| 597 tabbed_pane_->SelectTabAt(tab_id); | 614 tabbed_pane_->SelectTabAt(tab_id); |
| 598 } | 615 } |
| 599 | 616 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 layout->AddPaddingRow(1, kPermissionsSectionPaddingBottom); | 715 layout->AddPaddingRow(1, kPermissionsSectionPaddingBottom); |
| 699 return container; | 716 return container; |
| 700 } | 717 } |
| 701 | 718 |
| 702 void WebsiteSettingsPopupView::ResetConnectionSection( | 719 void WebsiteSettingsPopupView::ResetConnectionSection( |
| 703 views::View* section_container, | 720 views::View* section_container, |
| 704 const gfx::Image& icon, | 721 const gfx::Image& icon, |
| 705 const base::string16& headline, | 722 const base::string16& headline, |
| 706 const base::string16& text, | 723 const base::string16& text, |
| 707 views::Link* link, | 724 views::Link* link, |
| 708 views::Link* secondary_link) { | 725 views::Link* secondary_link, |
| 726 views::LabelButton* reset_decisions_button) { | |
| 709 section_container->RemoveAllChildViews(true); | 727 section_container->RemoveAllChildViews(true); |
| 710 | 728 |
| 711 views::GridLayout* layout = new views::GridLayout(section_container); | 729 views::GridLayout* layout = new views::GridLayout(section_container); |
| 712 section_container->SetLayoutManager(layout); | 730 section_container->SetLayoutManager(layout); |
| 713 views::ColumnSet* column_set = layout->AddColumnSet(0); | 731 views::ColumnSet* column_set = layout->AddColumnSet(0); |
| 714 column_set->AddPaddingColumn(0, kConnectionSectionPaddingLeft); | 732 column_set->AddPaddingColumn(0, kConnectionSectionPaddingLeft); |
| 715 column_set->AddColumn(views::GridLayout::LEADING, | 733 column_set->AddColumn(views::GridLayout::LEADING, |
| 716 views::GridLayout::LEADING, | 734 views::GridLayout::LEADING, |
| 717 0, | 735 0, |
| 718 views::GridLayout::USE_PREF, | 736 views::GridLayout::USE_PREF, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 if (link) { | 789 if (link) { |
| 772 content_layout->StartRow(1, 0); | 790 content_layout->StartRow(1, 0); |
| 773 content_layout->AddView(link); | 791 content_layout->AddView(link); |
| 774 } | 792 } |
| 775 | 793 |
| 776 if (secondary_link) { | 794 if (secondary_link) { |
| 777 content_layout->StartRow(1, 0); | 795 content_layout->StartRow(1, 0); |
| 778 content_layout->AddView(secondary_link); | 796 content_layout->AddView(secondary_link); |
| 779 } | 797 } |
| 780 | 798 |
| 799 if (reset_decisions_button) { | |
| 800 content_layout->StartRow(1, 0); | |
| 801 content_layout->AddView(reset_decisions_button); | |
| 802 } | |
| 803 | |
| 781 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, | 804 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, |
| 782 views::GridLayout::LEADING); | 805 views::GridLayout::LEADING); |
| 783 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); | 806 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); |
| 784 } | 807 } |
| 785 | 808 |
| 786 // Used to asynchronously handle clicks since these calls may cause the | 809 // Used to asynchronously handle clicks since these calls may cause the |
| 787 // destruction of the settings view and the base class window still | 810 // destruction of the settings view and the base class window still |
| 788 // needs to be alive to finish handling the mouse click. | 811 // needs to be alive to finish handling the mouse click. |
| 789 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { | 812 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { |
| 790 if (source == cookie_dialog_link_) { | 813 if (source == cookie_dialog_link_) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 802 web_contents_, signed_certificate_timestamp_ids_); | 825 web_contents_, signed_certificate_timestamp_ids_); |
| 803 } else if (source == help_center_link_) { | 826 } else if (source == help_center_link_) { |
| 804 browser_->OpenURL(content::OpenURLParams( | 827 browser_->OpenURL(content::OpenURLParams( |
| 805 GURL(chrome::kPageInfoHelpCenterURL), | 828 GURL(chrome::kPageInfoHelpCenterURL), |
| 806 content::Referrer(), | 829 content::Referrer(), |
| 807 NEW_FOREGROUND_TAB, | 830 NEW_FOREGROUND_TAB, |
| 808 content::PAGE_TRANSITION_LINK, | 831 content::PAGE_TRANSITION_LINK, |
| 809 false)); | 832 false)); |
| 810 } | 833 } |
| 811 } | 834 } |
| 835 | |
| 836 void WebsiteSettingsPopupView::HandleButtonPressedAsync(views::Button* button) { | |
| 837 if (button == reset_decisions_button_) { | |
| 838 content::BrowserContext* context = web_contents_->GetBrowserContext(); | |
| 839 content::SSLHostState host_state(context); | |
| 840 host_state.RevokeAllowAndDenyPreferencesHard(presenter_->site_url().host()); | |
| 841 GetWidget()->Close(); | |
| 842 } | |
| 843 } | |
| OLD | NEW |