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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 2448943002: Refactor SecurityStateModel/Clients for simplicity and reusability. (Closed)
Patch Set: Remove *SecurityModelClient. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This test creates a fake safebrowsing service, where we can inject known- 5 // This test creates a fake safebrowsing service, where we can inject known-
6 // threat urls. It then uses a real browser to go to these urls, and sends 6 // threat urls. It then uses a real browser to go to these urls, and sends
7 // "goback" or "proceed" commands and verifies they work. 7 // "goback" or "proceed" commands and verifies they work.
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/test/histogram_tester.h" 16 #include "base/test/histogram_tester.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
20 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h" 20 #include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
21 #include "chrome/browser/net/url_request_mock_util.h" 21 #include "chrome/browser/net/url_request_mock_util.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/safe_browsing/local_database_manager.h" 23 #include "chrome/browser/safe_browsing/local_database_manager.h"
24 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" 24 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h"
25 #include "chrome/browser/safe_browsing/test_safe_browsing_service.h" 25 #include "chrome/browser/safe_browsing/test_safe_browsing_service.h"
26 #include "chrome/browser/safe_browsing/threat_details.h" 26 #include "chrome/browser/safe_browsing/threat_details.h"
27 #include "chrome/browser/safe_browsing/ui_manager.h" 27 #include "chrome/browser/safe_browsing/ui_manager.h"
28 #include "chrome/browser/ssl/cert_verifier_browser_test.h" 28 #include "chrome/browser/ssl/cert_verifier_browser_test.h"
29 #include "chrome/browser/ssl/chrome_security_state_model_client.h" 29 #include "chrome/browser/ssl/chrome_security_state_model.h"
30 #include "chrome/browser/ssl/ssl_blocking_page.h" 30 #include "chrome/browser/ssl/ssl_blocking_page.h"
31 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_tabstrip.h" 32 #include "chrome/browser/ui/browser_tabstrip.h"
33 #include "chrome/browser/ui/tabs/tab_strip_model.h" 33 #include "chrome/browser/ui/tabs/tab_strip_model.h"
34 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
35 #include "chrome/common/url_constants.h" 35 #include "chrome/common/url_constants.h"
36 #include "chrome/test/base/in_process_browser_test.h" 36 #include "chrome/test/base/in_process_browser_test.h"
37 #include "chrome/test/base/ui_test_utils.h" 37 #include "chrome/test/base/ui_test_utils.h"
38 #include "components/prefs/pref_service.h" 38 #include "components/prefs/pref_service.h"
39 #include "components/safe_browsing_db/database_manager.h" 39 #include "components/safe_browsing_db/database_manager.h"
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 EXPECT_EQ(expected_parent, resource.url()); 562 EXPECT_EQ(expected_parent, resource.url());
563 break; 563 break;
564 } 564 }
565 } 565 }
566 EXPECT_EQ(expected_child_size, actual_resource.child_ids_size()); 566 EXPECT_EQ(expected_child_size, actual_resource.child_ids_size());
567 EXPECT_EQ(expected_tag_name, actual_resource.tag_name()); 567 EXPECT_EQ(expected_tag_name, actual_resource.tag_name());
568 } 568 }
569 569
570 void ExpectSecurityIndicatorDowngrade(content::WebContents* tab, 570 void ExpectSecurityIndicatorDowngrade(content::WebContents* tab,
571 net::CertStatus cert_status) { 571 net::CertStatus cert_status) {
572 ChromeSecurityStateModelClient* model_client = 572 ChromeSecurityStateModel* model =
573 ChromeSecurityStateModelClient::FromWebContents(tab); 573 ChromeSecurityStateModel::FromWebContents(tab);
574 ASSERT_TRUE(model_client); 574 ASSERT_TRUE(model);
575 security_state::SecurityStateModel::SecurityInfo security_info; 575 security_state::SecurityStateModel::SecurityInfo security_info;
576 model_client->GetSecurityInfo(&security_info); 576 model->GetSecurityInfo(&security_info);
577 EXPECT_EQ(security_state::SecurityStateModel::DANGEROUS, 577 EXPECT_EQ(security_state::SecurityStateModel::DANGEROUS,
578 security_info.security_level); 578 security_info.security_level);
579 EXPECT_TRUE(security_info.fails_malware_check); 579 EXPECT_TRUE(security_info.fails_malware_check);
580 // TODO(felt): Restore this check when https://crbug.com/641187 is fixed. 580 // TODO(felt): Restore this check when https://crbug.com/641187 is fixed.
581 // EXPECT_EQ(cert_status, model_client->GetSecurityInfo().cert_status); 581 // EXPECT_EQ(cert_status, model_client->GetSecurityInfo().cert_status);
582 } 582 }
583 583
584 protected: 584 protected:
585 TestThreatDetailsFactory details_factory_; 585 TestThreatDetailsFactory details_factory_;
586 586
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 1151
1152 INSTANTIATE_TEST_CASE_P( 1152 INSTANTIATE_TEST_CASE_P(
1153 SafeBrowsingBlockingPageIDNTestWithThreatType, 1153 SafeBrowsingBlockingPageIDNTestWithThreatType,
1154 SafeBrowsingBlockingPageIDNTest, 1154 SafeBrowsingBlockingPageIDNTest,
1155 testing::Combine(testing::Values(false, true), 1155 testing::Combine(testing::Values(false, true),
1156 testing::Values(SB_THREAT_TYPE_URL_MALWARE, 1156 testing::Values(SB_THREAT_TYPE_URL_MALWARE,
1157 SB_THREAT_TYPE_URL_PHISHING, 1157 SB_THREAT_TYPE_URL_PHISHING,
1158 SB_THREAT_TYPE_URL_UNWANTED))); 1158 SB_THREAT_TYPE_URL_UNWANTED)));
1159 1159
1160 } // namespace safe_browsing 1160 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698