| 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 using security_interstitials::BaseSafeBrowsingErrorUI; |
| 32 | 32 |
| 33 static const char* kGoogleURL = "http://www.google.com/"; | 33 static const char* kGoogleURL = "http://www.google.com/"; |
| 34 static const char* kGoodURL = "http://www.goodguys.com/"; | 34 static const char* kGoodURL = "http://www.goodguys.com/"; |
| 35 static const char* kBadURL = "http://www.badguys.com/"; | 35 static const char* kBadURL = "http://www.badguys.com/"; |
| 36 static const char* kBadURL2 = "http://www.badguys2.com/"; | 36 static const char* kBadURL2 = "http://www.badguys2.com/"; |
| 37 static const char* kBadURL3 = "http://www.badguys3.com/"; | 37 static const char* kBadURL3 = "http://www.badguys3.com/"; |
| 38 | 38 |
| 39 namespace safe_browsing { | 39 namespace safe_browsing { |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 // A SafeBrowingBlockingPage class that does not create windows. | 43 // A SafeBrowingBlockingPage class that does not create windows. |
| 44 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { | 44 class TestSafeBrowsingBlockingPage : public SafeBrowsingBlockingPage { |
| 45 public: | 45 public: |
| 46 TestSafeBrowsingBlockingPage( | 46 TestSafeBrowsingBlockingPage( |
| 47 BaseUIManager* manager, | 47 BaseUIManager* manager, |
| 48 WebContents* web_contents, | 48 WebContents* web_contents, |
| 49 const GURL& main_frame_url, | 49 const GURL& main_frame_url, |
| 50 const UnsafeResourceList& unsafe_resources, | 50 const UnsafeResourceList& unsafe_resources, |
| 51 const SafeBrowsingErrorUI::SBErrorDisplayOptions& display_options) | 51 const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options) |
| 52 : SafeBrowsingBlockingPage(manager, | 52 : SafeBrowsingBlockingPage(manager, |
| 53 web_contents, | 53 web_contents, |
| 54 main_frame_url, | 54 main_frame_url, |
| 55 unsafe_resources, | 55 unsafe_resources, |
| 56 display_options) { | 56 display_options) { |
| 57 // Don't delay details at all for the unittest. | 57 // Don't delay details at all for the unittest. |
| 58 SetThreatDetailsProceedDelayForTesting(0); | 58 SetThreatDetailsProceedDelayForTesting(0); |
| 59 DontCreateViewForTesting(); | 59 DontCreateViewForTesting(); |
| 60 } | 60 } |
| 61 }; | 61 }; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 72 const GURL& main_frame_url, | 72 const GURL& main_frame_url, |
| 73 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) | 73 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) |
| 74 override { | 74 override { |
| 75 PrefService* prefs = | 75 PrefService* prefs = |
| 76 Profile::FromBrowserContext(web_contents->GetBrowserContext()) | 76 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
| 77 ->GetPrefs(); | 77 ->GetPrefs(); |
| 78 bool is_extended_reporting_opt_in_allowed = | 78 bool is_extended_reporting_opt_in_allowed = |
| 79 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed); | 79 prefs->GetBoolean(prefs::kSafeBrowsingExtendedReportingOptInAllowed); |
| 80 bool is_proceed_anyway_disabled = | 80 bool is_proceed_anyway_disabled = |
| 81 prefs->GetBoolean(prefs::kSafeBrowsingProceedAnywayDisabled); | 81 prefs->GetBoolean(prefs::kSafeBrowsingProceedAnywayDisabled); |
| 82 SafeBrowsingErrorUI::SBErrorDisplayOptions display_options( | 82 BaseSafeBrowsingErrorUI::SBErrorDisplayOptions display_options( |
| 83 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources), | 83 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources), |
| 84 is_extended_reporting_opt_in_allowed, | 84 is_extended_reporting_opt_in_allowed, |
| 85 web_contents->GetBrowserContext()->IsOffTheRecord(), | 85 web_contents->GetBrowserContext()->IsOffTheRecord(), |
| 86 IsExtendedReportingEnabled(*prefs), IsScout(*prefs), | 86 IsExtendedReportingEnabled(*prefs), IsScout(*prefs), |
| 87 is_proceed_anyway_disabled, | 87 is_proceed_anyway_disabled, |
| 88 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources)); | 88 BaseBlockingPage::IsMainPageLoadBlocked(unsafe_resources)); |
| 89 return new TestSafeBrowsingBlockingPage(manager, web_contents, | 89 return new TestSafeBrowsingBlockingPage(manager, web_contents, |
| 90 main_frame_url, unsafe_resources, | 90 main_frame_url, unsafe_resources, |
| 91 display_options); | 91 display_options); |
| 92 } | 92 } |
| (...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 // The interstitial should be gone. | 772 // The interstitial should be gone. |
| 773 EXPECT_EQ(CANCEL, user_response()); | 773 EXPECT_EQ(CANCEL, user_response()); |
| 774 EXPECT_FALSE(GetSafeBrowsingBlockingPage()); | 774 EXPECT_FALSE(GetSafeBrowsingBlockingPage()); |
| 775 | 775 |
| 776 // No report should have been sent. | 776 // No report should have been sent. |
| 777 EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size()); | 777 EXPECT_EQ(0u, ui_manager_->GetThreatDetails()->size()); |
| 778 ui_manager_->GetThreatDetails()->clear(); | 778 ui_manager_->GetThreatDetails()->clear(); |
| 779 } | 779 } |
| 780 | 780 |
| 781 } // namespace safe_browsing | 781 } // namespace safe_browsing |
| OLD | NEW |