Commit 65bd7e54 authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[WebLayer] SecurityLevel+VisibleSecurityState from delegate.

Update PageInfo to get SecurityLevel and VisibleSecurityState from the
delegate, which moves a lot of duplicated logic from wherever PageInfo
is constructed into the delegate, and will also make componentizing
ConnectionInfoPopup and PageInfoController easier, because the
dependency on SecurityStateTabHelper won't be necessary.

UpdateSecurityState and ComputeUIInputs don't need SecurityLevel and
VisibleSecurityState, and have been updated to get them directly from
the delegate instead.

PageInfoTest was setting custom values for these, and so a test-only
method to set security state has been added.

Bug: 1052375
Change-Id: Icf09eba58654d46ca9f9bf075364c1f00793db91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2128107
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755050}
parent bb4cacc3
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "chrome/browser/media/webrtc/media_stream_capture_indicator.h" #include "chrome/browser/media/webrtc/media_stream_capture_indicator.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ui/page_info/chrome_page_info_delegate.h" #include "chrome/browser/ui/page_info/chrome_page_info_delegate.h"
#include "chrome/browser/vr/assets_loader.h" #include "chrome/browser/vr/assets_loader.h"
#include "chrome/browser/vr/browser_renderer.h" #include "chrome/browser/vr/browser_renderer.h"
...@@ -1204,12 +1203,9 @@ std::unique_ptr<PageInfo> VrShell::CreatePageInfo() { ...@@ -1204,12 +1203,9 @@ std::unique_ptr<PageInfo> VrShell::CreatePageInfo() {
if (!entry) if (!entry)
return nullptr; return nullptr;
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(web_contents_);
auto page_info = std::make_unique<PageInfo>( auto page_info = std::make_unique<PageInfo>(
std::make_unique<ChromePageInfoDelegate>(web_contents_), web_contents_, std::make_unique<ChromePageInfoDelegate>(web_contents_), web_contents_,
entry->GetVirtualURL(), helper->GetSecurityLevel(), entry->GetVirtualURL());
*helper->GetVisibleSecurityState());
page_info->InitializeUiState(this); page_info->InitializeUiState(this);
return page_info; return page_info;
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "chrome/android/chrome_jni_headers/ConnectionInfoPopup_jni.h" #include "chrome/android/chrome_jni_headers/ConnectionInfoPopup_jni.h"
#include "chrome/browser/android/resource_mapper.h" #include "chrome/browser/android/resource_mapper.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ui/page_info/chrome_page_info_delegate.h" #include "chrome/browser/ui/page_info/chrome_page_info_delegate.h"
#include "components/page_info/page_info.h" #include "components/page_info/page_info.h"
#include "components/security_state/core/security_state.h" #include "components/security_state/core/security_state.h"
...@@ -55,14 +54,9 @@ ConnectionInfoPopupAndroid::ConnectionInfoPopupAndroid( ...@@ -55,14 +54,9 @@ ConnectionInfoPopupAndroid::ConnectionInfoPopupAndroid(
popup_jobject_.Reset(env, java_page_info_pop); popup_jobject_.Reset(env, java_page_info_pop);
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(web_contents);
DCHECK(helper);
presenter_ = std::make_unique<PageInfo>( presenter_ = std::make_unique<PageInfo>(
std::make_unique<ChromePageInfoDelegate>(web_contents), web_contents, std::make_unique<ChromePageInfoDelegate>(web_contents), web_contents,
nav_entry->GetURL(), helper->GetSecurityLevel(), nav_entry->GetURL());
*helper->GetVisibleSecurityState());
presenter_->InitializeUiState(this); presenter_->InitializeUiState(this);
} }
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "chrome/android/chrome_jni_headers/PageInfoController_jni.h" #include "chrome/android/chrome_jni_headers/PageInfoController_jni.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ui/page_info/chrome_page_info_delegate.h" #include "chrome/browser/ui/page_info/chrome_page_info_delegate.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "components/content_settings/core/browser/host_content_settings_map.h" #include "components/content_settings/core/browser/host_content_settings_map.h"
...@@ -59,14 +58,9 @@ PageInfoControllerAndroid::PageInfoControllerAndroid( ...@@ -59,14 +58,9 @@ PageInfoControllerAndroid::PageInfoControllerAndroid(
controller_jobject_.Reset(env, java_page_info_pop); controller_jobject_.Reset(env, java_page_info_pop);
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(web_contents);
DCHECK(helper);
presenter_ = std::make_unique<PageInfo>( presenter_ = std::make_unique<PageInfo>(
std::make_unique<ChromePageInfoDelegate>(web_contents), web_contents, std::make_unique<ChromePageInfoDelegate>(web_contents), web_contents,
nav_entry->GetURL(), helper->GetSecurityLevel(), nav_entry->GetURL());
*helper->GetVisibleSecurityState());
presenter_->InitializeUiState(this); presenter_->InitializeUiState(this);
} }
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/browser/permissions/permission_manager_factory.h" #include "chrome/browser/permissions/permission_manager_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/chrome_password_protection_service.h" #include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ssl/stateful_ssl_host_state_delegate_factory.h" #include "chrome/browser/ssl/stateful_ssl_host_state_delegate_factory.h"
#include "chrome/browser/usb/usb_chooser_context.h" #include "chrome/browser/usb/usb_chooser_context.h"
#include "chrome/browser/usb/usb_chooser_context_factory.h" #include "chrome/browser/usb/usb_chooser_context_factory.h"
...@@ -207,3 +208,38 @@ HostContentSettingsMap* ChromePageInfoDelegate::GetContentSettings() { ...@@ -207,3 +208,38 @@ HostContentSettingsMap* ChromePageInfoDelegate::GetContentSettings() {
bool ChromePageInfoDelegate::IsContentDisplayedInVrHeadset() { bool ChromePageInfoDelegate::IsContentDisplayedInVrHeadset() {
return vr::VrTabHelper::IsContentDisplayedInHeadset(web_contents_); return vr::VrTabHelper::IsContentDisplayedInHeadset(web_contents_);
} }
security_state::SecurityLevel ChromePageInfoDelegate::GetSecurityLevel() {
if (security_state_for_tests_set_)
return security_level_for_tests_;
// This is a no-op if a SecurityStateTabHelper already exists for
// |web_contents|.
SecurityStateTabHelper::CreateForWebContents(web_contents_);
auto* helper = SecurityStateTabHelper::FromWebContents(web_contents_);
DCHECK(helper);
return helper->GetSecurityLevel();
}
security_state::VisibleSecurityState
ChromePageInfoDelegate::GetVisibleSecurityState() {
if (security_state_for_tests_set_)
return visible_security_state_for_tests_;
// This is a no-op if a SecurityStateTabHelper already exists for
// |web_contents|.
SecurityStateTabHelper::CreateForWebContents(web_contents_);
auto* helper = SecurityStateTabHelper::FromWebContents(web_contents_);
DCHECK(helper);
return *helper->GetVisibleSecurityState();
}
void ChromePageInfoDelegate::SetSecurityStateForTests(
security_state::SecurityLevel security_level,
security_state::VisibleSecurityState visible_security_state) {
security_state_for_tests_set_ = true;
security_level_for_tests_ = security_level;
visible_security_state_for_tests_ = visible_security_state;
}
...@@ -35,6 +35,10 @@ class ChromePageInfoDelegate : public PageInfoDelegate { ...@@ -35,6 +35,10 @@ class ChromePageInfoDelegate : public PageInfoDelegate {
explicit ChromePageInfoDelegate(content::WebContents* web_contents); explicit ChromePageInfoDelegate(content::WebContents* web_contents);
~ChromePageInfoDelegate() override = default; ~ChromePageInfoDelegate() override = default;
void SetSecurityStateForTests(
security_state::SecurityLevel security_level,
security_state::VisibleSecurityState visible_security_state);
// PageInfoDelegate implementation // PageInfoDelegate implementation
permissions::ChooserContextBase* GetChooserContext( permissions::ChooserContextBase* GetChooserContext(
ContentSettingsType type) override; ContentSettingsType type) override;
...@@ -65,6 +69,8 @@ class ChromePageInfoDelegate : public PageInfoDelegate { ...@@ -65,6 +69,8 @@ class ChromePageInfoDelegate : public PageInfoDelegate {
StatefulSSLHostStateDelegate* GetStatefulSSLHostStateDelegate() override; StatefulSSLHostStateDelegate* GetStatefulSSLHostStateDelegate() override;
HostContentSettingsMap* GetContentSettings() override; HostContentSettingsMap* GetContentSettings() override;
bool IsContentDisplayedInVrHeadset() override; bool IsContentDisplayedInVrHeadset() override;
security_state::SecurityLevel GetSecurityLevel() override;
security_state::VisibleSecurityState GetVisibleSecurityState() override;
private: private:
TabSpecificContentSettings* GetTabSpecificContentSettings() const; TabSpecificContentSettings* GetTabSpecificContentSettings() const;
...@@ -76,6 +82,9 @@ class ChromePageInfoDelegate : public PageInfoDelegate { ...@@ -76,6 +82,9 @@ class ChromePageInfoDelegate : public PageInfoDelegate {
GetChromePasswordProtectionService() const; GetChromePasswordProtectionService() const;
#endif #endif
content::WebContents* web_contents_; content::WebContents* web_contents_;
security_state::SecurityLevel security_level_for_tests_;
security_state::VisibleSecurityState visible_security_state_for_tests_;
bool security_state_for_tests_set_ = false;
}; };
#endif // CHROME_BROWSER_UI_PAGE_INFO_CHROME_PAGE_INFO_DELEGATE_H_ #endif // CHROME_BROWSER_UI_PAGE_INFO_CHROME_PAGE_INFO_DELEGATE_H_
...@@ -26,11 +26,8 @@ bool ShowPageInfoDialog(content::WebContents* web_contents, ...@@ -26,11 +26,8 @@ bool ShowPageInfoDialog(content::WebContents* web_contents,
if (!entry) if (!entry)
return false; return false;
SecurityStateTabHelper* helper = ShowPageInfoDialogImpl(browser, web_contents, entry->GetVirtualURL(), anchor,
SecurityStateTabHelper::FromWebContents(web_contents); std::move(closing_callback));
ShowPageInfoDialogImpl(
browser, web_contents, entry->GetVirtualURL(), helper->GetSecurityLevel(),
*helper->GetVisibleSecurityState(), anchor, std::move(closing_callback));
if (GetPageInfoDialogCreatedCallbackForTesting()) if (GetPageInfoDialogCreatedCallbackForTesting())
std::move(GetPageInfoDialogCreatedCallbackForTesting()).Run(); std::move(GetPageInfoDialogCreatedCallbackForTesting()).Run();
......
...@@ -39,8 +39,6 @@ void ShowPageInfoDialogImpl( ...@@ -39,8 +39,6 @@ void ShowPageInfoDialogImpl(
Browser* browser, Browser* browser,
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& virtual_url, const GURL& virtual_url,
security_state::SecurityLevel security_level,
const security_state::VisibleSecurityState& visible_security_state,
bubble_anchor_util::Anchor, bubble_anchor_util::Anchor,
PageInfoClosingCallback closing_callback); PageInfoClosingCallback closing_callback);
......
...@@ -199,10 +199,6 @@ class PageInfoTest : public ChromeRenderViewHostTestHarness { ...@@ -199,10 +199,6 @@ class PageInfoTest : public ChromeRenderViewHostTestHarness {
const url::Origin& origin() const { return origin_; } const url::Origin& origin() const { return origin_; }
scoped_refptr<net::X509Certificate> cert() { return cert_; } scoped_refptr<net::X509Certificate> cert() { return cert_; }
MockPageInfoUI* mock_ui() { return mock_ui_.get(); } MockPageInfoUI* mock_ui() { return mock_ui_.get(); }
security_state::SecurityLevel security_level() { return security_level_; }
const security_state::VisibleSecurityState& visible_security_state() {
return visible_security_state_;
}
const std::vector<std::unique_ptr<PageInfoUI::ChosenObjectInfo>>& const std::vector<std::unique_ptr<PageInfoUI::ChosenObjectInfo>>&
last_chosen_object_info() { last_chosen_object_info() {
return last_chosen_object_info_; return last_chosen_object_info_;
...@@ -216,9 +212,11 @@ class PageInfoTest : public ChromeRenderViewHostTestHarness { ...@@ -216,9 +212,11 @@ class PageInfoTest : public ChromeRenderViewHostTestHarness {
PageInfo* page_info() { PageInfo* page_info() {
if (!page_info_.get()) { if (!page_info_.get()) {
page_info_ = std::make_unique<PageInfo>( auto delegate = std::make_unique<ChromePageInfoDelegate>(web_contents());
std::make_unique<ChromePageInfoDelegate>(web_contents()), delegate->SetSecurityStateForTests(security_level_,
web_contents(), url(), security_level(), visible_security_state()); visible_security_state_);
page_info_ = std::make_unique<PageInfo>(std::move(delegate),
web_contents(), url());
page_info_->InitializeUiState(mock_ui()); page_info_->InitializeUiState(mock_ui());
} }
return page_info_.get(); return page_info_.get();
......
...@@ -1145,16 +1145,11 @@ bool LocationBarView::ShowPageInfoDialog() { ...@@ -1145,16 +1145,11 @@ bool LocationBarView::ShowPageInfoDialog() {
if (!entry) if (!entry)
return false; return false;
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(contents);
DCHECK(helper);
DCHECK(GetWidget()); DCHECK(GetWidget());
views::BubbleDialogDelegateView* bubble = views::BubbleDialogDelegateView* bubble =
PageInfoBubbleView::CreatePageInfoBubble( PageInfoBubbleView::CreatePageInfoBubble(
this, gfx::Rect(), GetWidget()->GetNativeWindow(), profile_, contents, this, gfx::Rect(), GetWidget()->GetNativeWindow(), profile_, contents,
entry->GetVirtualURL(), helper->GetSecurityLevel(), entry->GetVirtualURL(),
*helper->GetVisibleSecurityState(),
base::BindOnce(&LocationBarView::OnPageInfoBubbleClosed, base::BindOnce(&LocationBarView::OnPageInfoBubbleClosed,
weak_factory_.GetWeakPtr())); weak_factory_.GetWeakPtr()));
bubble->SetHighlightedButton(location_icon_view_); bubble->SetHighlightedButton(location_icon_view_);
......
...@@ -424,8 +424,6 @@ views::BubbleDialogDelegateView* PageInfoBubbleView::CreatePageInfoBubble( ...@@ -424,8 +424,6 @@ views::BubbleDialogDelegateView* PageInfoBubbleView::CreatePageInfoBubble(
Profile* profile, Profile* profile,
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& url, const GURL& url,
security_state::SecurityLevel security_level,
const security_state::VisibleSecurityState& visible_security_state,
PageInfoClosingCallback closing_callback) { PageInfoClosingCallback closing_callback) {
gfx::NativeView parent_view = platform_util::GetViewForWindow(parent_window); gfx::NativeView parent_view = platform_util::GetViewForWindow(parent_window);
...@@ -439,9 +437,8 @@ views::BubbleDialogDelegateView* PageInfoBubbleView::CreatePageInfoBubble( ...@@ -439,9 +437,8 @@ views::BubbleDialogDelegateView* PageInfoBubbleView::CreatePageInfoBubble(
web_contents, url); web_contents, url);
} }
return new PageInfoBubbleView( return new PageInfoBubbleView(anchor_view, anchor_rect, parent_view, profile,
anchor_view, anchor_rect, parent_view, profile, web_contents, url, web_contents, url, std::move(closing_callback));
security_level, visible_security_state, std::move(closing_callback));
} }
PageInfoBubbleView::PageInfoBubbleView( PageInfoBubbleView::PageInfoBubbleView(
...@@ -451,8 +448,6 @@ PageInfoBubbleView::PageInfoBubbleView( ...@@ -451,8 +448,6 @@ PageInfoBubbleView::PageInfoBubbleView(
Profile* profile, Profile* profile,
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& url, const GURL& url,
security_state::SecurityLevel security_level,
const security_state::VisibleSecurityState& visible_security_state,
PageInfoClosingCallback closing_callback) PageInfoClosingCallback closing_callback)
: PageInfoBubbleViewBase(anchor_view, : PageInfoBubbleViewBase(anchor_view,
anchor_rect, anchor_rect,
...@@ -522,8 +517,8 @@ PageInfoBubbleView::PageInfoBubbleView( ...@@ -522,8 +517,8 @@ PageInfoBubbleView::PageInfoBubbleView(
// |TabSpecificContentSettings| and need to create one; otherwise, noop. // |TabSpecificContentSettings| and need to create one; otherwise, noop.
TabSpecificContentSettings::CreateForWebContents(web_contents); TabSpecificContentSettings::CreateForWebContents(web_contents);
presenter_ = std::make_unique<PageInfo>( presenter_ = std::make_unique<PageInfo>(
std::make_unique<ChromePageInfoDelegate>(web_contents), web_contents, url, std::make_unique<ChromePageInfoDelegate>(web_contents), web_contents,
security_level, visible_security_state); url);
presenter_->InitializeUiState(this); presenter_->InitializeUiState(this);
} }
...@@ -923,16 +918,7 @@ void PageInfoBubbleView::LayoutPermissionsLikeUiRow(views::GridLayout* layout, ...@@ -923,16 +918,7 @@ void PageInfoBubbleView::LayoutPermissionsLikeUiRow(views::GridLayout* layout,
} }
void PageInfoBubbleView::DidChangeVisibleSecurityState() { void PageInfoBubbleView::DidChangeVisibleSecurityState() {
content::WebContents* contents = web_contents(); presenter_->UpdateSecurityState();
if (!contents)
return;
SecurityStateTabHelper* helper =
SecurityStateTabHelper::FromWebContents(contents);
DCHECK(helper);
presenter_->UpdateSecurityState(helper->GetSecurityLevel(),
*helper->GetVisibleSecurityState());
} }
#if BUILDFLAG(FULL_SAFE_BROWSING) #if BUILDFLAG(FULL_SAFE_BROWSING)
...@@ -1030,14 +1016,11 @@ void PageInfoBubbleView::StyledLabelLinkClicked(views::StyledLabel* label, ...@@ -1030,14 +1016,11 @@ void PageInfoBubbleView::StyledLabelLinkClicked(views::StyledLabel* label,
} }
} }
void ShowPageInfoDialogImpl( void ShowPageInfoDialogImpl(Browser* browser,
Browser* browser, content::WebContents* web_contents,
content::WebContents* web_contents, const GURL& virtual_url,
const GURL& virtual_url, bubble_anchor_util::Anchor anchor,
security_state::SecurityLevel security_level, PageInfoClosingCallback closing_callback) {
const security_state::VisibleSecurityState& visible_security_state,
bubble_anchor_util::Anchor anchor,
PageInfoClosingCallback closing_callback) {
AnchorConfiguration configuration = AnchorConfiguration configuration =
GetPageInfoAnchorConfiguration(browser, anchor); GetPageInfoAnchorConfiguration(browser, anchor);
gfx::Rect anchor_rect = gfx::Rect anchor_rect =
...@@ -1046,8 +1029,8 @@ void ShowPageInfoDialogImpl( ...@@ -1046,8 +1029,8 @@ void ShowPageInfoDialogImpl(
views::BubbleDialogDelegateView* bubble = views::BubbleDialogDelegateView* bubble =
PageInfoBubbleView::CreatePageInfoBubble( PageInfoBubbleView::CreatePageInfoBubble(
configuration.anchor_view, anchor_rect, parent_window, configuration.anchor_view, anchor_rect, parent_window,
browser->profile(), web_contents, virtual_url, security_level, browser->profile(), web_contents, virtual_url,
visible_security_state, std::move(closing_callback)); std::move(closing_callback));
bubble->SetHighlightedButton(configuration.highlighted_button); bubble->SetHighlightedButton(configuration.highlighted_button);
bubble->SetArrow(configuration.bubble_arrow); bubble->SetArrow(configuration.bubble_arrow);
bubble->GetWidget()->Show(); bubble->GetWidget()->Show();
......
...@@ -98,8 +98,6 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase, ...@@ -98,8 +98,6 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase,
Profile* profile, Profile* profile,
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& url, const GURL& url,
security_state::SecurityLevel security_level,
const security_state::VisibleSecurityState& visible_security_state,
PageInfoClosingCallback closing_callback); PageInfoClosingCallback closing_callback);
protected: protected:
...@@ -117,8 +115,6 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase, ...@@ -117,8 +115,6 @@ class PageInfoBubbleView : public PageInfoBubbleViewBase,
Profile* profile, Profile* profile,
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& url, const GURL& url,
security_state::SecurityLevel security_level,
const security_state::VisibleSecurityState& visible_security_state,
PageInfoClosingCallback closing_callback); PageInfoClosingCallback closing_callback);
// PageInfoBubbleViewBase: // PageInfoBubbleViewBase:
......
...@@ -79,7 +79,6 @@ class PageInfoBubbleViewTestApi { ...@@ -79,7 +79,6 @@ class PageInfoBubbleViewTestApi {
views::View* anchor_view = nullptr; views::View* anchor_view = nullptr;
view_ = new PageInfoBubbleView( view_ = new PageInfoBubbleView(
anchor_view, gfx::Rect(), parent_, profile_, web_contents_, GURL(kUrl), anchor_view, gfx::Rect(), parent_, profile_, web_contents_, GURL(kUrl),
security_state::NONE, security_state::VisibleSecurityState(),
base::BindOnce(&PageInfoBubbleViewTestApi::OnPageInfoBubbleClosed, base::BindOnce(&PageInfoBubbleViewTestApi::OnPageInfoBubbleClosed,
base::Unretained(this), run_loop_.QuitClosure())); base::Unretained(this), run_loop_.QuitClosure()));
} }
......
...@@ -301,12 +301,9 @@ const char kPageInfoTimeNoActionPrefix[] = ...@@ -301,12 +301,9 @@ const char kPageInfoTimeNoActionPrefix[] =
} // namespace } // namespace
PageInfo::PageInfo( PageInfo::PageInfo(std::unique_ptr<PageInfoDelegate> delegate,
std::unique_ptr<PageInfoDelegate> delegate, content::WebContents* web_contents,
content::WebContents* web_contents, const GURL& url)
const GURL& url,
security_state::SecurityLevel security_level,
const security_state::VisibleSecurityState& visible_security_state)
: content::WebContentsObserver(web_contents), : content::WebContentsObserver(web_contents),
delegate_(std::move(delegate)), delegate_(std::move(delegate)),
show_info_bar_(false), show_info_bar_(false),
...@@ -317,11 +314,11 @@ PageInfo::PageInfo( ...@@ -317,11 +314,11 @@ PageInfo::PageInfo(
site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN), site_connection_status_(SITE_CONNECTION_STATUS_UNKNOWN),
show_ssl_decision_revoke_button_(false), show_ssl_decision_revoke_button_(false),
did_revoke_user_ssl_decisions_(false), did_revoke_user_ssl_decisions_(false),
security_level_(security_level),
visible_security_state_for_metrics_(visible_security_state),
show_change_password_buttons_(false), show_change_password_buttons_(false),
did_perform_action_(false) { did_perform_action_(false) {
DCHECK(delegate_); DCHECK(delegate_);
security_level_ = delegate_->GetSecurityLevel();
visible_security_state_for_metrics_ = delegate_->GetVisibleSecurityState();
} }
PageInfo::~PageInfo() { PageInfo::~PageInfo() {
...@@ -399,8 +396,7 @@ void PageInfo::InitializeUiState(PageInfoUI* ui) { ...@@ -399,8 +396,7 @@ void PageInfo::InitializeUiState(PageInfoUI* ui) {
ui_ = ui; ui_ = ui;
DCHECK(ui_); DCHECK(ui_);
ComputeUIInputs(site_url_, security_level_, ComputeUIInputs(site_url_);
visible_security_state_for_metrics_);
PresentSitePermissions(); PresentSitePermissions();
PresentSiteIdentity(); PresentSiteIdentity();
PresentSiteData(); PresentSiteData();
...@@ -415,11 +411,8 @@ void PageInfo::InitializeUiState(PageInfoUI* ui) { ...@@ -415,11 +411,8 @@ void PageInfo::InitializeUiState(PageInfoUI* ui) {
start_time_ = base::TimeTicks::Now(); start_time_ = base::TimeTicks::Now();
} }
void PageInfo::UpdateSecurityState( void PageInfo::UpdateSecurityState() {
security_state::SecurityLevel security_level, ComputeUIInputs(site_url_);
const security_state::VisibleSecurityState& visible_security_state) {
visible_security_state_for_metrics_ = visible_security_state;
ComputeUIInputs(site_url_, security_level, visible_security_state);
PresentSiteIdentity(); PresentSiteIdentity();
} }
...@@ -618,10 +611,9 @@ permissions::ChooserContextBase* PageInfo::GetChooserContextFromUIInfo( ...@@ -618,10 +611,9 @@ permissions::ChooserContextBase* PageInfo::GetChooserContextFromUIInfo(
return delegate_->GetChooserContext(ui_info.content_settings_type); return delegate_->GetChooserContext(ui_info.content_settings_type);
} }
void PageInfo::ComputeUIInputs( void PageInfo::ComputeUIInputs(const GURL& url) {
const GURL& url, auto security_level = delegate_->GetSecurityLevel();
security_state::SecurityLevel security_level, auto visible_security_state = delegate_->GetVisibleSecurityState();
const security_state::VisibleSecurityState& visible_security_state) {
#if !defined(OS_ANDROID) #if !defined(OS_ANDROID)
// On desktop, internal URLs aren't handled by this class. Instead, a // On desktop, internal URLs aren't handled by this class. Instead, a
// custom and simpler bubble is shown. // custom and simpler bubble is shown.
...@@ -636,8 +628,6 @@ void PageInfo::ComputeUIInputs( ...@@ -636,8 +628,6 @@ void PageInfo::ComputeUIInputs(
is_chrome_ui_native_scheme = url.SchemeIs(browser_ui::kChromeUINativeScheme); is_chrome_ui_native_scheme = url.SchemeIs(browser_ui::kChromeUINativeScheme);
#endif #endif
security_level_ = security_level;
if (url.SchemeIs(url::kAboutScheme)) { if (url.SchemeIs(url::kAboutScheme)) {
// All about: URLs except about:blank are redirected. // All about: URLs except about:blank are redirected.
DCHECK_EQ(url::kAboutBlankURL, url.spec()); DCHECK_EQ(url::kAboutBlankURL, url.spec());
......
...@@ -143,9 +143,7 @@ class PageInfo : public content::WebContentsObserver { ...@@ -143,9 +143,7 @@ class PageInfo : public content::WebContentsObserver {
// object to determine the status of the site's connection. // object to determine the status of the site's connection.
PageInfo(std::unique_ptr<PageInfoDelegate> delegate, PageInfo(std::unique_ptr<PageInfoDelegate> delegate,
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& url, const GURL& url);
security_state::SecurityLevel security_level,
const security_state::VisibleSecurityState& visible_security_state);
~PageInfo() override; ~PageInfo() override;
// Initializes UI state that is dependent on having access to the PageInfoUI // Initializes UI state that is dependent on having access to the PageInfoUI
...@@ -159,9 +157,7 @@ class PageInfo : public content::WebContentsObserver { ...@@ -159,9 +157,7 @@ class PageInfo : public content::WebContentsObserver {
// This method is called to update the presenter's security state and forwards // This method is called to update the presenter's security state and forwards
// that change on to the UI to be redrawn. // that change on to the UI to be redrawn.
void UpdateSecurityState( void UpdateSecurityState();
security_state::SecurityLevel security_level,
const security_state::VisibleSecurityState& visible_security_state);
void RecordPageInfoAction(PageInfoAction action); void RecordPageInfoAction(PageInfoAction action);
...@@ -217,10 +213,7 @@ class PageInfo : public content::WebContentsObserver { ...@@ -217,10 +213,7 @@ class PageInfo : public content::WebContentsObserver {
friend class PageInfoBubbleViewBrowserTest; friend class PageInfoBubbleViewBrowserTest;
// Populates this object's UI state with provided security context. This // Populates this object's UI state with provided security context. This
// function does not update visible UI-- that's part of Present*(). // function does not update visible UI-- that's part of Present*().
void ComputeUIInputs( void ComputeUIInputs(const GURL& url);
const GURL& url,
const security_state::SecurityLevel security_level,
const security_state::VisibleSecurityState& visible_security_state);
// Sets (presents) the information about the site's permissions in the |ui_|. // Sets (presents) the information about the site's permissions in the |ui_|.
void PresentSitePermissions(); void PresentSitePermissions();
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "components/permissions/permission_uma_util.h" #include "components/permissions/permission_uma_util.h"
#include "components/safe_browsing/buildflags.h" #include "components/safe_browsing/buildflags.h"
#include "components/safe_browsing/content/password_protection/metrics_util.h" #include "components/safe_browsing/content/password_protection/metrics_util.h"
#include "components/security_state/core/security_state.h"
namespace safe_browsing { namespace safe_browsing {
class PasswordProtectionService; class PasswordProtectionService;
...@@ -86,6 +87,8 @@ class PageInfoDelegate { ...@@ -86,6 +87,8 @@ class PageInfoDelegate {
virtual HostContentSettingsMap* GetContentSettings() = 0; virtual HostContentSettingsMap* GetContentSettings() = 0;
virtual bool IsContentDisplayedInVrHeadset() = 0; virtual bool IsContentDisplayedInVrHeadset() = 0;
virtual security_state::SecurityLevel GetSecurityLevel() = 0;
virtual security_state::VisibleSecurityState GetVisibleSecurityState() = 0;
}; };
#endif // COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_ #endif // COMPONENTS_PAGE_INFO_PAGE_INFO_DELEGATE_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment