Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3294)

Unified Diff: chrome/browser/ssl/ssl_browser_tests.cc

Issue 2448943002: Refactor SecurityStateModel/Clients for simplicity and reusability. (Closed)
Patch Set: update comments. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ssl/ssl_browser_tests.cc
diff --git a/chrome/browser/ssl/ssl_browser_tests.cc b/chrome/browser/ssl/ssl_browser_tests.cc
index d8f3a8f5d574adf6e028103b2bcd36c15c9544ea..8c2df7cef945de18984990a39ee0ce579a5b6f0d 100644
--- a/chrome/browser/ssl/ssl_browser_tests.cc
+++ b/chrome/browser/ssl/ssl_browser_tests.cc
@@ -32,9 +32,9 @@
#include "chrome/browser/ssl/cert_report_helper.h"
#include "chrome/browser/ssl/cert_verifier_browser_test.h"
#include "chrome/browser/ssl/certificate_reporting_test_utils.h"
-#include "chrome/browser/ssl/chrome_security_state_model_client.h"
#include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
#include "chrome/browser/ssl/common_name_mismatch_handler.h"
+#include "chrome/browser/ssl/security_state_tab_helper.h"
#include "chrome/browser/ssl/ssl_blocking_page.h"
#include "chrome/browser/ssl/ssl_error_handler.h"
#include "chrome/browser/ui/browser.h"
@@ -54,8 +54,8 @@
#include "components/prefs/pref_service.h"
#include "components/security_interstitials/core/controller_client.h"
#include "components/security_interstitials/core/metrics_helper.h"
-#include "components/security_state/security_state_model.h"
-#include "components/security_state/switches.h"
+#include "components/security_state/core/security_state_model.h"
+#include "components/security_state/core/switches.h"
#include "components/ssl_errors/error_classification.h"
#include "components/variations/variations_associated_data.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
@@ -162,10 +162,9 @@ namespace SecurityStyle {
void Check(
WebContents* tab,
security_state::SecurityStateModel::SecurityLevel expected_security_level) {
- ChromeSecurityStateModelClient* model_client =
- ChromeSecurityStateModelClient::FromWebContents(tab);
+ SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
security_state::SecurityStateModel::SecurityInfo security_info;
- model_client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(expected_security_level, security_info.security_level);
}
@@ -1201,13 +1200,13 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, MarkFileAsNonSecure) {
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(contents);
- ChromeSecurityStateModelClient* model_client =
- ChromeSecurityStateModelClient::FromWebContents(contents);
- ASSERT_TRUE(model_client);
+ SecurityStateTabHelper* helper =
+ SecurityStateTabHelper::FromWebContents(contents);
+ ASSERT_TRUE(helper);
ui_test_utils::NavigateToURL(browser(), GURL("file:///"));
security_state::SecurityStateModel::SecurityInfo security_info;
- model_client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(security_state::SecurityStateModel::NONE,
security_info.security_level);
}
@@ -1221,13 +1220,13 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, MarkAboutAsNonSecure) {
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(contents);
- ChromeSecurityStateModelClient* model_client =
- ChromeSecurityStateModelClient::FromWebContents(contents);
- ASSERT_TRUE(model_client);
+ SecurityStateTabHelper* helper =
+ SecurityStateTabHelper::FromWebContents(contents);
+ ASSERT_TRUE(helper);
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
security_state::SecurityStateModel::SecurityInfo security_info;
- model_client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(security_state::SecurityStateModel::NONE,
security_info.security_level);
}
@@ -1241,13 +1240,13 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, MarkDataAsNonSecure) {
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(contents);
- ChromeSecurityStateModelClient* model_client =
- ChromeSecurityStateModelClient::FromWebContents(contents);
- ASSERT_TRUE(model_client);
+ SecurityStateTabHelper* helper =
+ SecurityStateTabHelper::FromWebContents(contents);
+ ASSERT_TRUE(helper);
ui_test_utils::NavigateToURL(browser(), GURL("data:text/plain,hello"));
security_state::SecurityStateModel::SecurityInfo security_info;
- model_client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(security_state::SecurityStateModel::NONE,
security_info.security_level);
}
@@ -1261,15 +1260,15 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, MarkBlobAsNonSecure) {
browser()->tab_strip_model()->GetActiveWebContents();
ASSERT_TRUE(contents);
- ChromeSecurityStateModelClient* model_client =
- ChromeSecurityStateModelClient::FromWebContents(contents);
- ASSERT_TRUE(model_client);
+ SecurityStateTabHelper* helper =
+ SecurityStateTabHelper::FromWebContents(contents);
+ ASSERT_TRUE(helper);
ui_test_utils::NavigateToURL(
browser(),
GURL("blob:chrome://newtab/49a463bb-fac8-476c-97bf-5d7076c3ea1a"));
security_state::SecurityStateModel::SecurityInfo security_info;
- model_client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(security_state::SecurityStateModel::NONE,
security_info.security_level);
}
@@ -2459,11 +2458,10 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerWithUserException) {
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
AuthState::NONE);
- ChromeSecurityStateModelClient* client =
- ChromeSecurityStateModelClient::FromWebContents(tab);
- ASSERT_TRUE(client);
+ SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
+ ASSERT_TRUE(helper);
security_state::SecurityStateModel::SecurityInfo security_info;
- client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
security_info.mixed_content_status);
EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
@@ -2480,7 +2478,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsInWorkerWithUserException) {
CheckWorkerLoadResult(tab, true); // Worker loads insecure content
CheckAuthenticationBrokenState(tab, CertError::NONE, AuthState::NONE);
- client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
security_info.mixed_content_status);
EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_RAN,
@@ -2495,11 +2493,10 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) {
"/ssl/page_with_unsafe_contents.html"));
CheckAuthenticationBrokenState(tab, CertError::NONE, AuthState::NONE);
- ChromeSecurityStateModelClient* client =
- ChromeSecurityStateModelClient::FromWebContents(tab);
- ASSERT_TRUE(client);
+ SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
+ ASSERT_TRUE(helper);
security_state::SecurityStateModel::SecurityInfo security_info;
- client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
security_info.mixed_content_status);
EXPECT_EQ(
@@ -2534,7 +2531,7 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeContentsWithUserException) {
CheckAuthenticationBrokenState(tab, net::CERT_STATUS_COMMON_NAME_INVALID,
AuthState::NONE);
- client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
security_info.mixed_content_status);
EXPECT_EQ(
@@ -2548,11 +2545,10 @@ IN_PROC_BROWSER_TEST_F(SSLUITest, TestUnsafeImageWithUserException) {
ASSERT_NO_FATAL_FAILURE(
SetUpUnsafeContentsWithUserException("/ssl/page_with_unsafe_image.html"));
- ChromeSecurityStateModelClient* client =
- ChromeSecurityStateModelClient::FromWebContents(tab);
- ASSERT_TRUE(client);
+ SecurityStateTabHelper* helper = SecurityStateTabHelper::FromWebContents(tab);
+ ASSERT_TRUE(helper);
security_state::SecurityStateModel::SecurityInfo security_info;
- client->GetSecurityInfo(&security_info);
+ helper->GetSecurityInfo(&security_info);
EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_NONE,
security_info.mixed_content_status);
EXPECT_EQ(security_state::SecurityStateModel::CONTENT_STATUS_DISPLAYED,

Powered by Google App Engine
This is Rietveld 408576698