| 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 11 matching lines...) Expand all Loading... |
| 22 #include "content/public/browser/render_process_host.h" | 22 #include "content/public/browser/render_process_host.h" |
| 23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 24 #include "content/public/test/web_contents_tester.h" | 24 #include "content/public/test/web_contents_tester.h" |
| 25 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 27 |
| 28 using content::InterstitialPage; | 28 using content::InterstitialPage; |
| 29 using content::NavigationEntry; | 29 using content::NavigationEntry; |
| 30 using content::WebContents; | 30 using content::WebContents; |
| 31 using content::WebContentsTester; | 31 using content::WebContentsTester; |
| 32 using security_interstitials::SafeBrowsingErrorUI; | 32 using security_interstitials::BaseSafeBrowsingErrorUI; |
| 33 | 33 |
| 34 static const char* kGoogleURL = "http://www.google.com/"; | 34 static const char* kGoogleURL = "http://www.google.com/"; |
| 35 static const char* kGoodURL = "http://www.goodguys.com/"; | 35 static const char* kGoodURL = "http://www.goodguys.com/"; |
| 36 static const char* kBadURL = "http://www.badguys.com/"; | 36 static const char* kBadURL = "http://www.badguys.com/"; |
| 37 static const char* kBadURL2 = "http://www.badguys2.com/"; | 37 static const char* kBadURL2 = "http://www.badguys2.com/"; |
| 38 static const char* kBadURL3 = "http://www.badguys3.com/"; | 38 static const char* kBadURL3 = "http://www.badguys3.com/"; |
| 39 | 39 |
| 40 namespace safe_browsing { | 40 namespace safe_browsing { |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 // A SafeBrowingBlockingPage class that does not create windows. | 44 // A SafeBrowingBlockingPage class that does not create windows. |
| 45 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { | 45 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { |
| 46 public: | 46 public: |
| 47 TestSafeBrowsingBlockingPage( | 47 TestSafeBrowsingBlockingPage( |
| 48 BaseUIManager* manager, | 48 BaseUIManager* manager, |
| 49 WebContents* web_contents, | 49 WebContents* web_contents, |
| 50 const GURL& main_frame_url, | 50 const GURL& main_frame_url, |
| 51 const UnsafeResourceList& unsafe_resources, | 51 const UnsafeResourceList& unsafe_resources, |
| 52 const SafeBrowsingErrorUI::SBErrorDisplayOptions& display_options) | 52 const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options) |
| 53 : SafeBrowsingBlockingPage(manager, | 53 : SafeBrowsingBlockingPage(manager, |
| 54 web_contents, | 54 web_contents, |
| 55 main_frame_url, | 55 main_frame_url, |
| 56 unsafe_resources, | 56 unsafe_resources, |
| 57 display_options) { | 57 display_options) { |
| 58 // Don't delay details at all for the unittest. | 58 // Don't delay details at all for the unittest. |
| 59 SetThreatDetailsProceedDelayForTesting(0); | 59 SetThreatDetailsProceedDelayForTesting(0); |
| 60 DontCreateViewForTesting(); | 60 DontCreateViewForTesting(); |
| 61 } | 61 } |
| 62 }; | 62 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 73 const GURL& main_frame_url, | 73 const GURL& main_frame_url, |
| 74 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 74 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| 75 override { | 75 override { |
| 76 PrefService* prefs = | 76 PrefService* prefs = |
| 77 Profile::FromBrowserContext(web_contents->GetBrowserContext()) | 77 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
| 78 ->GetPrefs(); | 78 ->GetPrefs(); |
| 79 bool is_extended_reporting_opt_in_allowed = | 79 bool is_extended_reporting_opt_in_allowed = |
| 80 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed); | 80 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed); |
| 81 bool is_proceed_anyway_disabled = | 81 bool is_proceed_anyway_disabled = |
| 82 prefs->GetBoolean(prefs::kSafeBrowsingProceedAnywayDisabled); | 82 prefs->GetBoolean(prefs::kSafeBrowsingProceedAnywayDisabled); |
| 83 SafeBrowsingErrorUI::SBErrorDisplayOptions display_options( | 83 BaseSafeBrowsingErrorUI::SBErrorDisplayOptions display_options( |
| 84 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources), | 84 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources), |
| 85 is_extended_reporting_opt_in_allowed, | 85 is_extended_reporting_opt_in_allowed, |
| 86 web_contents->GetBrowserContext()->IsOffTheRecord(), | 86 web_contents->GetBrowserContext()->IsOffTheRecord(), |
| 87 IsExtendedReportingEnabled(*prefs), IsScout(*prefs), | 87 IsExtendedReportingEnabled(*prefs), IsScout(*prefs), |
| 88 is_proceed_anyway_disabled, | 88 is_proceed_anyway_disabled, |
| 89 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources)); | 89 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources)); |
| 90 return new TestSafeBrowsingBlockingPage(manager, web_contents, | 90 return new TestSafeBrowsingBlockingPage(manager, web_contents, |
| 91 main_frame_url, unsafe_resources, | 91 main_frame_url, unsafe_resources, |
| 92 display_options); | 92 display_options); |
| 93 } | 93 } |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 // The interstitial should be gone. | 789 // The interstitial should be gone. |
| 790 EXPECT_EQ(CANCEL, user_response()); | 790 EXPECT_EQ(CANCEL, user_response()); |
| 791 EXPECT_FALSE(GetSafeBrowsingBlockingPage()); | 791 EXPECT_FALSE(GetSafeBrowsingBlockingPage()); |
| 792 | 792 |
| 793 // No report should have been sent. | 793 // No report should have been sent. |
| 794 EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size()); | 794 EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size()); |
| 795 ui_manager_->GetThreatDetails()->clear(); | 795 ui_manager_->GetThreatDetails()->clear(); |
| 796 } | 796 } |
| 797 | 797 |
| 798 } // namespace safe_browsing | 798 } // namespace safe_browsing |
| OLD | NEW |