Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc

Issue 5102001: Add a checkbox to the malware interstitial page, for user to opt-in to send m... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
===================================================================
--- chrome/browser/safe_browsing/safe_browsing_blocking_page.cc (revision 66339)
+++ chrome/browser/safe_browsing/safe_browsing_blocking_page.cc (working copy)
@@ -14,17 +14,21 @@
#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"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/metrics/user_metrics.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/tab_contents/navigation_controller.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/browser/tab_contents/tab_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
@@ -67,6 +71,8 @@
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
SafeBrowsingBlockingPageFactory* SafeBrowsingBlockingPage::factory_ = NULL;
@@ -111,6 +117,11 @@
}
}
+bool SafeBrowsingBlockingPage::CanShowMalwareReportOption() {
+ return (!tab()->profile()->IsOffTheRecord() &&
+ tab()->GetURL().SchemeIs("http"));
+}
+
SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() {
}
@@ -283,6 +294,26 @@
strings->SetString("proceed_link",
l10n_util::GetStringUTF16(IDS_SAFE_BROWSING_MALWARE_PROCEED_LINK));
strings->SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr");
+
+ if (!CanShowMalwareReportOption()) {
+ strings->SetBoolean("displaycheckbox", false);
+ return;
+ }
+
+ // show the checkbox about sending malware report
+ strings->SetBoolean("displaycheckbox", false);
lzheng 2010/11/23 01:14:49 nit: How about using a const char for "displaychec
+ 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("boxchecked", "yes");
+ } else {
+ strings->SetString("boxchecked", "");
+ }
}
void SafeBrowsingBlockingPage::PopulatePhishingStringDictionary(
@@ -293,8 +324,7 @@
l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_HEADLINE),
l10n_util::GetStringF(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION1,
UTF8ToWide(url().host())),
- l10n_util::GetStringF(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION2,
- UTF8ToWide(url().host())),
+ l10n_util::GetString(IDS_SAFE_BROWSING_PHISHING_DESCRIPTION2),
L"");
strings->SetString("continue_button",
@@ -313,6 +343,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;
@@ -388,6 +428,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);

Powered by Google App Engine
This is Rietveld 408576698