OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 | 52 |
53 // URL for the "Learn more" link on the multi threat malware blocking page. | 53 // URL for the "Learn more" link on the multi threat malware blocking page. |
54 static const char* const kLearnMoreMalwareUrl = | 54 static const char* const kLearnMoreMalwareUrl = |
55 "http://www.google.com/support/bin/answer.py?answer=45449&topic=360" | 55 "http://www.google.com/support/bin/answer.py?answer=45449&topic=360" |
56 "&sa=X&oi=malwarewarninglink&resnum=1&ct=help"; | 56 "&sa=X&oi=malwarewarninglink&resnum=1&ct=help"; |
57 | 57 |
58 // URL for the "Learn more" link on the phishing blocking page. | 58 // URL for the "Learn more" link on the phishing blocking page. |
59 static const char* const kLearnMorePhishingUrl = | 59 static const char* const kLearnMorePhishingUrl = |
60 "http://www.google.com/support/bin/answer.py?answer=106318"; | 60 "http://www.google.com/support/bin/answer.py?answer=106318"; |
61 | 61 |
62 // URL for the "Safe Browsing Privacy Policies" link on the blocking page. | |
63 static const char* const kSbPrivacyPolicyUrl = | |
64 "http://www.google.com/intl/en_us/privacy/browsing.html"; | |
65 | |
62 static const char* const kSbDiagnosticHtml = | 66 static const char* const kSbDiagnosticHtml = |
63 "<a href=\"\" onclick=\"sendCommand('showDiagnostic'); return false;\" " | 67 "<a href=\"\" onclick=\"sendCommand('showDiagnostic'); return false;\" " |
64 "onmousedown=\"return false;\">%s</a>"; | 68 "onmousedown=\"return false;\">%s</a>"; |
65 | 69 |
66 static const char* const kPLinkHtml = | 70 static const char* const kPLinkHtml = |
67 "<a href=\"\" onclick=\"sendCommand('proceed'); return false;\" " | 71 "<a href=\"\" onclick=\"sendCommand('proceed'); return false;\" " |
68 "onmousedown=\"return false;\">%s</a>"; | 72 "onmousedown=\"return false;\">%s</a>"; |
69 | 73 |
74 static const char* const kPrivacyLinkHtml = | |
75 "<a href=\"\" onclick=\"sendCommand('showPrivacy'); return false;\" " | |
76 "onmousedown=\"return false;\">%s</a>"; | |
77 | |
70 // The commands returned by the page when the user performs an action. | 78 // The commands returned by the page when the user performs an action. |
71 static const char* const kShowDiagnosticCommand = "showDiagnostic"; | 79 static const char* const kShowDiagnosticCommand = "showDiagnostic"; |
72 static const char* const kReportErrorCommand = "reportError"; | 80 static const char* const kReportErrorCommand = "reportError"; |
73 static const char* const kLearnMoreCommand = "learnMore"; | 81 static const char* const kLearnMoreCommand = "learnMore"; |
82 static const char* const kShowPrivacyCommand = "showPrivacy"; | |
74 static const char* const kProceedCommand = "proceed"; | 83 static const char* const kProceedCommand = "proceed"; |
75 static const char* const kTakeMeBackCommand = "takeMeBack"; | 84 static const char* const kTakeMeBackCommand = "takeMeBack"; |
76 static const char* const kDoReportCommand = "doReport"; | 85 static const char* const kDoReportCommand = "doReport"; |
77 static const char* const kDontReportCommand = "dontReport"; | 86 static const char* const kDontReportCommand = "dontReport"; |
78 static const char* const kDisplayCheckBox = "displaycheckbox"; | 87 static const char* const kDisplayCheckBox = "displaycheckbox"; |
79 static const char* const kBoxChecked = "boxchecked"; | 88 static const char* const kBoxChecked = "boxchecked"; |
80 | 89 |
81 // static | 90 // static |
82 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; | 91 SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
83 | 92 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); | 329 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_BACK_BUTTON)); |
321 strings->SetString("proceed_link", | 330 strings->SetString("proceed_link", |
322 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK)); | 331 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK)); |
323 strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); | 332 strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); |
324 | 333 |
325 if (!CanShowMalwareDetailsOption()) { | 334 if (!CanShowMalwareDetailsOption()) { |
326 strings->SetBoolean(kDisplayCheckBox, false); | 335 strings->SetBoolean(kDisplayCheckBox, false); |
327 } else { | 336 } else { |
328 // Show the checkbox for sending malware details. | 337 // Show the checkbox for sending malware details. |
329 strings->SetBoolean(kDisplayCheckBox, true); | 338 strings->SetBoolean(kDisplayCheckBox, true); |
330 strings->SetString( | 339 |
331 "confirm_text", | 340 std::string privacy_link = StringPrintf( |
332 l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE)); | 341 kPrivacyLinkHtml, |
342 l10n_util::GetStringUTF8( | |
343 IDS_SAFE_BROWSING_PRIVACY_POLICY_PAGE).c_str()); | |
344 | |
345 strings->SetString("confirm_text", | |
346 l10n_util::GetStringFUTF16( | |
347 IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE, | |
348 UTF8ToUTF16(privacy_link))); | |
333 | 349 |
334 const PrefService::Preference* pref = | 350 const PrefService::Preference* pref = |
335 tab()->profile()->GetPrefs()->FindPreference( | 351 tab()->profile()->GetPrefs()->FindPreference( |
336 prefs::kSafeBrowsingReportingEnabled); | 352 prefs::kSafeBrowsingReportingEnabled); |
337 | 353 |
338 bool value; | 354 bool value; |
339 if (pref && pref->GetValue()->GetAsBoolean(&value) && value) { | 355 if (pref && pref->GetValue()->GetAsBoolean(&value) && value) { |
340 strings->SetString(kBoxChecked, "yes"); | 356 strings->SetString(kBoxChecked, "yes"); |
341 } else { | 357 } else { |
342 strings->SetString(kBoxChecked, ""); | 358 strings->SetString(kBoxChecked, ""); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 } else if (unsafe_resources_[0].threat_type == | 409 } else if (unsafe_resources_[0].threat_type == |
394 SafeBrowsingService::URL_PHISHING) { | 410 SafeBrowsingService::URL_PHISHING) { |
395 url = google_util::AppendGoogleLocaleParam(GURL(kLearnMorePhishingUrl)); | 411 url = google_util::AppendGoogleLocaleParam(GURL(kLearnMorePhishingUrl)); |
396 } else { | 412 } else { |
397 NOTREACHED(); | 413 NOTREACHED(); |
398 } | 414 } |
399 tab()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::LINK); | 415 tab()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::LINK); |
400 return; | 416 return; |
401 } | 417 } |
402 | 418 |
419 if (command == kShowPrivacyCommand) { | |
420 // User pressed "Safe Browsing privacy policy". | |
421 GURL url(kSbPrivacyPolicyUrl); // Note: this page is not yet localized. | |
lzheng
2011/01/13 17:49:35
Put this note at where kSbPrivacyPolicyUrl is defi
panayiotis
2011/01/13 18:56:29
Done. I'll ping Ian on the localization plan. Loca
| |
422 tab()->OpenURL(url, GURL(), CURRENT_TAB, PageTransition::LINK); | |
423 return; | |
424 } | |
425 | |
403 if (command == kProceedCommand) { | 426 if (command == kProceedCommand) { |
404 Proceed(); | 427 Proceed(); |
405 // We are deleted after this. | 428 // We are deleted after this. |
406 return; | 429 return; |
407 } | 430 } |
408 | 431 |
409 if (command == kTakeMeBackCommand) { | 432 if (command == kTakeMeBackCommand) { |
410 DontProceed(); | 433 DontProceed(); |
411 // We are deleted after this. | 434 // We are deleted after this. |
412 return; | 435 return; |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
645 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 668 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
646 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource); | 669 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource); |
647 } | 670 } |
648 | 671 |
649 // static | 672 // static |
650 bool SafeBrowsingBlockingPage::IsMainPage( | 673 bool SafeBrowsingBlockingPage::IsMainPage( |
651 const UnsafeResourceList& unsafe_resources) { | 674 const UnsafeResourceList& unsafe_resources) { |
652 return unsafe_resources.size() == 1 && | 675 return unsafe_resources.size() == 1 && |
653 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME; | 676 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME; |
654 } | 677 } |
OLD | NEW |