| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Implementation of the SafeBrowsingBlockingPage class. | 5 // Implementation of the SafeBrowsingBlockingPage class. |
| 6 | 6 |
| 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 static const char* const kTakeMeBackCommand = "takeMeBack"; | 95 static const char* const kTakeMeBackCommand = "takeMeBack"; |
| 96 static const char* const kDoReportCommand = "doReport"; | 96 static const char* const kDoReportCommand = "doReport"; |
| 97 static const char* const kDontReportCommand = "dontReport"; | 97 static const char* const kDontReportCommand = "dontReport"; |
| 98 static const char* const kDisplayCheckBox = "displaycheckbox"; | 98 static const char* const kDisplayCheckBox = "displaycheckbox"; |
| 99 static const char* const kBoxChecked = "boxchecked"; | 99 static const char* const kBoxChecked = "boxchecked"; |
| 100 | 100 |
| 101 // static | 101 // static |
| 102 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; | 102 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
| 103 | 103 |
| 104 static base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> | 104 static base::LazyInstance<SafeBrowsingBlockingPage::UnsafeResourceMap> |
| 105 g_unsafe_resource_map(base::LINKER_INITIALIZED); | 105 g_unsafe_resource_map = LAZY_INSTANCE_INITIALIZER; |
| 106 | 106 |
| 107 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we | 107 // The default SafeBrowsingBlockingPageFactory. Global, made a singleton so we |
| 108 // don't leak it. | 108 // don't leak it. |
| 109 class SafeBrowsingBlockingPageFactoryImpl | 109 class SafeBrowsingBlockingPageFactoryImpl |
| 110 : public SafeBrowsingBlockingPageFactory { | 110 : public SafeBrowsingBlockingPageFactory { |
| 111 public: | 111 public: |
| 112 SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 112 SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 113 SafeBrowsingService* service, | 113 SafeBrowsingService* service, |
| 114 TabContents* tab_contents, | 114 TabContents* tab_contents, |
| 115 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) { | 115 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) { |
| 116 return new SafeBrowsingBlockingPage(service, tab_contents, | 116 return new SafeBrowsingBlockingPage(service, tab_contents, |
| 117 unsafe_resources); | 117 unsafe_resources); |
| 118 } | 118 } |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 friend struct base::DefaultLazyInstanceTraits< | 121 friend struct base::DefaultLazyInstanceTraits< |
| 122 SafeBrowsingBlockingPageFactoryImpl>; | 122 SafeBrowsingBlockingPageFactoryImpl>; |
| 123 | 123 |
| 124 SafeBrowsingBlockingPageFactoryImpl() { } | 124 SafeBrowsingBlockingPageFactoryImpl() { } |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageFactoryImpl); | 126 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageFactoryImpl); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 static base::LazyInstance<SafeBrowsingBlockingPageFactoryImpl> | 129 static base::LazyInstance<SafeBrowsingBlockingPageFactoryImpl> |
| 130 g_safe_browsing_blocking_page_factory_impl(base::LINKER_INITIALIZED); | 130 g_safe_browsing_blocking_page_factory_impl = LAZY_INSTANCE_INITIALIZER; |
| 131 | 131 |
| 132 SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( | 132 SafeBrowsingBlockingPage::SafeBrowsingBlockingPage( |
| 133 SafeBrowsingService* sb_service, | 133 SafeBrowsingService* sb_service, |
| 134 TabContents* tab_contents, | 134 TabContents* tab_contents, |
| 135 const UnsafeResourceList& unsafe_resources) | 135 const UnsafeResourceList& unsafe_resources) |
| 136 : ChromeInterstitialPage(tab_contents, | 136 : ChromeInterstitialPage(tab_contents, |
| 137 IsMainPageLoadBlocked(unsafe_resources), | 137 IsMainPageLoadBlocked(unsafe_resources), |
| 138 unsafe_resources[0].url), | 138 unsafe_resources[0].url), |
| 139 malware_details_proceed_delay_ms_( | 139 malware_details_proceed_delay_ms_( |
| 140 kMalwareDetailsProceedDelayMilliSeconds), | 140 kMalwareDetailsProceedDelayMilliSeconds), |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 // Client-side phishing detection interstitials never block the main frame | 707 // Client-side phishing detection interstitials never block the main frame |
| 708 // load, since they happen after the page is finished loading. | 708 // load, since they happen after the page is finished loading. |
| 709 if (unsafe_resources[0].threat_type == | 709 if (unsafe_resources[0].threat_type == |
| 710 SafeBrowsingService::CLIENT_SIDE_PHISHING_URL) { | 710 SafeBrowsingService::CLIENT_SIDE_PHISHING_URL) { |
| 711 return false; | 711 return false; |
| 712 } | 712 } |
| 713 | 713 |
| 714 // Otherwise, check the threat type. | 714 // Otherwise, check the threat type. |
| 715 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; | 715 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; |
| 716 } | 716 } |
| OLD | NEW |