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, |
|
Peter Kasting
2014/08/07 03:56:57
So can we get rid of this async stuff as well? Or
jww
2014/08/08 16:48:50
I would rather leave that to someone else since I
Peter Kasting
2014/08/08 17:15:12
I would say, make it synchronous, try using it und
jww
2014/08/11 19:21:28
Done.
| |
| 395 weak_factory_.GetWeakPtr(), source)); | 391 weak_factory_.GetWeakPtr(), source)); |
| 396 } | 392 } |
| 397 | 393 |
| 394 void WebsiteSettingsPopupView::ButtonPressed(views::Button* button, | |
|
Peter Kasting
2014/08/07 03:56:57
Nit: Keep function definition order matching decla
jww
2014/08/08 16:48:50
Done.
| |
| 395 const ui::Event& event) { | |
| 396 if (button == reset_decisions_button_) { | |
| 397 content::SSLHostState(web_contents_->GetBrowserContext()). | |
| 398 RevokeAllowAndDenyPreferencesHard(presenter_->site_url().host()); | |
| 399 GetWidget()->Close(); | |
| 400 } | |
| 401 } | |
| 402 | |
| 398 void WebsiteSettingsPopupView::TabSelectedAt(int index) { | 403 void WebsiteSettingsPopupView::TabSelectedAt(int index) { |
| 399 tabbed_pane_->GetSelectedTab()->Layout(); | 404 tabbed_pane_->GetSelectedTab()->Layout(); |
| 400 SizeToContents(); | 405 SizeToContents(); |
| 401 } | 406 } |
| 402 | 407 |
| 403 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() const { | 408 gfx::Size WebsiteSettingsPopupView::GetPreferredSize() const { |
| 404 if (header_ == NULL && tabbed_pane_ == NULL) | 409 if (header_ == NULL && tabbed_pane_ == NULL) |
| 405 return views::View::GetPreferredSize(); | 410 return views::View::GetPreferredSize(); |
| 406 | 411 |
| 407 int height = 0; | 412 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)); | 554 l10n_util::GetStringUTF16(IDS_PAGEINFO_CERT_INFO_BUTTON)); |
| 550 certificate_dialog_link_->set_listener(this); | 555 certificate_dialog_link_->set_listener(this); |
| 551 | 556 |
| 552 if (!signed_certificate_timestamp_ids_.empty()) { | 557 if (!signed_certificate_timestamp_ids_.empty()) { |
| 553 signed_certificate_timestamps_link_ = | 558 signed_certificate_timestamps_link_ = |
| 554 new views::Link(l10n_util::GetStringUTF16( | 559 new views::Link(l10n_util::GetStringUTF16( |
| 555 IDS_PAGEINFO_CERT_TRANSPARENCY_INFO_BUTTON)); | 560 IDS_PAGEINFO_CERT_TRANSPARENCY_INFO_BUTTON)); |
| 556 signed_certificate_timestamps_link_->set_listener(this); | 561 signed_certificate_timestamps_link_->set_listener(this); |
| 557 } | 562 } |
| 558 | 563 |
| 564 if (identity_info.certificate_decision_made) { | |
| 565 reset_decisions_button_ = new views::LabelButton( | |
| 566 this, | |
| 567 l10n_util::GetStringUTF16( | |
| 568 IDS_PAGEINFO_RESET_INVALID_CERTIFICATE_DECISIONS_BUTTON)); | |
| 569 reset_decisions_button_->SetStyle(views::Button::STYLE_BUTTON); | |
| 570 } | |
| 571 | |
| 559 headline = base::UTF8ToUTF16(identity_info.site_identity); | 572 headline = base::UTF8ToUTF16(identity_info.site_identity); |
| 560 } | 573 } |
| 561 ResetConnectionSection( | 574 ResetConnectionSection( |
| 562 identity_info_content_, | 575 identity_info_content_, |
| 563 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status), | 576 WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status), |
| 564 base::string16(), // The identity section has no headline. | 577 base::string16(), // The identity section has no headline. |
| 565 base::UTF8ToUTF16(identity_info.identity_status_description), | 578 base::UTF8ToUTF16(identity_info.identity_status_description), |
| 566 certificate_dialog_link_, | 579 certificate_dialog_link_, |
| 567 signed_certificate_timestamps_link_); | 580 signed_certificate_timestamps_link_, |
| 581 reset_decisions_button_); | |
| 568 | 582 |
| 569 ResetConnectionSection( | 583 ResetConnectionSection( |
| 570 connection_info_content_, | 584 connection_info_content_, |
| 571 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status), | 585 WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status), |
| 572 base::string16(), // The connection section has no headline. | 586 base::string16(), // The connection section has no headline. |
| 573 base::UTF8ToUTF16(identity_info.connection_status_description), | 587 base::UTF8ToUTF16(identity_info.connection_status_description), |
| 574 NULL, | 588 NULL, |
| 589 NULL, | |
| 575 NULL); | 590 NULL); |
| 576 | 591 |
| 577 connection_tab_->InvalidateLayout(); | 592 connection_tab_->InvalidateLayout(); |
| 578 Layout(); | 593 Layout(); |
| 579 SizeToContents(); | 594 SizeToContents(); |
| 580 } | 595 } |
| 581 | 596 |
| 582 void WebsiteSettingsPopupView::SetFirstVisit( | 597 void WebsiteSettingsPopupView::SetFirstVisit( |
| 583 const base::string16& first_visit) { | 598 const base::string16& first_visit) { |
| 584 ResetConnectionSection( | 599 ResetConnectionSection( |
| 585 page_info_content_, | 600 page_info_content_, |
| 586 WebsiteSettingsUI::GetFirstVisitIcon(first_visit), | 601 WebsiteSettingsUI::GetFirstVisitIcon(first_visit), |
| 587 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE), | 602 l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE), |
| 588 first_visit, | 603 first_visit, |
| 589 NULL, | 604 NULL, |
| 605 NULL, | |
| 590 NULL); | 606 NULL); |
| 591 connection_tab_->InvalidateLayout(); | 607 connection_tab_->InvalidateLayout(); |
| 592 Layout(); | 608 Layout(); |
| 593 SizeToContents(); | 609 SizeToContents(); |
| 594 } | 610 } |
| 595 | 611 |
| 596 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { | 612 void WebsiteSettingsPopupView::SetSelectedTab(TabId tab_id) { |
| 597 tabbed_pane_->SelectTabAt(tab_id); | 613 tabbed_pane_->SelectTabAt(tab_id); |
| 598 } | 614 } |
| 599 | 615 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 698 layout->AddPaddingRow(1, kPermissionsSectionPaddingBottom); | 714 layout->AddPaddingRow(1, kPermissionsSectionPaddingBottom); |
| 699 return container; | 715 return container; |
| 700 } | 716 } |
| 701 | 717 |
| 702 void WebsiteSettingsPopupView::ResetConnectionSection( | 718 void WebsiteSettingsPopupView::ResetConnectionSection( |
| 703 views::View* section_container, | 719 views::View* section_container, |
| 704 const gfx::Image& icon, | 720 const gfx::Image& icon, |
| 705 const base::string16& headline, | 721 const base::string16& headline, |
| 706 const base::string16& text, | 722 const base::string16& text, |
| 707 views::Link* link, | 723 views::Link* link, |
| 708 views::Link* secondary_link) { | 724 views::Link* secondary_link, |
| 725 views::LabelButton* reset_decisions_button) { | |
| 709 section_container->RemoveAllChildViews(true); | 726 section_container->RemoveAllChildViews(true); |
| 710 | 727 |
| 711 views::GridLayout* layout = new views::GridLayout(section_container); | 728 views::GridLayout* layout = new views::GridLayout(section_container); |
| 712 section_container->SetLayoutManager(layout); | 729 section_container->SetLayoutManager(layout); |
| 713 views::ColumnSet* column_set = layout->AddColumnSet(0); | 730 views::ColumnSet* column_set = layout->AddColumnSet(0); |
| 714 column_set->AddPaddingColumn(0, kConnectionSectionPaddingLeft); | 731 column_set->AddPaddingColumn(0, kConnectionSectionPaddingLeft); |
| 715 column_set->AddColumn(views::GridLayout::LEADING, | 732 column_set->AddColumn(views::GridLayout::LEADING, |
| 716 views::GridLayout::LEADING, | 733 views::GridLayout::LEADING, |
| 717 0, | 734 0, |
| 718 views::GridLayout::USE_PREF, | 735 views::GridLayout::USE_PREF, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 771 if (link) { | 788 if (link) { |
| 772 content_layout->StartRow(1, 0); | 789 content_layout->StartRow(1, 0); |
| 773 content_layout->AddView(link); | 790 content_layout->AddView(link); |
| 774 } | 791 } |
| 775 | 792 |
| 776 if (secondary_link) { | 793 if (secondary_link) { |
| 777 content_layout->StartRow(1, 0); | 794 content_layout->StartRow(1, 0); |
| 778 content_layout->AddView(secondary_link); | 795 content_layout->AddView(secondary_link); |
| 779 } | 796 } |
| 780 | 797 |
| 798 if (reset_decisions_button) { | |
| 799 content_layout->StartRow(1, 0); | |
| 800 content_layout->AddView(reset_decisions_button); | |
| 801 } | |
| 802 | |
| 781 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, | 803 layout->AddView(content_pane, 1, 1, views::GridLayout::LEADING, |
| 782 views::GridLayout::LEADING); | 804 views::GridLayout::LEADING); |
| 783 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); | 805 layout->AddPaddingRow(0, kConnectionSectionPaddingBottom); |
| 784 } | 806 } |
| 785 | 807 |
| 786 // Used to asynchronously handle clicks since these calls may cause the | 808 // Used to asynchronously handle clicks since these calls may cause the |
| 787 // destruction of the settings view and the base class window still | 809 // destruction of the settings view and the base class window still |
| 788 // needs to be alive to finish handling the mouse click. | 810 // needs to be alive to finish handling the mouse click. |
| 789 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { | 811 void WebsiteSettingsPopupView::HandleLinkClickedAsync(views::Link* source) { |
| 790 if (source == cookie_dialog_link_) { | 812 if (source == cookie_dialog_link_) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 802 web_contents_, signed_certificate_timestamp_ids_); | 824 web_contents_, signed_certificate_timestamp_ids_); |
| 803 } else if (source == help_center_link_) { | 825 } else if (source == help_center_link_) { |
| 804 browser_->OpenURL(content::OpenURLParams( | 826 browser_->OpenURL(content::OpenURLParams( |
| 805 GURL(chrome::kPageInfoHelpCenterURL), | 827 GURL(chrome::kPageInfoHelpCenterURL), |
| 806 content::Referrer(), | 828 content::Referrer(), |
| 807 NEW_FOREGROUND_TAB, | 829 NEW_FOREGROUND_TAB, |
| 808 content::PAGE_TRANSITION_LINK, | 830 content::PAGE_TRANSITION_LINK, |
| 809 false)); | 831 false)); |
| 810 } | 832 } |
| 811 } | 833 } |
| OLD | NEW |