Commit 53b2989a authored by Emily Stark's avatar Emily Stark Committed by Commit Bot

Remove safety_tips namespace

Named namespaces are discouraged in chrome/ (as discussed on
chromium-dev and recently codified in
https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++-dos-and-donts.md#named-namespaces). This
removes the safety_tips namespace, renames a couple functions as
needed, and does a little more miscellaneous cleanup (e.g., removing
unnecessary aliases).

TBR=csharrison@chromium.org,ellyjones@chromium.org

Change-Id: I28dbd6ba2a90784fe148e91ccd75bc607d6192b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1876474Reviewed-by: default avatarEmily Stark <estark@chromium.org>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Reviewed-by: default avatarJoe DeBlasio <jdeblasio@chromium.org>
Commit-Queue: Emily Stark <estark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709073}
parent 0b4e397d
...@@ -101,7 +101,7 @@ void SafetyTipsComponentInstallerPolicy::ComponentReady( ...@@ -101,7 +101,7 @@ void SafetyTipsComponentInstallerPolicy::ComponentReady(
FROM_HERE, FROM_HERE,
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT}, {base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(&LoadSafetyTipsProtoFromDisk, pb_path), base::BindOnce(&LoadSafetyTipsProtoFromDisk, pb_path),
base::BindOnce(&safety_tips::SetRemoteConfigProto)); base::BindOnce(&SetSafetyTipsRemoteConfigProto));
} }
// Called during startup and installation before ComponentReady(). // Called during startup and installation before ComponentReady().
......
...@@ -258,8 +258,8 @@ IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest, ...@@ -258,8 +258,8 @@ IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
content::WebContents* contents = content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
safety_tips::ReputationWebContentsObserver* rep_observer = ReputationWebContentsObserver* rep_observer =
safety_tips::ReputationWebContentsObserver::FromWebContents(contents); ReputationWebContentsObserver::FromWebContents(contents);
ASSERT_TRUE(rep_observer); ASSERT_TRUE(rep_observer);
// Navigate to |url| and wait for the reputation check to complete before // Navigate to |url| and wait for the reputation check to complete before
...@@ -308,8 +308,8 @@ IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest, ...@@ -308,8 +308,8 @@ IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
content::WebContents* contents = content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
safety_tips::ReputationWebContentsObserver* rep_observer = ReputationWebContentsObserver* rep_observer =
safety_tips::ReputationWebContentsObserver::FromWebContents(contents); ReputationWebContentsObserver::FromWebContents(contents);
ASSERT_TRUE(rep_observer); ASSERT_TRUE(rep_observer);
// Navigate to |url| and wait for the reputation check to complete before // Navigate to |url| and wait for the reputation check to complete before
...@@ -483,8 +483,8 @@ IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest, ...@@ -483,8 +483,8 @@ IN_PROC_BROWSER_TEST_F(SecurityStatePageLoadMetricsBrowserTest,
} }
content::WebContents* contents = content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
safety_tips::ReputationWebContentsObserver* rep_observer = ReputationWebContentsObserver* rep_observer =
safety_tips::ReputationWebContentsObserver::FromWebContents(contents); ReputationWebContentsObserver::FromWebContents(contents);
ASSERT_TRUE(rep_observer); ASSERT_TRUE(rep_observer);
// Navigate to |url| and wait for the reputation check to complete before // Navigate to |url| and wait for the reputation check to complete before
......
...@@ -25,8 +25,6 @@ const base::FeatureParam<bool> kEnableLookalikeEditDistanceSiteEngagement{ ...@@ -25,8 +25,6 @@ const base::FeatureParam<bool> kEnableLookalikeEditDistanceSiteEngagement{
} // namespace } // namespace
namespace safety_tips {
bool ShouldTriggerSafetyTipFromLookalike( bool ShouldTriggerSafetyTipFromLookalike(
const GURL& url, const GURL& url,
const DomainInfo& navigated_domain, const DomainInfo& navigated_domain,
...@@ -103,5 +101,3 @@ bool ShouldTriggerSafetyTipFromKeywordInURL( ...@@ -103,5 +101,3 @@ bool ShouldTriggerSafetyTipFromKeywordInURL(
return false; return false;
} }
} // namespace safety_tips
...@@ -12,11 +12,6 @@ ...@@ -12,11 +12,6 @@
#include "chrome/browser/lookalikes/lookalike_url_service.h" #include "chrome/browser/lookalikes/lookalike_url_service.h"
#include "url/gurl.h" #include "url/gurl.h"
// These functions exist as utility functions, and are currently used in
// "safety_tip_heuristics". These functions SHOULD NOT be called directly. See
// reptuation_service.h for module use.
namespace safety_tips {
// Checks to see whether a given URL qualifies as a lookalike domain, and thus // Checks to see whether a given URL qualifies as a lookalike domain, and thus
// should trigger a safety tip. This algorithm factors in the sites that the // should trigger a safety tip. This algorithm factors in the sites that the
// user has already engaged with. This heuristic stores a "safe url" that the // user has already engaged with. This heuristic stores a "safe url" that the
...@@ -34,6 +29,4 @@ bool ShouldTriggerSafetyTipFromKeywordInURL( ...@@ -34,6 +29,4 @@ bool ShouldTriggerSafetyTipFromKeywordInURL(
const char* const sensitive_keywords[], const char* const sensitive_keywords[],
size_t num_keywords); size_t num_keywords);
} // namespace safety_tips
#endif // CHROME_BROWSER_REPUTATION_LOCAL_HEURISTICS_H_ #endif // CHROME_BROWSER_REPUTATION_LOCAL_HEURISTICS_H_
...@@ -104,7 +104,7 @@ TEST(SafetyTipHeuristicsTest, SensitiveKeywordsTest) { ...@@ -104,7 +104,7 @@ TEST(SafetyTipHeuristicsTest, SensitiveKeywordsTest) {
for (const auto& test_case : test_cases) { for (const auto& test_case : test_cases) {
ASSERT_EQ(test_case.should_trigger, ASSERT_EQ(test_case.should_trigger,
safety_tips::ShouldTriggerSafetyTipFromKeywordInURL( ShouldTriggerSafetyTipFromKeywordInURL(
test_case.url, keywords.data(), keywords.size())) test_case.url, keywords.data(), keywords.size()))
<< "Expected that \"" << test_case.url << "\" should" << "Expected that \"" << test_case.url << "\" should"
<< (test_case.should_trigger ? "" : "n't") << " trigger but it did" << (test_case.should_trigger ? "" : "n't") << " trigger but it did"
......
...@@ -29,7 +29,6 @@ namespace { ...@@ -29,7 +29,6 @@ namespace {
using chrome_browser_safety_tips::FlaggedPage; using chrome_browser_safety_tips::FlaggedPage;
using chrome_browser_safety_tips::UrlPattern; using chrome_browser_safety_tips::UrlPattern;
using safe_browsing::V4ProtocolManagerUtil; using safe_browsing::V4ProtocolManagerUtil;
using safety_tips::ReputationService;
// This factory helps construct and find the singleton ReputationService linked // This factory helps construct and find the singleton ReputationService linked
// to a Profile. // to a Profile.
...@@ -57,7 +56,7 @@ class ReputationServiceFactory : public BrowserContextKeyedServiceFactory { ...@@ -57,7 +56,7 @@ class ReputationServiceFactory : public BrowserContextKeyedServiceFactory {
// BrowserContextKeyedServiceFactory: // BrowserContextKeyedServiceFactory:
KeyedService* BuildServiceInstanceFor( KeyedService* BuildServiceInstanceFor(
content::BrowserContext* profile) const override { content::BrowserContext* profile) const override {
return new safety_tips::ReputationService(static_cast<Profile*>(profile)); return new ReputationService(static_cast<Profile*>(profile));
} }
content::BrowserContext* GetBrowserContextToUse( content::BrowserContext* GetBrowserContextToUse(
...@@ -122,7 +121,7 @@ bool ShouldSuppressWarning(const GURL& url) { ...@@ -122,7 +121,7 @@ bool ShouldSuppressWarning(const GURL& url) {
std::vector<std::string> patterns; std::vector<std::string> patterns;
UrlToPatterns(url, &patterns); UrlToPatterns(url, &patterns);
auto* proto = safety_tips::GetRemoteConfigProto(); auto* proto = GetSafetyTipsRemoteConfigProto();
if (!proto) { if (!proto) {
// This happens when the component hasn't downloaded yet. This should only // This happens when the component hasn't downloaded yet. This should only
// happen for a short time after initial upgrade to M79. // happen for a short time after initial upgrade to M79.
...@@ -153,8 +152,6 @@ bool ShouldSuppressWarning(const GURL& url) { ...@@ -153,8 +152,6 @@ bool ShouldSuppressWarning(const GURL& url) {
} // namespace } // namespace
namespace safety_tips {
ReputationService::ReputationService(Profile* profile) : profile_(profile) {} ReputationService::ReputationService(Profile* profile) : profile_(profile) {}
ReputationService::~ReputationService() {} ReputationService::~ReputationService() {}
...@@ -234,7 +231,7 @@ void ReputationService::GetReputationStatusWithEngagedSites( ...@@ -234,7 +231,7 @@ void ReputationService::GetReputationStatusWithEngagedSites(
} }
// 2. Server-side blocklist check. // 2. Server-side blocklist check.
security_state::SafetyTipStatus status = GetUrlBlockType(url); security_state::SafetyTipStatus status = GetSafetyTipUrlBlockType(url);
if (status != security_state::SafetyTipStatus::kNone) { if (status != security_state::SafetyTipStatus::kNone) {
std::move(callback).Run(status, IsIgnored(url), url, GURL()); std::move(callback).Run(status, IsIgnored(url), url, GURL());
return; return;
...@@ -271,11 +268,11 @@ void ReputationService::GetReputationStatusWithEngagedSites( ...@@ -271,11 +268,11 @@ void ReputationService::GetReputationStatusWithEngagedSites(
IsIgnored(url), url, GURL()); IsIgnored(url), url, GURL());
} }
security_state::SafetyTipStatus GetUrlBlockType(const GURL& url) { security_state::SafetyTipStatus GetSafetyTipUrlBlockType(const GURL& url) {
std::vector<std::string> patterns; std::vector<std::string> patterns;
UrlToPatterns(url, &patterns); UrlToPatterns(url, &patterns);
auto* proto = safety_tips::GetRemoteConfigProto(); auto* proto = GetSafetyTipsRemoteConfigProto();
if (!proto) { if (!proto) {
return security_state::SafetyTipStatus::kNone; return security_state::SafetyTipStatus::kNone;
} }
...@@ -305,5 +302,3 @@ security_state::SafetyTipStatus GetUrlBlockType(const GURL& url) { ...@@ -305,5 +302,3 @@ security_state::SafetyTipStatus GetUrlBlockType(const GURL& url) {
return security_state::SafetyTipStatus::kNone; return security_state::SafetyTipStatus::kNone;
} }
} // namespace safety_tips
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
class Profile; class Profile;
struct DomainInfo; struct DomainInfo;
namespace safety_tips {
// Callback type used for retrieving reputation status. |ignored| indicates // Callback type used for retrieving reputation status. |ignored| indicates
// whether the user has dismissed the warning and thus should not be warned // whether the user has dismissed the warning and thus should not be warned
// again. |url| is the URL applicable for this result, // again. |url| is the URL applicable for this result,
...@@ -78,8 +76,6 @@ class ReputationService : public KeyedService { ...@@ -78,8 +76,6 @@ class ReputationService : public KeyedService {
// Checks SafeBrowsing-style permutations of |url| against the component updater // Checks SafeBrowsing-style permutations of |url| against the component updater
// blocklist and returns the match type. kNone means the URL is not blocked. // blocklist and returns the match type. kNone means the URL is not blocked.
security_state::SafetyTipStatus GetUrlBlockType(const GURL& url); security_state::SafetyTipStatus GetSafetyTipUrlBlockType(const GURL& url);
} // namespace safety_tips
#endif // CHROME_BROWSER_REPUTATION_REPUTATION_SERVICE_H_ #endif // CHROME_BROWSER_REPUTATION_REPUTATION_SERVICE_H_
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#include "components/security_state/core/security_state.h" #include "components/security_state/core/security_state.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using safety_tips::GetUrlBlockType;
class ReputationServiceTest : public ChromeRenderViewHostTestHarness { class ReputationServiceTest : public ChromeRenderViewHostTestHarness {
protected: protected:
ReputationServiceTest() {} ReputationServiceTest() {}
...@@ -94,6 +92,6 @@ TEST_F(ReputationServiceTest, BlocklistTest) { ...@@ -94,6 +92,6 @@ TEST_F(ReputationServiceTest, BlocklistTest) {
}; };
for (auto test : kTests) { for (auto test : kTests) {
EXPECT_EQ(GetUrlBlockType(GURL(test.first)), test.second); EXPECT_EQ(GetSafetyTipUrlBlockType(GURL(test.first)), test.second);
} }
} }
...@@ -18,34 +18,34 @@ namespace { ...@@ -18,34 +18,34 @@ namespace {
void OnSafetyTipClosed(security_state::SafetyTipStatus safety_tip_status, void OnSafetyTipClosed(security_state::SafetyTipStatus safety_tip_status,
base::Time start_time, base::Time start_time,
safety_tips::SafetyTipInteraction action) { SafetyTipInteraction action) {
std::string action_suffix; std::string action_suffix;
bool warning_dismissed = false; bool warning_dismissed = false;
switch (action) { switch (action) {
case safety_tips::SafetyTipInteraction::kNoAction: case SafetyTipInteraction::kNoAction:
action_suffix = "NoAction"; action_suffix = "NoAction";
break; break;
case safety_tips::SafetyTipInteraction::kLeaveSite: case SafetyTipInteraction::kLeaveSite:
action_suffix = "LeaveSite"; action_suffix = "LeaveSite";
break; break;
case safety_tips::SafetyTipInteraction::kDismiss: case SafetyTipInteraction::kDismiss:
NOTREACHED(); NOTREACHED();
// Do nothing because the dismissal action passed to this method should // Do nothing because the dismissal action passed to this method should
// be the more specific version (esc, close, or ignore). // be the more specific version (esc, close, or ignore).
break; break;
case safety_tips::SafetyTipInteraction::kDismissWithEsc: case SafetyTipInteraction::kDismissWithEsc:
action_suffix = "DismissWithEsc"; action_suffix = "DismissWithEsc";
warning_dismissed = true; warning_dismissed = true;
break; break;
case safety_tips::SafetyTipInteraction::kDismissWithClose: case SafetyTipInteraction::kDismissWithClose:
action_suffix = "DismissWithClose"; action_suffix = "DismissWithClose";
warning_dismissed = true; warning_dismissed = true;
break; break;
case safety_tips::SafetyTipInteraction::kDismissWithIgnore: case SafetyTipInteraction::kDismissWithIgnore:
action_suffix = "DismissWithIgnore"; action_suffix = "DismissWithIgnore";
warning_dismissed = true; warning_dismissed = true;
break; break;
case safety_tips::SafetyTipInteraction::kLearnMore: case SafetyTipInteraction::kLearnMore:
action_suffix = "LearnMore"; action_suffix = "LearnMore";
break; break;
} }
...@@ -67,8 +67,6 @@ void OnSafetyTipClosed(security_state::SafetyTipStatus safety_tip_status, ...@@ -67,8 +67,6 @@ void OnSafetyTipClosed(security_state::SafetyTipStatus safety_tip_status,
} // namespace } // namespace
namespace safety_tips {
ReputationWebContentsObserver::~ReputationWebContentsObserver() {} ReputationWebContentsObserver::~ReputationWebContentsObserver() {}
void ReputationWebContentsObserver::DidFinishNavigation( void ReputationWebContentsObserver::DidFinishNavigation(
...@@ -187,5 +185,3 @@ void ReputationWebContentsObserver::MaybeCallReputationCheckCallback() { ...@@ -187,5 +185,3 @@ void ReputationWebContentsObserver::MaybeCallReputationCheckCallback() {
} }
WEB_CONTENTS_USER_DATA_KEY_IMPL(ReputationWebContentsObserver) WEB_CONTENTS_USER_DATA_KEY_IMPL(ReputationWebContentsObserver)
} // namespace safety_tips
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
class Profile; class Profile;
namespace safety_tips {
// Observes navigations and triggers a warning if a visited site is determined // Observes navigations and triggers a warning if a visited site is determined
// to be low-reputation as determined by heuristics or inclusion on // to be low-reputation as determined by heuristics or inclusion on
// pre-calculated lists. // pre-calculated lists.
...@@ -80,6 +78,4 @@ class ReputationWebContentsObserver ...@@ -80,6 +78,4 @@ class ReputationWebContentsObserver
WEB_CONTENTS_USER_DATA_KEY_DECL(); WEB_CONTENTS_USER_DATA_KEY_DECL();
}; };
} // namespace safety_tips
#endif // CHROME_BROWSER_REPUTATION_REPUTATION_WEB_CONTENTS_OBSERVER_H_ #endif // CHROME_BROWSER_REPUTATION_REPUTATION_WEB_CONTENTS_OBSERVER_H_
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
using base::android::ScopedJavaLocalRef; using base::android::ScopedJavaLocalRef;
using safety_tips::SafetyTipInfoBarDelegate;
namespace safety_tips {
// static // static
std::unique_ptr<infobars::InfoBar> SafetyTipInfoBar::CreateInfoBar( std::unique_ptr<infobars::InfoBar> SafetyTipInfoBar::CreateInfoBar(
...@@ -61,5 +58,3 @@ ScopedJavaLocalRef<jobject> SafetyTipInfoBar::CreateRenderInfoBar(JNIEnv* env) { ...@@ -61,5 +58,3 @@ ScopedJavaLocalRef<jobject> SafetyTipInfoBar::CreateRenderInfoBar(JNIEnv* env) {
SafetyTipInfoBarDelegate* SafetyTipInfoBar::GetDelegate() { SafetyTipInfoBarDelegate* SafetyTipInfoBar::GetDelegate() {
return static_cast<SafetyTipInfoBarDelegate*>(delegate()); return static_cast<SafetyTipInfoBarDelegate*>(delegate());
} }
} // namespace safety_tips
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/ui/android/infobars/confirm_infobar.h" #include "chrome/browser/ui/android/infobars/confirm_infobar.h"
namespace safety_tips {
class SafetyTipInfoBarDelegate; class SafetyTipInfoBarDelegate;
// SafetyTipInfoBar is a thin vineer over ConfirmInfoBar that adds a discrete // SafetyTipInfoBar is a thin vineer over ConfirmInfoBar that adds a discrete
...@@ -18,22 +16,19 @@ class SafetyTipInfoBarDelegate; ...@@ -18,22 +16,19 @@ class SafetyTipInfoBarDelegate;
class SafetyTipInfoBar : public ConfirmInfoBar { class SafetyTipInfoBar : public ConfirmInfoBar {
public: public:
static std::unique_ptr<infobars::InfoBar> CreateInfoBar( static std::unique_ptr<infobars::InfoBar> CreateInfoBar(
std::unique_ptr<safety_tips::SafetyTipInfoBarDelegate> delegate); std::unique_ptr<SafetyTipInfoBarDelegate> delegate);
~SafetyTipInfoBar() override; ~SafetyTipInfoBar() override;
private: private:
explicit SafetyTipInfoBar( explicit SafetyTipInfoBar(std::unique_ptr<SafetyTipInfoBarDelegate> delegate);
std::unique_ptr<safety_tips::SafetyTipInfoBarDelegate> delegate);
// ConfirmInfoBar: // ConfirmInfoBar:
base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar( base::android::ScopedJavaLocalRef<jobject> CreateRenderInfoBar(
JNIEnv* env) override; JNIEnv* env) override;
safety_tips::SafetyTipInfoBarDelegate* GetDelegate(); SafetyTipInfoBarDelegate* GetDelegate();
DISALLOW_COPY_AND_ASSIGN(SafetyTipInfoBar); DISALLOW_COPY_AND_ASSIGN(SafetyTipInfoBar);
}; };
} // namespace safety_tips
#endif // CHROME_BROWSER_REPUTATION_SAFETY_TIP_INFOBAR_H_ #endif // CHROME_BROWSER_REPUTATION_SAFETY_TIP_INFOBAR_H_
...@@ -16,11 +16,6 @@ ...@@ -16,11 +16,6 @@
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
using content::WebContents;
using safety_tips::SafetyTipInfoBarDelegate;
namespace safety_tips {
// From safety_tip_ui.h // From safety_tip_ui.h
void ShowSafetyTipDialog( void ShowSafetyTipDialog(
content::WebContents* web_contents, content::WebContents* web_contents,
...@@ -37,13 +32,11 @@ void ShowSafetyTipDialog( ...@@ -37,13 +32,11 @@ void ShowSafetyTipDialog(
SafetyTipInfoBar::CreateInfoBar(std::move(delegate))); SafetyTipInfoBar::CreateInfoBar(std::move(delegate)));
} }
} // namespace safety_tips
SafetyTipInfoBarDelegate::SafetyTipInfoBarDelegate( SafetyTipInfoBarDelegate::SafetyTipInfoBarDelegate(
security_state::SafetyTipStatus safety_tip_status, security_state::SafetyTipStatus safety_tip_status,
const GURL& url, const GURL& url,
const GURL& suggested_url, const GURL& suggested_url,
WebContents* web_contents, content::WebContents* web_contents,
base::OnceCallback<void(SafetyTipInteraction)> close_callback) base::OnceCallback<void(SafetyTipInteraction)> close_callback)
: safety_tip_status_(safety_tip_status), : safety_tip_status_(safety_tip_status),
url_(url), url_(url),
...@@ -82,8 +75,8 @@ bool SafetyTipInfoBarDelegate::Accept() { ...@@ -82,8 +75,8 @@ bool SafetyTipInfoBarDelegate::Accept() {
action_taken_ = SafetyTipInteraction::kLeaveSite; action_taken_ = SafetyTipInteraction::kLeaveSite;
auto url = safety_tip_status_ == security_state::SafetyTipStatus::kLookalike auto url = safety_tip_status_ == security_state::SafetyTipStatus::kLookalike
? suggested_url_ ? suggested_url_
: GURL(safety_tips::kSafeUrl); : GURL(kSafetyTipLeaveSiteUrl);
LeaveSite(web_contents_, url); LeaveSiteFromSafetyTip(web_contents_, url);
return true; return true;
} }
...@@ -95,7 +88,7 @@ bool SafetyTipInfoBarDelegate::Cancel() { ...@@ -95,7 +88,7 @@ bool SafetyTipInfoBarDelegate::Cancel() {
if (action_taken_ != SafetyTipInteraction::kDismissWithClose) { if (action_taken_ != SafetyTipInteraction::kDismissWithClose) {
action_taken_ = SafetyTipInteraction::kDismissWithIgnore; action_taken_ = SafetyTipInteraction::kDismissWithIgnore;
} }
safety_tips::ReputationService::Get(tab->GetProfile()) ReputationService::Get(tab->GetProfile())
->SetUserIgnore(web_contents_, url_, action_taken_); ->SetUserIgnore(web_contents_, url_, action_taken_);
} }
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "url/gurl.h" #include "url/gurl.h"
namespace safety_tips {
class SafetyTipInfoBarDelegate : public ConfirmInfoBarDelegate { class SafetyTipInfoBarDelegate : public ConfirmInfoBarDelegate {
public: public:
SafetyTipInfoBarDelegate( SafetyTipInfoBarDelegate(
...@@ -54,6 +52,4 @@ class SafetyTipInfoBarDelegate : public ConfirmInfoBarDelegate { ...@@ -54,6 +52,4 @@ class SafetyTipInfoBarDelegate : public ConfirmInfoBarDelegate {
content::WebContents* web_contents_; content::WebContents* web_contents_;
}; };
} // namespace safety_tips
#endif // CHROME_BROWSER_REPUTATION_SAFETY_TIP_INFOBAR_DELEGATE_H_ #endif // CHROME_BROWSER_REPUTATION_SAFETY_TIP_INFOBAR_DELEGATE_H_
...@@ -14,7 +14,7 @@ namespace { ...@@ -14,7 +14,7 @@ namespace {
// Retrieve existing config proto if set, or create a new one otherwise. // Retrieve existing config proto if set, or create a new one otherwise.
std::unique_ptr<chrome_browser_safety_tips::SafetyTipsConfig> GetConfig() { std::unique_ptr<chrome_browser_safety_tips::SafetyTipsConfig> GetConfig() {
auto* old = safety_tips::GetRemoteConfigProto(); auto* old = GetSafetyTipsRemoteConfigProto();
if (old) { if (old) {
return std::make_unique<chrome_browser_safety_tips::SafetyTipsConfig>(*old); return std::make_unique<chrome_browser_safety_tips::SafetyTipsConfig>(*old);
} }
...@@ -28,7 +28,7 @@ std::unique_ptr<chrome_browser_safety_tips::SafetyTipsConfig> GetConfig() { ...@@ -28,7 +28,7 @@ std::unique_ptr<chrome_browser_safety_tips::SafetyTipsConfig> GetConfig() {
} // namespace } // namespace
void InitializeSafetyTipConfig() { void InitializeSafetyTipConfig() {
safety_tips::SetRemoteConfigProto(GetConfig()); SetSafetyTipsRemoteConfigProto(GetConfig());
} }
void SetSafetyTipPatternsWithFlagType( void SetSafetyTipPatternsWithFlagType(
...@@ -43,7 +43,7 @@ void SetSafetyTipPatternsWithFlagType( ...@@ -43,7 +43,7 @@ void SetSafetyTipPatternsWithFlagType(
page->set_type(type); page->set_type(type);
} }
safety_tips::SetRemoteConfigProto(std::move(config_proto)); SetSafetyTipsRemoteConfigProto(std::move(config_proto));
} }
void SetSafetyTipBadRepPatterns(std::vector<std::string> patterns) { void SetSafetyTipBadRepPatterns(std::vector<std::string> patterns) {
...@@ -59,5 +59,5 @@ void SetSafetyTipAllowlistPatterns(std::vector<std::string> patterns) { ...@@ -59,5 +59,5 @@ void SetSafetyTipAllowlistPatterns(std::vector<std::string> patterns) {
config_proto->add_allowed_pattern(); config_proto->add_allowed_pattern();
page->set_pattern(pattern); page->set_pattern(pattern);
} }
safety_tips::SetRemoteConfigProto(std::move(config_proto)); SetSafetyTipsRemoteConfigProto(std::move(config_proto));
} }
...@@ -14,8 +14,6 @@ class WebContents; ...@@ -14,8 +14,6 @@ class WebContents;
class GURL; class GURL;
namespace safety_tips {
// Represents the different user interactions with a Safety Tip dialog. // Represents the different user interactions with a Safety Tip dialog.
// //
// These values are persisted to logs. Entries should not be renumbered and // These values are persisted to logs. Entries should not be renumbered and
...@@ -51,6 +49,4 @@ void ShowSafetyTipDialog( ...@@ -51,6 +49,4 @@ void ShowSafetyTipDialog(
const GURL& suggested_url, const GURL& suggested_url,
base::OnceCallback<void(SafetyTipInteraction)> close_callback); base::OnceCallback<void(SafetyTipInteraction)> close_callback);
} // namespace safety_tips
#endif // CHROME_BROWSER_REPUTATION_SAFETY_TIP_UI_H_ #endif // CHROME_BROWSER_REPUTATION_SAFETY_TIP_UI_H_
...@@ -14,10 +14,7 @@ ...@@ -14,10 +14,7 @@
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
namespace safety_tips { const char kSafetyTipLeaveSiteUrl[] = "chrome://newtab";
// URL that the "leave site" button aborts to.
const char kSafeUrl[] = "chrome://newtab";
void RecordSafetyTipInteractionHistogram(content::WebContents* web_contents, void RecordSafetyTipInteractionHistogram(content::WebContents* web_contents,
SafetyTipInteraction interaction) { SafetyTipInteraction interaction) {
...@@ -31,7 +28,8 @@ void RecordSafetyTipInteractionHistogram(content::WebContents* web_contents, ...@@ -31,7 +28,8 @@ void RecordSafetyTipInteractionHistogram(content::WebContents* web_contents,
interaction); interaction);
} }
void LeaveSite(content::WebContents* web_contents, const GURL& safe_url) { void LeaveSiteFromSafetyTip(content::WebContents* web_contents,
const GURL& safe_url) {
RecordSafetyTipInteractionHistogram(web_contents, RecordSafetyTipInteractionHistogram(web_contents,
SafetyTipInteraction::kLeaveSite); SafetyTipInteraction::kLeaveSite);
content::OpenURLParams params( content::OpenURLParams params(
...@@ -41,7 +39,7 @@ void LeaveSite(content::WebContents* web_contents, const GURL& safe_url) { ...@@ -41,7 +39,7 @@ void LeaveSite(content::WebContents* web_contents, const GURL& safe_url) {
web_contents->OpenURL(params); web_contents->OpenURL(params);
} }
void OpenHelpCenter(content::WebContents* web_contents) { void OpenHelpCenterFromSafetyTip(content::WebContents* web_contents) {
RecordSafetyTipInteractionHistogram(web_contents, RecordSafetyTipInteractionHistogram(web_contents,
SafetyTipInteraction::kLearnMore); SafetyTipInteraction::kLearnMore);
web_contents->OpenURL(content::OpenURLParams( web_contents->OpenURL(content::OpenURLParams(
...@@ -126,5 +124,3 @@ int GetSafetyTipLeaveButtonId(security_state::SafetyTipStatus warning_type) { ...@@ -126,5 +124,3 @@ int GetSafetyTipLeaveButtonId(security_state::SafetyTipStatus warning_type) {
NOTREACHED(); NOTREACHED();
return 0; return 0;
} }
} // namespace safety_tips
...@@ -14,10 +14,8 @@ namespace content { ...@@ -14,10 +14,8 @@ namespace content {
class WebContents; class WebContents;
} }
namespace safety_tips {
// URL that the "leave site" button aborts to by default. // URL that the "leave site" button aborts to by default.
extern const char kSafeUrl[]; extern const char kSafetyTipLeaveSiteUrl[];
// Records a histogram for a user's interaction with a Safety Tip in the given // Records a histogram for a user's interaction with a Safety Tip in the given
// |web_contents|. // |web_contents|.
...@@ -26,11 +24,12 @@ void RecordSafetyTipInteractionHistogram(content::WebContents* web_contents, ...@@ -26,11 +24,12 @@ void RecordSafetyTipInteractionHistogram(content::WebContents* web_contents,
// Invokes action when 'leave site' button is clicked, and records a histogram. // Invokes action when 'leave site' button is clicked, and records a histogram.
// Navigates to a safe URL, replacing the current page in the process. // Navigates to a safe URL, replacing the current page in the process.
void LeaveSite(content::WebContents* web_contents, const GURL& safe_url); void LeaveSiteFromSafetyTip(content::WebContents* web_contents,
const GURL& safe_url);
// Invoke action when 'Learn more' button is clicked, and records a histogram. // Invoke action when 'Learn more' button is clicked, and records a histogram.
// Navigates to the help center URL. // Navigates to the help center URL.
void OpenHelpCenter(content::WebContents* web_contents); void OpenHelpCenterFromSafetyTip(content::WebContents* web_contents);
// Get the titles, descriptions, and button strings or IDs needed to describe // Get the titles, descriptions, and button strings or IDs needed to describe
// the applicable warning type. Handles both Android and desktop warnings. // the applicable warning type. Handles both Android and desktop warnings.
...@@ -44,6 +43,4 @@ base::string16 GetSafetyTipDescription( ...@@ -44,6 +43,4 @@ base::string16 GetSafetyTipDescription(
const GURL& suggested_url); const GURL& suggested_url);
int GetSafetyTipLeaveButtonId(security_state::SafetyTipStatus warning_type); int GetSafetyTipLeaveButtonId(security_state::SafetyTipStatus warning_type);
} // namespace safety_tips
#endif // CHROME_BROWSER_REPUTATION_SAFETY_TIP_UI_HELPER_H_ #endif // CHROME_BROWSER_REPUTATION_SAFETY_TIP_UI_HELPER_H_
...@@ -30,17 +30,14 @@ class SafetyTipsConfigSingleton { ...@@ -30,17 +30,14 @@ class SafetyTipsConfigSingleton {
} // namespace } // namespace
namespace safety_tips {
// static // static
void SetRemoteConfigProto( void SetSafetyTipsRemoteConfigProto(
std::unique_ptr<chrome_browser_safety_tips::SafetyTipsConfig> proto) { std::unique_ptr<chrome_browser_safety_tips::SafetyTipsConfig> proto) {
SafetyTipsConfigSingleton::GetInstance().SetProto(std::move(proto)); SafetyTipsConfigSingleton::GetInstance().SetProto(std::move(proto));
} }
// static // static
const chrome_browser_safety_tips::SafetyTipsConfig* GetRemoteConfigProto() { const chrome_browser_safety_tips::SafetyTipsConfig*
GetSafetyTipsRemoteConfigProto() {
return SafetyTipsConfigSingleton::GetInstance().GetProto(); return SafetyTipsConfigSingleton::GetInstance().GetProto();
} }
} // namespace safety_tips
...@@ -9,19 +9,16 @@ ...@@ -9,19 +9,16 @@
#include "chrome/browser/reputation/safety_tips.pb.h" #include "chrome/browser/reputation/safety_tips.pb.h"
namespace safety_tips {
// Sets the global configuration for Safety Tips retrieved from the component // Sets the global configuration for Safety Tips retrieved from the component
// updater. The configuration proto contains the list of URLs that can trigger // updater. The configuration proto contains the list of URLs that can trigger
// a safety tip. // a safety tip.
void SetRemoteConfigProto( void SetSafetyTipsRemoteConfigProto(
std::unique_ptr<chrome_browser_safety_tips::SafetyTipsConfig> proto); std::unique_ptr<chrome_browser_safety_tips::SafetyTipsConfig> proto);
// Gets the global configuration for Safety Tips as retrieved from the component // Gets the global configuration for Safety Tips as retrieved from the component
// updater. The configuration proto contains the list of URLs that can trigger // updater. The configuration proto contains the list of URLs that can trigger
// a safety tip. // a safety tip.
const chrome_browser_safety_tips::SafetyTipsConfig* GetRemoteConfigProto(); const chrome_browser_safety_tips::SafetyTipsConfig*
GetSafetyTipsRemoteConfigProto();
} // namespace safety_tips
#endif // CHROME_BROWSER_REPUTATION_SAFETY_TIPS_CONFIG_H_ #endif // CHROME_BROWSER_REPUTATION_SAFETY_TIPS_CONFIG_H_
...@@ -158,9 +158,8 @@ SecurityStateTabHelper::GetVisibleSecurityState() { ...@@ -158,9 +158,8 @@ SecurityStateTabHelper::GetVisibleSecurityState() {
// information is still being initialized, thus no need to check for that. // information is still being initialized, thus no need to check for that.
state->malicious_content_status = GetMaliciousContentStatus(); state->malicious_content_status = GetMaliciousContentStatus();
safety_tips::ReputationWebContentsObserver* reputation_web_contents_observer = ReputationWebContentsObserver* reputation_web_contents_observer =
safety_tips::ReputationWebContentsObserver::FromWebContents( ReputationWebContentsObserver::FromWebContents(web_contents());
web_contents());
state->safety_tip_info = state->safety_tip_info =
reputation_web_contents_observer reputation_web_contents_observer
? reputation_web_contents_observer ? reputation_web_contents_observer
......
...@@ -255,8 +255,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) { ...@@ -255,8 +255,7 @@ void TabHelpers::AttachTabHelpers(WebContents* web_contents) {
web_contents); web_contents);
safe_browsing::TriggerCreator::MaybeCreateTriggersForWebContents( safe_browsing::TriggerCreator::MaybeCreateTriggersForWebContents(
profile, web_contents); profile, web_contents);
safety_tips::ReputationWebContentsObserver::CreateForWebContents( ReputationWebContentsObserver::CreateForWebContents(web_contents);
web_contents);
SearchEngineTabHelper::CreateForWebContents(web_contents); SearchEngineTabHelper::CreateForWebContents(web_contents);
SecurityStateTabHelper::CreateForWebContents(web_contents); SecurityStateTabHelper::CreateForWebContents(web_contents);
if (SiteEngagementService::IsEnabled()) if (SiteEngagementService::IsEnabled())
......
...@@ -996,7 +996,7 @@ void PageInfoBubbleView::StyledLabelLinkClicked(views::StyledLabel* label, ...@@ -996,7 +996,7 @@ void PageInfoBubbleView::StyledLabelLinkClicked(views::StyledLabel* label,
switch (label->GetID()) { switch (label->GetID()) {
case PageInfoBubbleView::VIEW_ID_PAGE_INFO_LABEL_SECURITY_DETAILS: case PageInfoBubbleView::VIEW_ID_PAGE_INFO_LABEL_SECURITY_DETAILS:
if (GetSecurityDescriptionType() == SecurityDescriptionType::SAFETY_TIP) { if (GetSecurityDescriptionType() == SecurityDescriptionType::SAFETY_TIP) {
safety_tips::OpenHelpCenter(web_contents()); OpenHelpCenterFromSafetyTip(web_contents());
} else { } else {
web_contents()->OpenURL(content::OpenURLParams( web_contents()->OpenURL(content::OpenURLParams(
GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(), GURL(chrome::kPageInfoHelpCenterURL), content::Referrer(),
......
...@@ -30,8 +30,6 @@ ...@@ -30,8 +30,6 @@
#include "ui/views/window/dialog_client_view.h" #include "ui/views/window/dialog_client_view.h"
#include "url/gurl.h" #include "url/gurl.h"
using security_state::SafetyTipStatus;
namespace { namespace {
int GetSafetyTipBannerId(security_state::SafetyTipStatus safety_tip_status) { int GetSafetyTipBannerId(security_state::SafetyTipStatus safety_tip_status) {
...@@ -76,7 +74,7 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView( ...@@ -76,7 +74,7 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView(
security_state::SafetyTipStatus safety_tip_status, security_state::SafetyTipStatus safety_tip_status,
const GURL& url, const GURL& url,
const GURL& suggested_url, const GURL& suggested_url,
base::OnceCallback<void(safety_tips::SafetyTipInteraction)> close_callback) base::OnceCallback<void(SafetyTipInteraction)> close_callback)
: PageInfoBubbleViewBase(anchor_view, : PageInfoBubbleViewBase(anchor_view,
anchor_rect, anchor_rect,
parent_window, parent_window,
...@@ -91,7 +89,7 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView( ...@@ -91,7 +89,7 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView(
set_close_on_deactivate(false); set_close_on_deactivate(false);
const base::string16 title_text = const base::string16 title_text =
safety_tips::GetSafetyTipTitle(safety_tip_status, suggested_url); GetSafetyTipTitle(safety_tip_status, suggested_url);
set_window_title(title_text); set_window_title(title_text);
views::BubbleDialogDelegateView::CreateBubble(this); views::BubbleDialogDelegateView::CreateBubble(this);
...@@ -154,9 +152,8 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView( ...@@ -154,9 +152,8 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView(
layout_provider->GetDistanceMetric(DISTANCE_CONTROL_LIST_VERTICAL); layout_provider->GetDistanceMetric(DISTANCE_CONTROL_LIST_VERTICAL);
bottom_layout->StartRowWithPadding(views::GridLayout::kFixedSize, kColumnId, bottom_layout->StartRowWithPadding(views::GridLayout::kFixedSize, kColumnId,
views::GridLayout::kFixedSize, spacing); views::GridLayout::kFixedSize, spacing);
auto text_label = auto text_label = std::make_unique<views::Label>(
std::make_unique<views::Label>(safety_tips::GetSafetyTipDescription( GetSafetyTipDescription(safety_tip_status, url_, suggested_url_));
safety_tip_status, url_, suggested_url_));
text_label->SetMultiLine(true); text_label->SetMultiLine(true);
text_label->SetLineHeight(20); text_label->SetLineHeight(20);
text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); text_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
...@@ -211,9 +208,8 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView( ...@@ -211,9 +208,8 @@ SafetyTipPageInfoBubbleView::SafetyTipPageInfoBubbleView(
// Leave site button. // Leave site button.
std::unique_ptr<views::Button> leave_button( std::unique_ptr<views::Button> leave_button(
views::MdTextButton::CreateSecondaryUiBlueButton( views::MdTextButton::CreateSecondaryUiBlueButton(
this, this, l10n_util::GetStringUTF16(
l10n_util::GetStringUTF16( GetSafetyTipLeaveButtonId(safety_tip_status))));
safety_tips::GetSafetyTipLeaveButtonId(safety_tip_status))));
leave_button->SetID(PageInfoBubbleView::VIEW_ID_PAGE_INFO_BUTTON_LEAVE_SITE); leave_button->SetID(PageInfoBubbleView::VIEW_ID_PAGE_INFO_BUTTON_LEAVE_SITE);
leave_button_ = button_layout->AddView(std::move(leave_button)); leave_button_ = button_layout->AddView(std::move(leave_button));
...@@ -250,15 +246,15 @@ void SafetyTipPageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) { ...@@ -250,15 +246,15 @@ void SafetyTipPageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) {
// stumble there again, we should warn again. // stumble there again, we should warn again.
break; break;
case views::Widget::ClosedReason::kEscKeyPressed: case views::Widget::ClosedReason::kEscKeyPressed:
action_taken_ = safety_tips::SafetyTipInteraction::kDismissWithEsc; action_taken_ = SafetyTipInteraction::kDismissWithEsc;
should_set_ignore = true; should_set_ignore = true;
break; break;
case views::Widget::ClosedReason::kCloseButtonClicked: case views::Widget::ClosedReason::kCloseButtonClicked:
action_taken_ = safety_tips::SafetyTipInteraction::kDismissWithClose; action_taken_ = SafetyTipInteraction::kDismissWithClose;
should_set_ignore = true; should_set_ignore = true;
break; break;
case views::Widget::ClosedReason::kCancelButtonClicked: case views::Widget::ClosedReason::kCancelButtonClicked:
action_taken_ = safety_tips::SafetyTipInteraction::kDismissWithIgnore; action_taken_ = SafetyTipInteraction::kDismissWithIgnore;
should_set_ignore = true; should_set_ignore = true;
break; break;
} }
...@@ -266,7 +262,7 @@ void SafetyTipPageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) { ...@@ -266,7 +262,7 @@ void SafetyTipPageInfoBubbleView::OnWidgetDestroying(views::Widget* widget) {
if (should_set_ignore) { if (should_set_ignore) {
Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
if (browser) { if (browser) {
safety_tips::ReputationService::Get(browser->profile()) ReputationService::Get(browser->profile())
->SetUserIgnore(web_contents(), url_, action_taken_); ->SetUserIgnore(web_contents(), url_, action_taken_);
} }
} }
...@@ -276,15 +272,16 @@ void SafetyTipPageInfoBubbleView::ButtonPressed(views::Button* button, ...@@ -276,15 +272,16 @@ void SafetyTipPageInfoBubbleView::ButtonPressed(views::Button* button,
const ui::Event& event) { const ui::Event& event) {
switch (button->GetID()) { switch (button->GetID()) {
case PageInfoBubbleView::VIEW_ID_PAGE_INFO_BUTTON_LEAVE_SITE: case PageInfoBubbleView::VIEW_ID_PAGE_INFO_BUTTON_LEAVE_SITE:
action_taken_ = safety_tips::SafetyTipInteraction::kLeaveSite; action_taken_ = SafetyTipInteraction::kLeaveSite;
safety_tips::LeaveSite(web_contents(), LeaveSiteFromSafetyTip(
safety_tip_status_ == SafetyTipStatus::kLookalike web_contents(),
? suggested_url_ safety_tip_status_ == security_state::SafetyTipStatus::kLookalike
: GURL(safety_tips::kSafeUrl)); ? suggested_url_
: GURL(kSafetyTipLeaveSiteUrl));
return; return;
case PageInfoBubbleView::VIEW_ID_PAGE_INFO_BUTTON_IGNORE_WARNING: case PageInfoBubbleView::VIEW_ID_PAGE_INFO_BUTTON_IGNORE_WARNING:
action_taken_ = safety_tips::SafetyTipInteraction::kDismiss; action_taken_ = SafetyTipInteraction::kDismiss;
GetWidget()->CloseWithReason( GetWidget()->CloseWithReason(
views::Widget::ClosedReason::kCancelButtonClicked); views::Widget::ClosedReason::kCancelButtonClicked);
return; return;
...@@ -296,12 +293,10 @@ void SafetyTipPageInfoBubbleView::StyledLabelLinkClicked( ...@@ -296,12 +293,10 @@ void SafetyTipPageInfoBubbleView::StyledLabelLinkClicked(
views::StyledLabel* label, views::StyledLabel* label,
const gfx::Range& range, const gfx::Range& range,
int event_flags) { int event_flags) {
action_taken_ = safety_tips::SafetyTipInteraction::kLearnMore; action_taken_ = SafetyTipInteraction::kLearnMore;
safety_tips::OpenHelpCenter(web_contents()); OpenHelpCenterFromSafetyTip(web_contents());
} }
namespace safety_tips {
void ShowSafetyTipDialog( void ShowSafetyTipDialog(
content::WebContents* web_contents, content::WebContents* web_contents,
security_state::SafetyTipStatus safety_tip_status, security_state::SafetyTipStatus safety_tip_status,
...@@ -331,16 +326,13 @@ void ShowSafetyTipDialog( ...@@ -331,16 +326,13 @@ void ShowSafetyTipDialog(
bubble->GetWidget()->Show(); bubble->GetWidget()->Show();
} }
} // namespace safety_tips
PageInfoBubbleViewBase* CreateSafetyTipBubbleForTesting( PageInfoBubbleViewBase* CreateSafetyTipBubbleForTesting(
gfx::NativeView parent_view, gfx::NativeView parent_view,
content::WebContents* web_contents, content::WebContents* web_contents,
security_state::SafetyTipStatus safety_tip_status, security_state::SafetyTipStatus safety_tip_status,
const GURL& virtual_url, const GURL& virtual_url,
const GURL& suggested_url, const GURL& suggested_url,
base::OnceCallback<void(safety_tips::SafetyTipInteraction)> base::OnceCallback<void(SafetyTipInteraction)> close_callback) {
close_callback) {
return new SafetyTipPageInfoBubbleView( return new SafetyTipPageInfoBubbleView(
nullptr, gfx::Rect(), parent_view, web_contents, safety_tip_status, nullptr, gfx::Rect(), parent_view, web_contents, safety_tip_status,
virtual_url, suggested_url, std::move(close_callback)); virtual_url, suggested_url, std::move(close_callback));
......
...@@ -45,8 +45,7 @@ class SafetyTipPageInfoBubbleView : public PageInfoBubbleViewBase, ...@@ -45,8 +45,7 @@ class SafetyTipPageInfoBubbleView : public PageInfoBubbleViewBase,
security_state::SafetyTipStatus safety_tip_status, security_state::SafetyTipStatus safety_tip_status,
const GURL& url, const GURL& url,
const GURL& suggested_url, const GURL& suggested_url,
base::OnceCallback<void(safety_tips::SafetyTipInteraction)> base::OnceCallback<void(SafetyTipInteraction)> close_callback);
close_callback);
~SafetyTipPageInfoBubbleView() override; ~SafetyTipPageInfoBubbleView() override;
// views::WidgetObserver: // views::WidgetObserver:
...@@ -79,9 +78,8 @@ class SafetyTipPageInfoBubbleView : public PageInfoBubbleViewBase, ...@@ -79,9 +78,8 @@ class SafetyTipPageInfoBubbleView : public PageInfoBubbleViewBase,
views::StyledLabel* info_button_; views::StyledLabel* info_button_;
views::Button* ignore_button_; views::Button* ignore_button_;
views::Button* leave_button_; views::Button* leave_button_;
base::OnceCallback<void(safety_tips::SafetyTipInteraction)> close_callback_; base::OnceCallback<void(SafetyTipInteraction)> close_callback_;
safety_tips::SafetyTipInteraction action_taken_ = SafetyTipInteraction action_taken_ = SafetyTipInteraction::kNoAction;
safety_tips::SafetyTipInteraction::kNoAction;
DISALLOW_COPY_AND_ASSIGN(SafetyTipPageInfoBubbleView); DISALLOW_COPY_AND_ASSIGN(SafetyTipPageInfoBubbleView);
}; };
...@@ -93,6 +91,6 @@ PageInfoBubbleViewBase* CreateSafetyTipBubbleForTesting( ...@@ -93,6 +91,6 @@ PageInfoBubbleViewBase* CreateSafetyTipBubbleForTesting(
security_state::SafetyTipStatus safety_tip_status, security_state::SafetyTipStatus safety_tip_status,
const GURL& virtual_url, const GURL& virtual_url,
const GURL& suggested_url, const GURL& suggested_url,
base::OnceCallback<void(safety_tips::SafetyTipInteraction)> close_callback); base::OnceCallback<void(SafetyTipInteraction)> close_callback);
#endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_SAFETY_TIP_PAGE_INFO_BUBBLE_VIEW_H_ #endif // CHROME_BROWSER_UI_VIEWS_PAGE_INFO_SAFETY_TIP_PAGE_INFO_BUBBLE_VIEW_H_
...@@ -648,7 +648,7 @@ IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest, ...@@ -648,7 +648,7 @@ IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest,
CloseWarningLeaveSite(browser()); CloseWarningLeaveSite(browser());
histogram_tester.ExpectUniqueSample( histogram_tester.ExpectUniqueSample(
kHistogramPrefix + "SafetyTip_Lookalike", kHistogramPrefix + "SafetyTip_Lookalike",
safety_tips::SafetyTipInteraction::kLeaveSite, 1); SafetyTipInteraction::kLeaveSite, 1);
} }
{ {
...@@ -663,10 +663,10 @@ IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest, ...@@ -663,10 +663,10 @@ IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest,
CloseWarningIgnore(views::Widget::ClosedReason::kCloseButtonClicked); CloseWarningIgnore(views::Widget::ClosedReason::kCloseButtonClicked);
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
kHistogramPrefix + "SafetyTip_BadReputation", kHistogramPrefix + "SafetyTip_BadReputation",
safety_tips::SafetyTipInteraction::kDismiss, 1); SafetyTipInteraction::kDismiss, 1);
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
kHistogramPrefix + "SafetyTip_BadReputation", kHistogramPrefix + "SafetyTip_BadReputation",
safety_tips::SafetyTipInteraction::kDismissWithClose, 1); SafetyTipInteraction::kDismissWithClose, 1);
} }
// Test that the specific dismissal type is recorded correctly. // Test that the specific dismissal type is recorded correctly.
...@@ -678,10 +678,10 @@ IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest, ...@@ -678,10 +678,10 @@ IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest,
CloseWarningIgnore(views::Widget::ClosedReason::kEscKeyPressed); CloseWarningIgnore(views::Widget::ClosedReason::kEscKeyPressed);
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
kHistogramPrefix + "SafetyTip_BadReputation", kHistogramPrefix + "SafetyTip_BadReputation",
safety_tips::SafetyTipInteraction::kDismiss, 1); SafetyTipInteraction::kDismiss, 1);
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
kHistogramPrefix + "SafetyTip_BadReputation", kHistogramPrefix + "SafetyTip_BadReputation",
safety_tips::SafetyTipInteraction::kDismissWithEsc, 1); SafetyTipInteraction::kDismissWithEsc, 1);
} }
{ {
...@@ -692,10 +692,10 @@ IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest, ...@@ -692,10 +692,10 @@ IN_PROC_BROWSER_TEST_P(SafetyTipPageInfoBubbleViewBrowserTest,
CloseWarningIgnore(views::Widget::ClosedReason::kCancelButtonClicked); CloseWarningIgnore(views::Widget::ClosedReason::kCancelButtonClicked);
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
kHistogramPrefix + "SafetyTip_BadReputation", kHistogramPrefix + "SafetyTip_BadReputation",
safety_tips::SafetyTipInteraction::kDismiss, 1); SafetyTipInteraction::kDismiss, 1);
histogram_tester.ExpectBucketCount( histogram_tester.ExpectBucketCount(
kHistogramPrefix + "SafetyTip_BadReputation", kHistogramPrefix + "SafetyTip_BadReputation",
safety_tips::SafetyTipInteraction::kDismissWithIgnore, 1); SafetyTipInteraction::kDismissWithIgnore, 1);
} }
} }
......
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