Commit 83baeabc authored by Mugdha Lakhani's avatar Mugdha Lakhani Committed by Commit Bot

[WebLayer] Refactor PageInfo.

A delegate interface PageInfoDelegate has been introduced
to allow the embedder to customize PageInfo.
ChromePageInfoDelegate is Chrome's implementation of it.

There will be follow up work to clean up chrome dependencies
from PageInfo, after which, PageInfo can be moved to components.

Bug: 1052375

Change-Id: I9b2ac5811ede505171787f23120cc46927e90f4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2089710
Commit-Queue: Mugdha Lakhani <nator@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#751995}
parent 5ce169f0
...@@ -30,11 +30,13 @@ ...@@ -30,11 +30,13 @@
#include "chrome/browser/android/vr/vr_shell_delegate.h" #include "chrome/browser/android/vr/vr_shell_delegate.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/component_updater/vr_assets_component_installer.h" #include "chrome/browser/component_updater/vr_assets_component_installer.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h" #include "chrome/browser/media/webrtc/media_capture_devices_dispatcher.h"
#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/ssl/security_state_tab_helper.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"
#include "chrome/browser/vr/location_bar_helper.h" #include "chrome/browser/vr/location_bar_helper.h"
...@@ -1205,6 +1207,7 @@ std::unique_ptr<PageInfo> VrShell::CreatePageInfo() { ...@@ -1205,6 +1207,7 @@ std::unique_ptr<PageInfo> VrShell::CreatePageInfo() {
SecurityStateTabHelper::FromWebContents(web_contents_); SecurityStateTabHelper::FromWebContents(web_contents_);
return std::make_unique<PageInfo>( return std::make_unique<PageInfo>(
this, Profile::FromBrowserContext(web_contents_->GetBrowserContext()), this, Profile::FromBrowserContext(web_contents_->GetBrowserContext()),
std::make_unique<ChromePageInfoDelegate>(web_contents_),
TabSpecificContentSettings::FromWebContents(web_contents_), web_contents_, TabSpecificContentSettings::FromWebContents(web_contents_), web_contents_,
entry->GetVirtualURL(), helper->GetSecurityLevel(), entry->GetVirtualURL(), helper->GetSecurityLevel(),
*helper->GetVisibleSecurityState()); *helper->GetVisibleSecurityState());
......
...@@ -124,10 +124,13 @@ jumbo_static_library("ui") { ...@@ -124,10 +124,13 @@ jumbo_static_library("ui") {
"native_file_system_dialogs.h", "native_file_system_dialogs.h",
"navigation_correction_tab_observer.cc", "navigation_correction_tab_observer.cc",
"navigation_correction_tab_observer.h", "navigation_correction_tab_observer.h",
"page_info/chrome_page_info_delegate.cc",
"page_info/chrome_page_info_delegate.h",
"page_info/chrome_page_info_ui_delegate.cc", "page_info/chrome_page_info_ui_delegate.cc",
"page_info/chrome_page_info_ui_delegate.h", "page_info/chrome_page_info_ui_delegate.h",
"page_info/page_info.cc", "page_info/page_info.cc",
"page_info/page_info.h", "page_info/page_info.h",
"page_info/page_info_delegate.h",
"page_info/page_info_ui.cc", "page_info/page_info_ui.cc",
"page_info/page_info_ui.h", "page_info/page_info_ui.h",
"page_info/page_info_ui_delegate.h", "page_info/page_info_ui_delegate.h",
......
...@@ -9,9 +9,11 @@ ...@@ -9,9 +9,11 @@
#include "base/android/jni_string.h" #include "base/android/jni_string.h"
#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/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ssl/security_state_tab_helper.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/page_info.h" #include "chrome/browser/ui/page_info/page_info.h"
#include "components/security_state/core/security_state.h" #include "components/security_state/core/security_state.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
...@@ -64,6 +66,7 @@ ConnectionInfoPopupAndroid::ConnectionInfoPopupAndroid( ...@@ -64,6 +66,7 @@ ConnectionInfoPopupAndroid::ConnectionInfoPopupAndroid(
TabSpecificContentSettings::CreateForWebContents(web_contents); TabSpecificContentSettings::CreateForWebContents(web_contents);
presenter_ = std::make_unique<PageInfo>( presenter_ = std::make_unique<PageInfo>(
this, Profile::FromBrowserContext(web_contents->GetBrowserContext()), this, Profile::FromBrowserContext(web_contents->GetBrowserContext()),
std::make_unique<ChromePageInfoDelegate>(web_contents),
TabSpecificContentSettings::FromWebContents(web_contents), web_contents, TabSpecificContentSettings::FromWebContents(web_contents), web_contents,
nav_entry->GetURL(), helper->GetSecurityLevel(), nav_entry->GetURL(), helper->GetSecurityLevel(),
*helper->GetVisibleSecurityState()); *helper->GetVisibleSecurityState());
......
...@@ -10,9 +10,11 @@ ...@@ -10,9 +10,11 @@
#include "base/command_line.h" #include "base/command_line.h"
#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/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ssl/security_state_tab_helper.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/page_info.h" #include "chrome/browser/ui/page_info/page_info.h"
#include "chrome/browser/ui/page_info/page_info_ui.h" #include "chrome/browser/ui/page_info/page_info_ui.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
...@@ -67,6 +69,7 @@ PageInfoControllerAndroid::PageInfoControllerAndroid( ...@@ -67,6 +69,7 @@ PageInfoControllerAndroid::PageInfoControllerAndroid(
TabSpecificContentSettings::CreateForWebContents(web_contents); TabSpecificContentSettings::CreateForWebContents(web_contents);
presenter_ = std::make_unique<PageInfo>( presenter_ = std::make_unique<PageInfo>(
this, Profile::FromBrowserContext(web_contents->GetBrowserContext()), this, Profile::FromBrowserContext(web_contents->GetBrowserContext()),
std::make_unique<ChromePageInfoDelegate>(web_contents),
TabSpecificContentSettings::FromWebContents(web_contents), web_contents, TabSpecificContentSettings::FromWebContents(web_contents), web_contents,
nav_entry->GetURL(), helper->GetSecurityLevel(), nav_entry->GetURL(), helper->GetSecurityLevel(),
*helper->GetVisibleSecurityState()); *helper->GetVisibleSecurityState());
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/page_info/chrome_page_info_delegate.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "content/public/browser/web_contents.h"
ChromePageInfoDelegate::ChromePageInfoDelegate(
content::WebContents* web_contents)
: web_contents_(web_contents) {}
bool ChromePageInfoDelegate::HasContentSettingChangedViaPageInfo(
ContentSettingsType type) {
return tab_specific_content_settings()->HasContentSettingChangedViaPageInfo(
type);
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_PAGE_INFO_CHROME_PAGE_INFO_DELEGATE_H_
#define CHROME_BROWSER_UI_PAGE_INFO_CHROME_PAGE_INFO_DELEGATE_H_
#include "build/build_config.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/ui/page_info/page_info_delegate.h"
#include "content/public/browser/web_contents_user_data.h"
namespace content {
class WebContents;
} // namespace content
class ChromePageInfoDelegate : public PageInfoDelegate {
public:
explicit ChromePageInfoDelegate(content::WebContents* web_contents);
~ChromePageInfoDelegate() override = default;
// PageInfoDelegate implementation
bool HasContentSettingChangedViaPageInfo(ContentSettingsType type) override;
private:
TabSpecificContentSettings* tab_specific_content_settings() const {
TabSpecificContentSettings::CreateForWebContents(web_contents_);
return TabSpecificContentSettings::FromWebContents(web_contents_);
}
content::WebContents* web_contents_;
};
#endif // CHROME_BROWSER_UI_PAGE_INFO_CHROME_PAGE_INFO_DELEGATE_H_
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h" #include "chrome/browser/safe_browsing/safe_browsing_service.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/ui/page_info/page_info_delegate.h"
#include "chrome/browser/ui/page_info/page_info_ui.h" #include "chrome/browser/ui/page_info/page_info_ui.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"
...@@ -172,12 +173,11 @@ bool IsPermissionFactoryDefault(HostContentSettingsMap* content_settings, ...@@ -172,12 +173,11 @@ bool IsPermissionFactoryDefault(HostContentSettingsMap* content_settings,
// Determines whether to show permission |type| in the Page Info UI. Only // Determines whether to show permission |type| in the Page Info UI. Only
// applies to permissions listed in |kPermissionType|. // applies to permissions listed in |kPermissionType|.
bool ShouldShowPermission( bool ShouldShowPermission(const PageInfoUI::PermissionInfo& info,
const PageInfoUI::PermissionInfo& info, const GURL& site_url,
const GURL& site_url, HostContentSettingsMap* content_settings,
HostContentSettingsMap* content_settings, content::WebContents* web_contents,
content::WebContents* web_contents, bool changed_since_last_page_load) {
TabSpecificContentSettings* tab_specific_content_settings) {
// Note |ContentSettingsType::ADS| will show up regardless of its default // Note |ContentSettingsType::ADS| will show up regardless of its default
// value when it has been activated on the current origin. // value when it has been activated on the current origin.
if (info.type == ContentSettingsType::ADS) { if (info.type == ContentSettingsType::ADS) {
...@@ -232,8 +232,7 @@ bool ShouldShowPermission( ...@@ -232,8 +232,7 @@ bool ShouldShowPermission(
// Show the content setting if it has been changed by the user since the last // Show the content setting if it has been changed by the user since the last
// page load. // page load.
if (tab_specific_content_settings->HasContentSettingChangedViaPageInfo( if (changed_since_last_page_load) {
info.type)) {
return true; return true;
} }
...@@ -358,6 +357,7 @@ const char kPageInfoTimeNoActionPrefix[] = ...@@ -358,6 +357,7 @@ const char kPageInfoTimeNoActionPrefix[] =
PageInfo::PageInfo( PageInfo::PageInfo(
PageInfoUI* ui, PageInfoUI* ui,
Profile* profile, Profile* profile,
std::unique_ptr<PageInfoDelegate> delegate,
TabSpecificContentSettings* tab_specific_content_settings, TabSpecificContentSettings* tab_specific_content_settings,
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& url, const GURL& url,
...@@ -365,6 +365,7 @@ PageInfo::PageInfo( ...@@ -365,6 +365,7 @@ PageInfo::PageInfo(
const security_state::VisibleSecurityState& visible_security_state) const security_state::VisibleSecurityState& visible_security_state)
: content::WebContentsObserver(web_contents), : content::WebContentsObserver(web_contents),
ui_(ui), ui_(ui),
delegate_(std::move(delegate)),
show_info_bar_(false), show_info_bar_(false),
site_url_(url), site_url_(url),
site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN), site_identity_status_(SITE_IDENTITY_STATUS_UNKNOWN),
...@@ -387,6 +388,7 @@ PageInfo::PageInfo( ...@@ -387,6 +388,7 @@ PageInfo::PageInfo(
#endif #endif
show_change_password_buttons_(false), show_change_password_buttons_(false),
did_perform_action_(false) { did_perform_action_(false) {
DCHECK(delegate_);
ComputeUIInputs(url, security_level, visible_security_state); ComputeUIInputs(url, security_level, visible_security_state);
PresentSitePermissions(); PresentSitePermissions();
...@@ -640,7 +642,7 @@ void PageInfo::OpenSiteSettingsView() { ...@@ -640,7 +642,7 @@ void PageInfo::OpenSiteSettingsView() {
#else #else
chrome::ShowSiteSettings(chrome::FindBrowserWithWebContents(web_contents()), chrome::ShowSiteSettings(chrome::FindBrowserWithWebContents(web_contents()),
site_url()); site_url());
RecordPageInfoAction(PageInfo::PAGE_INFO_SITE_SETTINGS_OPENED); RecordPageInfoAction(PAGE_INFO_SITE_SETTINGS_OPENED);
#endif #endif
} }
...@@ -1018,8 +1020,12 @@ void PageInfo::PresentSitePermissions() { ...@@ -1018,8 +1020,12 @@ void PageInfo::PresentSitePermissions() {
} }
} }
// TODO(crbug.com/1058597): Remove the call to |delegate_| once
// TabSpecificContentSettings has been componentized.
if (ShouldShowPermission(permission_info, site_url_, content_settings_, if (ShouldShowPermission(permission_info, site_url_, content_settings_,
web_contents(), tab_specific_content_settings_)) { web_contents(),
delegate_->HasContentSettingChangedViaPageInfo(
permission_info.type))) {
permission_info_list.push_back(permission_info); permission_info_list.push_back(permission_info);
} }
} }
......
...@@ -39,6 +39,7 @@ class ChromePasswordProtectionService; ...@@ -39,6 +39,7 @@ class ChromePasswordProtectionService;
class StatefulSSLHostStateDelegate; class StatefulSSLHostStateDelegate;
class HostContentSettingsMap; class HostContentSettingsMap;
class Profile; class Profile;
class PageInfoDelegate;
class PageInfoUI; class PageInfoUI;
class PageInfoBubbleViewBrowserTest; class PageInfoBubbleViewBrowserTest;
...@@ -152,6 +153,7 @@ class PageInfo : public content::WebContentsObserver { ...@@ -152,6 +153,7 @@ class PageInfo : public content::WebContentsObserver {
// |PageInfo| takes ownership of the |ui|. // |PageInfo| takes ownership of the |ui|.
PageInfo(PageInfoUI* ui, PageInfo(PageInfoUI* ui,
Profile* profile, Profile* profile,
std::unique_ptr<PageInfoDelegate> delegate,
TabSpecificContentSettings* tab_specific_content_settings, TabSpecificContentSettings* tab_specific_content_settings,
content::WebContents* web_contents, content::WebContents* web_contents,
const GURL& url, const GURL& url,
...@@ -256,6 +258,9 @@ class PageInfo : public content::WebContentsObserver { ...@@ -256,6 +258,9 @@ class PageInfo : public content::WebContentsObserver {
// information (identity, connection status, etc.). // information (identity, connection status, etc.).
PageInfoUI* ui_; PageInfoUI* ui_;
// The delegate allows the embedder to customize |PageInfo|'s behavior.
std::unique_ptr<PageInfoDelegate> delegate_;
// The flag that controls whether an infobar is displayed after the website // The flag that controls whether an infobar is displayed after the website
// settings UI is closed or not. // settings UI is closed or not.
bool show_info_bar_; bool show_info_bar_;
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_PAGE_INFO_PAGE_INFO_DELEGATE_H_
#define CHROME_BROWSER_UI_PAGE_INFO_PAGE_INFO_DELEGATE_H_
#include <string>
#include "components/content_settings/core/common/content_settings_types.h"
// PageInfoDelegate allows an embedder to customize PageInfo logic.
class PageInfoDelegate {
public:
virtual ~PageInfoDelegate() = default;
// Whether the content setting of type |type| has changed via Page Info UI.
virtual bool HasContentSettingChangedViaPageInfo(
ContentSettingsType type) = 0;
};
#endif // CHROME_BROWSER_UI_PAGE_INFO_PAGE_INFO_DELEGATE_H_
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "chrome/browser/infobars/mock_infobar_service.h" #include "chrome/browser/infobars/mock_infobar_service.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/ssl/tls_deprecation_test_utils.h" #include "chrome/browser/ssl/tls_deprecation_test_utils.h"
#include "chrome/browser/ui/page_info/chrome_page_info_delegate.h"
#include "chrome/browser/ui/page_info/chrome_page_info_ui_delegate.h" #include "chrome/browser/ui/page_info/chrome_page_info_ui_delegate.h"
#include "chrome/browser/ui/page_info/page_info_ui.h" #include "chrome/browser/ui/page_info/page_info_ui.h"
#include "chrome/browser/usb/usb_chooser_context.h" #include "chrome/browser/usb/usb_chooser_context.h"
...@@ -220,8 +221,10 @@ class PageInfoTest : public ChromeRenderViewHostTestHarness { ...@@ -220,8 +221,10 @@ class PageInfoTest : public ChromeRenderViewHostTestHarness {
PageInfo* page_info() { PageInfo* page_info() {
if (!page_info_.get()) { if (!page_info_.get()) {
page_info_ = std::make_unique<PageInfo>( page_info_ = std::make_unique<PageInfo>(
mock_ui(), profile(), tab_specific_content_settings(), web_contents(), mock_ui(), profile(),
url(), security_level(), visible_security_state()); std::make_unique<ChromePageInfoDelegate>(web_contents()),
tab_specific_content_settings(), web_contents(), url(),
security_level(), visible_security_state());
} }
return page_info_.get(); return page_info_.get();
} }
...@@ -1070,19 +1073,18 @@ TEST_F(PageInfoTest, SecurityLevelMetrics) { ...@@ -1070,19 +1073,18 @@ TEST_F(PageInfoTest, SecurityLevelMetrics) {
histograms.ExpectTotalCount(kGenericHistogram, 0); histograms.ExpectTotalCount(kGenericHistogram, 0);
histograms.ExpectTotalCount(test.histogram_name, 0); histograms.ExpectTotalCount(test.histogram_name, 0);
page_info()->RecordPageInfoAction( page_info()->RecordPageInfoAction(PageInfo::PAGE_INFO_OPENED);
PageInfo::PageInfoAction::PAGE_INFO_OPENED);
// RecordPageInfoAction() is called during PageInfo // RecordPageInfoAction() is called during PageInfo
// creation in addition to the explicit RecordPageInfoAction() // creation in addition to the explicit RecordPageInfoAction()
// call, so it is called twice in total. // call, so it is called twice in total.
histograms.ExpectTotalCount(kGenericHistogram, 2); histograms.ExpectTotalCount(kGenericHistogram, 2);
histograms.ExpectBucketCount(kGenericHistogram, histograms.ExpectBucketCount(kGenericHistogram, PageInfo::PAGE_INFO_OPENED,
PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); 2);
histograms.ExpectTotalCount(test.histogram_name, 2); histograms.ExpectTotalCount(test.histogram_name, 2);
histograms.ExpectBucketCount(test.histogram_name, histograms.ExpectBucketCount(test.histogram_name,
PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); PageInfo::PAGE_INFO_OPENED, 2);
} }
} }
...@@ -1183,19 +1185,18 @@ TEST_F(PageInfoTest, SafetyTipMetrics) { ...@@ -1183,19 +1185,18 @@ TEST_F(PageInfoTest, SafetyTipMetrics) {
histograms.ExpectTotalCount(kGenericHistogram, 0); histograms.ExpectTotalCount(kGenericHistogram, 0);
histograms.ExpectTotalCount(test.histogram_name, 0); histograms.ExpectTotalCount(test.histogram_name, 0);
page_info()->RecordPageInfoAction( page_info()->RecordPageInfoAction(PageInfo::PAGE_INFO_OPENED);
PageInfo::PageInfoAction::PAGE_INFO_OPENED);
// RecordPageInfoAction() is called during PageInfo // RecordPageInfoAction() is called during PageInfo
// creation in addition to the explicit RecordPageInfoAction() // creation in addition to the explicit RecordPageInfoAction()
// call, so it is called twice in total. // call, so it is called twice in total.
histograms.ExpectTotalCount(kGenericHistogram, 2); histograms.ExpectTotalCount(kGenericHistogram, 2);
histograms.ExpectBucketCount(kGenericHistogram, histograms.ExpectBucketCount(kGenericHistogram, PageInfo::PAGE_INFO_OPENED,
PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); 2);
histograms.ExpectTotalCount(test.histogram_name, 2); histograms.ExpectTotalCount(test.histogram_name, 2);
histograms.ExpectBucketCount(test.histogram_name, histograms.ExpectBucketCount(test.histogram_name,
PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); PageInfo::PAGE_INFO_OPENED, 2);
} }
} }
...@@ -1298,19 +1299,18 @@ TEST_F(PageInfoTest, LegacyTLSMetrics) { ...@@ -1298,19 +1299,18 @@ TEST_F(PageInfoTest, LegacyTLSMetrics) {
histograms.ExpectTotalCount(kHistogramPrefix + "." + test.histogram_suffix, histograms.ExpectTotalCount(kHistogramPrefix + "." + test.histogram_suffix,
0); 0);
page_info()->RecordPageInfoAction( page_info()->RecordPageInfoAction(PageInfo::PAGE_INFO_OPENED);
PageInfo::PageInfoAction::PAGE_INFO_OPENED);
// RecordPageInfoAction() is called during PageInfo creation in addition to // RecordPageInfoAction() is called during PageInfo creation in addition to
// the explicit RecordPageInfoAction() call, so it is called twice in total. // the explicit RecordPageInfoAction() call, so it is called twice in total.
histograms.ExpectTotalCount(kGenericHistogram, 2); histograms.ExpectTotalCount(kGenericHistogram, 2);
histograms.ExpectBucketCount(kGenericHistogram, histograms.ExpectBucketCount(kGenericHistogram, PageInfo::PAGE_INFO_OPENED,
PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); 2);
histograms.ExpectTotalCount(kHistogramPrefix + "." + test.histogram_suffix, histograms.ExpectTotalCount(kHistogramPrefix + "." + test.histogram_suffix,
2); 2);
histograms.ExpectBucketCount(kHistogramPrefix + "." + test.histogram_suffix, histograms.ExpectBucketCount(kHistogramPrefix + "." + test.histogram_suffix,
PageInfo::PageInfoAction::PAGE_INFO_OPENED, 2); PageInfo::PAGE_INFO_OPENED, 2);
} }
} }
......
...@@ -26,7 +26,9 @@ ...@@ -26,7 +26,9 @@
#include "chrome/browser/ssl/security_state_tab_helper.h" #include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/page_info/chrome_page_info_delegate.h"
#include "chrome/browser/ui/page_info/page_info.h" #include "chrome/browser/ui/page_info/page_info.h"
#include "chrome/browser/ui/page_info/page_info_delegate.h"
#include "chrome/browser/ui/page_info/page_info_dialog.h" #include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/view_ids.h"
...@@ -518,8 +520,9 @@ PageInfoBubbleView::PageInfoBubbleView( ...@@ -518,8 +520,9 @@ 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>(
this, profile, TabSpecificContentSettings::FromWebContents(web_contents), this, profile, std::make_unique<ChromePageInfoDelegate>(web_contents),
web_contents, url, security_level, visible_security_state); TabSpecificContentSettings::FromWebContents(web_contents), web_contents,
url, security_level, visible_security_state);
} }
void PageInfoBubbleView::WebContentsDestroyed() { void PageInfoBubbleView::WebContentsDestroyed() {
......
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