Chromium Code Reviews| Index: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc |
| =================================================================== |
| --- chrome/browser/safe_browsing/safe_browsing_blocking_page.cc (revision 70457) |
| +++ chrome/browser/safe_browsing/safe_browsing_blocking_page.cc (working copy) |
| @@ -15,6 +15,7 @@ |
| #include "base/string_number_conversions.h" |
| #include "base/utf_string_conversions.h" |
| #include "base/values.h" |
| +#include "chrome/browser/browser_process.h" |
| #include "chrome/browser/browser_thread.h" |
| #include "chrome/browser/dom_operation_notification_details.h" |
| #include "chrome/browser/dom_ui/new_tab_ui.h" |
| @@ -72,6 +73,10 @@ |
| static const char* const kLearnMoreCommand = "learnMore"; |
| static const char* const kProceedCommand = "proceed"; |
| static const char* const kTakeMeBackCommand = "takeMeBack"; |
| +static const char* const kDoReportCommand = "doReport"; |
| +static const char* const kDontReportCommand = "dontReport"; |
| +static const char* const kDisplayCheckBox = "displaycheckbox"; |
| +static const char* const kBoxChecked = "boxchecked"; |
| // static |
| SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL; |
| @@ -316,6 +321,26 @@ |
| strings->SetString("proceed_link", |
| l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK)); |
| strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); |
| + |
| + if (!CanShowMalwareDetailsOption()) { |
| + strings->SetBoolean(kDisplayCheckBox, false); |
| + return; |
| + } |
|
lzheng
2011/01/05 23:28:29
I think it will be better to wrap the rest of code
|
| + |
| + // show the checkbox about sending malware report |
| + strings->SetBoolean(kDisplayCheckBox, true); |
| + strings->SetString("confirm_text", |
| + l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_REPORTING_AGREE)); |
| + |
| + const PrefService::Preference* pref = |
| + tab()->profile()->GetPrefs()->FindPreference( |
| + prefs::kSafeBrowsingReportingEnabled); |
| + bool value; |
| + if (pref && pref->GetValue()->GetAsBoolean(&value) && value) { |
| + strings->SetString(kBoxChecked, "yes"); |
| + } else { |
| + strings->SetString(kBoxChecked, ""); |
| + } |
| } |
| void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary( |
| @@ -349,6 +374,16 @@ |
| command = command.substr(1, command.length() - 2); |
| } |
| + if (command == kDoReportCommand) { |
| + SetReportingPreference(true); |
| + return; |
| + } |
| + |
| + if (command == kDontReportCommand) { |
| + SetReportingPreference(false); |
| + return; |
| + } |
| + |
| if (command == kLearnMoreCommand) { |
| // User pressed "Learn more". |
| GURL url; |
| @@ -424,6 +459,11 @@ |
| NOTREACHED() << "Unexpected command: " << command; |
| } |
| +void SafeBrowsingBlockingPage::SetReportingPreference(bool report) { |
| + PrefService* pref = tab()->profile()->GetPrefs(); |
| + pref->SetBoolean(prefs::kSafeBrowsingReportingEnabled, report); |
| +} |
| + |
| void SafeBrowsingBlockingPage::Proceed() { |
| RecordUserAction(PROCEED); |
| FinishMalwareDetails(); // Send the malware details, if we opted to. |