OLD | NEW |
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 #include <list> | 5 #include <list> |
6 | 6 |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/interstitials/chrome_controller_client.h" | 8 #include "chrome/browser/interstitials/chrome_controller_client.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 10 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "content/public/test/web_contents_tester.h" | 23 #include "content/public/test/web_contents_tester.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
26 | 26 |
27 using content::InterstitialPage; | 27 using content::InterstitialPage; |
28 using content::NavigationEntry; | 28 using content::NavigationEntry; |
29 using content::WebContents; | 29 using content::WebContents; |
30 using content::WebContentsTester; | 30 using content::WebContentsTester; |
| 31 using security_interstitials::SafeBrowsingErrorUI; |
31 | 32 |
32 static const char* kGoogleURL = "http://www.google.com/"; | 33 static const char* kGoogleURL = "http://www.google.com/"; |
33 static const char* kGoodURL = "http://www.goodguys.com/"; | 34 static const char* kGoodURL = "http://www.goodguys.com/"; |
34 static const char* kBadURL = "http://www.badguys.com/"; | 35 static const char* kBadURL = "http://www.badguys.com/"; |
35 static const char* kBadURL2 = "http://www.badguys2.com/"; | 36 static const char* kBadURL2 = "http://www.badguys2.com/"; |
36 static const char* kBadURL3 = "http://www.badguys3.com/"; | 37 static const char* kBadURL3 = "http://www.badguys3.com/"; |
37 | 38 |
38 namespace safe_browsing { | 39 namespace safe_browsing { |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 // A SafeBrowingBlockingPage class that does not create windows. | 43 // A SafeBrowingBlockingPage class that does not create windows. |
43 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { | 44 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { |
44 public: | 45 public: |
45 TestSafeBrowsingBlockingPage(SafeBrowsingUIManager* manager, | 46 TestSafeBrowsingBlockingPage( |
46 WebContents* web_contents, | 47 BaseUIManager* manager, |
47 const GURL& main_frame_url, | 48 WebContents* web_contents, |
48 const UnsafeResourceList& unsafe_resources) | 49 const GURL& main_frame_url, |
| 50 const UnsafeResourceList& unsafe_resources, |
| 51 SafeBrowsingErrorUI::SBErrorDisplayOptions* display_options) |
49 : SafeBrowsingBlockingPage(manager, | 52 : SafeBrowsingBlockingPage(manager, |
50 web_contents, | 53 web_contents, |
51 main_frame_url, | 54 main_frame_url, |
52 unsafe_resources) { | 55 unsafe_resources, |
| 56 display_options) { |
53 // Don't delay details at all for the unittest. | 57 // Don't delay details at all for the unittest. |
54 threat_details_proceed_delay_ms_ = 0; | 58 threat_details_proceed_delay_ms_ = 0; |
55 DontCreateViewForTesting(); | 59 DontCreateViewForTesting(); |
56 } | 60 } |
57 }; | 61 }; |
58 | 62 |
59 class TestSafeBrowsingBlockingPageFactory | 63 class TestSafeBrowsingBlockingPageFactory |
60 : public SafeBrowsingBlockingPageFactory { | 64 : public SafeBrowsingBlockingPageFactory { |
61 public: | 65 public: |
62 TestSafeBrowsingBlockingPageFactory() { } | 66 TestSafeBrowsingBlockingPageFactory() { } |
63 ~TestSafeBrowsingBlockingPageFactory() override {} | 67 ~TestSafeBrowsingBlockingPageFactory() override {} |
64 | 68 |
65 SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 69 SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
66 SafeBrowsingUIManager* manager, | 70 BaseUIManager* manager, |
67 WebContents* web_contents, | 71 WebContents* web_contents, |
68 const GURL& main_frame_url, | 72 const GURL& main_frame_url, |
69 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 73 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
70 override { | 74 override { |
| 75 PrefService* prefs = |
| 76 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
| 77 ->GetPrefs(); |
| 78 bool is_extended_reporting_opt_in_allowed = |
| 79 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed); |
| 80 bool is_proceed_anyway_disabled = |
| 81 prefs->GetBoolean(prefs::kSafeBrowsingProceedAnywayDisabled); |
| 82 SafeBrowsingErrorUI::SBErrorDisplayOptions display_options( |
| 83 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources), |
| 84 is_extended_reporting_opt_in_allowed, |
| 85 web_contents->GetBrowserContext()->IsOffTheRecord(), |
| 86 IsExtendedReportingEnabled(*prefs), IsScout(*prefs), |
| 87 is_proceed_anyway_disabled); |
71 return new TestSafeBrowsingBlockingPage(manager, web_contents, | 88 return new TestSafeBrowsingBlockingPage(manager, web_contents, |
72 main_frame_url, unsafe_resources); | 89 main_frame_url, unsafe_resources, |
| 90 &display_options); |
73 } | 91 } |
74 }; | 92 }; |
75 | 93 |
76 class MockTestingProfile : public TestingProfile { | 94 class MockTestingProfile : public TestingProfile { |
77 public: | 95 public: |
78 MockTestingProfile() {} | 96 MockTestingProfile() {} |
79 virtual ~MockTestingProfile() {} | 97 virtual ~MockTestingProfile() {} |
80 | 98 |
81 MOCK_CONST_METHOD0(IsOffTheRecord, bool()); | 99 MOCK_CONST_METHOD0(IsOffTheRecord, bool()); |
82 }; | 100 }; |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 // The interstitial should be gone. | 769 // The interstitial should be gone. |
752 EXPECT_EQ(CANCEL, user_response()); | 770 EXPECT_EQ(CANCEL, user_response()); |
753 EXPECT_FALSE(GetSafeBrowsingBlockingPage()); | 771 EXPECT_FALSE(GetSafeBrowsingBlockingPage()); |
754 | 772 |
755 // No report should have been sent. | 773 // No report should have been sent. |
756 EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size()); | 774 EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size()); |
757 ui_manager_->GetThreatDetails()->clear(); | 775 ui_manager_->GetThreatDetails()->clear(); |
758 } | 776 } |
759 | 777 |
760 } // namespace safe_browsing | 778 } // namespace safe_browsing |
OLD | NEW |