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