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 // 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // For malware interstitial pages, we link the problematic URL to Google's | 66 // For malware interstitial pages, we link the problematic URL to Google's |
67 // diagnostic page. | 67 // diagnostic page. |
68 #if defined(GOOGLE_CHROME_BUILD) | 68 #if defined(GOOGLE_CHROME_BUILD) |
69 const char* const kSbDiagnosticUrl = | 69 const char* const kSbDiagnosticUrl = |
70 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie
nt=googlechrome"; | 70 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie
nt=googlechrome"; |
71 #else | 71 #else |
72 const char* const kSbDiagnosticUrl = | 72 const char* const kSbDiagnosticUrl = |
73 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie
nt=chromium"; | 73 "http://safebrowsing.clients.google.com/safebrowsing/diagnostic?site=%s&clie
nt=chromium"; |
74 #endif | 74 #endif |
75 | 75 |
76 const char kSbReportPhishingErrorUrl[] = | |
77 "http://www.google.com/safebrowsing/report_error/"; | |
78 | |
79 // URL for malware and phishing, V2. | 76 // URL for malware and phishing, V2. |
80 const char kLearnMoreMalwareUrlV2[] = | 77 const char kLearnMoreMalwareUrlV2[] = |
81 "https://www.google.com/transparencyreport/safebrowsing/"; | 78 "https://www.google.com/transparencyreport/safebrowsing/"; |
82 const char kLearnMorePhishingUrlV2[] = | 79 const char kLearnMorePhishingUrlV2[] = |
83 "https://www.google.com/transparencyreport/safebrowsing/"; | 80 "https://www.google.com/transparencyreport/safebrowsing/"; |
84 | 81 |
85 const char kPrivacyLinkHtml[] = | 82 const char kPrivacyLinkHtml[] = |
86 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand('showPrivacy'); " | 83 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand('showPrivacy'); " |
87 "return false;\" onmousedown=\"return false;\">%s</a>"; | 84 "return false;\" onmousedown=\"return false;\">%s</a>"; |
88 | 85 |
89 // After a malware interstitial where the user opted-in to the report | 86 // After a malware interstitial where the user opted-in to the report |
90 // but clicked "proceed anyway", we delay the call to | 87 // but clicked "proceed anyway", we delay the call to |
91 // MalwareDetails::FinishCollection() by this much time (in | 88 // MalwareDetails::FinishCollection() by this much time (in |
92 // milliseconds). | 89 // milliseconds). |
93 const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000; | 90 const int64 kMalwareDetailsProceedDelayMilliSeconds = 3000; |
94 | 91 |
95 // The commands returned by the page when the user performs an action. | 92 // The commands returned by the page when the user performs an action. |
96 const char kDoReportCommand[] = "doReport"; | 93 const char kDoReportCommand[] = "doReport"; |
97 const char kDontReportCommand[] = "dontReport"; | 94 const char kDontReportCommand[] = "dontReport"; |
98 const char kExpandedSeeMoreCommand[] = "expandedSeeMore"; | 95 const char kExpandedSeeMoreCommand[] = "expandedSeeMore"; |
99 const char kLearnMoreCommand[] = "learnMore2"; | 96 const char kLearnMoreCommand[] = "learnMore2"; |
100 const char kProceedCommand[] = "proceed"; | 97 const char kProceedCommand[] = "proceed"; |
101 const char kReportErrorCommand[] = "reportError"; | |
102 const char kShowDiagnosticCommand[] = "showDiagnostic"; | 98 const char kShowDiagnosticCommand[] = "showDiagnostic"; |
103 const char kShowPrivacyCommand[] = "showPrivacy"; | 99 const char kShowPrivacyCommand[] = "showPrivacy"; |
104 const char kTakeMeBackCommand[] = "takeMeBack"; | 100 const char kTakeMeBackCommand[] = "takeMeBack"; |
105 // Special command that we use when the user navigated away from the | 101 // Special command that we use when the user navigated away from the |
106 // page. E.g., closed the tab or the window. This is only used by | 102 // page. E.g., closed the tab or the window. This is only used by |
107 // RecordUserReactionTime. | 103 // RecordUserReactionTime. |
108 const char kNavigatedAwayMetaCommand[] = "closed"; | 104 const char kNavigatedAwayMetaCommand[] = "closed"; |
109 | 105 |
110 // Other constants used to communicate with the JavaScript. | 106 // Other constants used to communicate with the JavaScript. |
111 const char kBoxChecked[] = "boxchecked"; | 107 const char kBoxChecked[] = "boxchecked"; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 if (result) | 378 if (result) |
383 element_index = static_cast<size_t>(result_int); | 379 element_index = static_cast<size_t>(result_int); |
384 } | 380 } |
385 | 381 |
386 if (element_index >= unsafe_resources_.size()) { | 382 if (element_index >= unsafe_resources_.size()) { |
387 NOTREACHED(); | 383 NOTREACHED(); |
388 return; | 384 return; |
389 } | 385 } |
390 | 386 |
391 std::string bad_url_spec = unsafe_resources_[element_index].url.spec(); | 387 std::string bad_url_spec = unsafe_resources_[element_index].url.spec(); |
392 if (command == kReportErrorCommand) { | |
393 // User pressed "Report error" for a phishing site. | |
394 // Note that we cannot just put a link in the interstitial at this point. | |
395 // It is not OK to navigate in the context of an interstitial page. | |
396 SBThreatType threat_type = unsafe_resources_[element_index].threat_type; | |
397 DCHECK(threat_type == SB_THREAT_TYPE_URL_PHISHING || | |
398 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); | |
399 GURL report_url = | |
400 safe_browsing_util::GeneratePhishingReportUrl( | |
401 kSbReportPhishingErrorUrl, | |
402 bad_url_spec, | |
403 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL); | |
404 OpenURLParams params( | |
405 report_url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, | |
406 false); | |
407 web_contents_->OpenURL(params); | |
408 return; | |
409 } | |
410 | |
411 if (command == kShowDiagnosticCommand) { | 388 if (command == kShowDiagnosticCommand) { |
412 // We're going to take the user to Google's SafeBrowsing diagnostic page. | 389 // We're going to take the user to Google's SafeBrowsing diagnostic page. |
413 std::string diagnostic = | 390 std::string diagnostic = |
414 base::StringPrintf(kSbDiagnosticUrl, | 391 base::StringPrintf(kSbDiagnosticUrl, |
415 net::EscapeQueryParamValue(bad_url_spec, true).c_str()); | 392 net::EscapeQueryParamValue(bad_url_spec, true).c_str()); |
416 GURL diagnostic_url(diagnostic); | 393 GURL diagnostic_url(diagnostic); |
417 diagnostic_url = google_util::AppendGoogleLocaleParam( | 394 diagnostic_url = google_util::AppendGoogleLocaleParam( |
418 diagnostic_url, g_browser_process->GetApplicationLocale()); | 395 diagnostic_url, g_browser_process->GetApplicationLocale()); |
419 DCHECK(unsafe_resources_[element_index].threat_type == | 396 DCHECK(unsafe_resources_[element_index].threat_type == |
420 SB_THREAT_TYPE_URL_MALWARE || | 397 SB_THREAT_TYPE_URL_MALWARE || |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, | 917 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, |
941 base::UTF8ToUTF16(url_.host()))); | 918 base::UTF8ToUTF16(url_.host()))); |
942 load_time_data->SetString( | 919 load_time_data->SetString( |
943 "explanationParagraph", | 920 "explanationParagraph", |
944 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 921 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
945 base::UTF8ToUTF16(url_.host()))); | 922 base::UTF8ToUTF16(url_.host()))); |
946 load_time_data->SetString( | 923 load_time_data->SetString( |
947 "finalParagraph", | 924 "finalParagraph", |
948 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 925 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
949 } | 926 } |
OLD | NEW |