| 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 12 matching lines...) Expand all Loading... |
| 23 #include "chrome/browser/safe_browsing/malware_details.h" | 23 #include "chrome/browser/safe_browsing/malware_details.h" |
| 24 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 24 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 25 #include "chrome/browser/tab_contents/tab_util.h" | 25 #include "chrome/browser/tab_contents/tab_util.h" |
| 26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 27 #include "chrome/common/jstemplate_builder.h" | 27 #include "chrome/common/jstemplate_builder.h" |
| 28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 30 #include "content/browser/tab_contents/navigation_controller.h" | 30 #include "content/browser/tab_contents/navigation_controller.h" |
| 31 #include "content/browser/tab_contents/navigation_entry.h" | 31 #include "content/browser/tab_contents/navigation_entry.h" |
| 32 #include "content/browser/tab_contents/tab_contents.h" | 32 #include "content/browser/tab_contents/tab_contents.h" |
| 33 #include "content/browser/user_metrics.h" | |
| 34 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/user_metrics.h" |
| 35 #include "grit/browser_resources.h" | 35 #include "grit/browser_resources.h" |
| 36 #include "grit/generated_resources.h" | 36 #include "grit/generated_resources.h" |
| 37 #include "grit/locale_settings.h" | 37 #include "grit/locale_settings.h" |
| 38 #include "net/base/escape.h" | 38 #include "net/base/escape.h" |
| 39 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
| 40 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
| 41 | 41 |
| 42 using content::BrowserThread; | 42 using content::BrowserThread; |
| 43 using content::UserMetricsAction; |
| 43 | 44 |
| 44 // For malware interstitial pages, we link the problematic URL to Google's | 45 // For malware interstitial pages, we link the problematic URL to Google's |
| 45 // diagnostic page. | 46 // diagnostic page. |
| 46 #if defined(GOOGLE_CHROME_BUILD) | 47 #if defined(GOOGLE_CHROME_BUILD) |
| 47 static const char* const kSbDiagnosticUrl = | 48 static const char* const kSbDiagnosticUrl = |
| 48 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie
nt=googlechrome"; | 49 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie
nt=googlechrome"; |
| 49 #else | 50 #else |
| 50 static const char* const kSbDiagnosticUrl = | 51 static const char* const kSbDiagnosticUrl = |
| 51 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie
nt=chromium"; | 52 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie
nt=chromium"; |
| 52 #endif | 53 #endif |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 case PROCEED: | 620 case PROCEED: |
| 620 action.append("Proceed"); | 621 action.append("Proceed"); |
| 621 break; | 622 break; |
| 622 case DONT_PROCEED: | 623 case DONT_PROCEED: |
| 623 action.append("DontProceed"); | 624 action.append("DontProceed"); |
| 624 break; | 625 break; |
| 625 default: | 626 default: |
| 626 NOTREACHED() << "Unexpected event: " << event; | 627 NOTREACHED() << "Unexpected event: " << event; |
| 627 } | 628 } |
| 628 | 629 |
| 629 UserMetrics::RecordComputedAction(action); | 630 content::RecordComputedAction(action); |
| 630 } | 631 } |
| 631 | 632 |
| 632 void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) { | 633 void SafeBrowsingBlockingPage::FinishMalwareDetails(int64 delay_ms) { |
| 633 if (malware_details_ == NULL) | 634 if (malware_details_ == NULL) |
| 634 return; // Not all interstitials have malware details (eg phishing). | 635 return; // Not all interstitials have malware details (eg phishing). |
| 635 | 636 |
| 636 Profile* profile = Profile::FromBrowserContext(tab()->browser_context()); | 637 Profile* profile = Profile::FromBrowserContext(tab()->browser_context()); |
| 637 const PrefService::Preference* pref = | 638 const PrefService::Preference* pref = |
| 638 profile->GetPrefs()->FindPreference(prefs::kSafeBrowsingReportingEnabled); | 639 profile->GetPrefs()->FindPreference(prefs::kSafeBrowsingReportingEnabled); |
| 639 | 640 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 // Client-side phishing detection interstitials never block the main frame | 708 // Client-side phishing detection interstitials never block the main frame |
| 708 // load, since they happen after the page is finished loading. | 709 // load, since they happen after the page is finished loading. |
| 709 if (unsafe_resources[0].threat_type == | 710 if (unsafe_resources[0].threat_type == |
| 710 SafeBrowsingService::CLIENT_SIDE_PHISHING_URL) { | 711 SafeBrowsingService::CLIENT_SIDE_PHISHING_URL) { |
| 711 return false; | 712 return false; |
| 712 } | 713 } |
| 713 | 714 |
| 714 // Otherwise, check the threat type. | 715 // Otherwise, check the threat type. |
| 715 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; | 716 return unsafe_resources.size() == 1 && !unsafe_resources[0].is_subresource; |
| 716 } | 717 } |
| OLD | NEW |