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

Side by Side Diff: chrome/browser/interstitials/security_interstitial_page.cc

Issue 935663004: Add checkbox for reporting invalid TLS/SSL cert chains (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: felt's comments Created 5 years, 10 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 #include "chrome/browser/interstitials/security_interstitial_page.h" 5 #include "chrome/browser/interstitials/security_interstitial_page.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 11 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/pref_names.h"
11 #include "chrome/grit/browser_resources.h" 15 #include "chrome/grit/browser_resources.h"
12 #include "content/public/browser/interstitial_page.h" 16 #include "content/public/browser/interstitial_page.h"
13 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
14 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/base/webui/jstemplate_builder.h" 19 #include "ui/base/webui/jstemplate_builder.h"
16 #include "ui/base/webui/web_ui_util.h" 20 #include "ui/base/webui/web_ui_util.h"
17 21
22 namespace interstitials {
23 const char kBoxChecked[] = "boxchecked";
24 const char kDisplayCheckBox[] = "displaycheckbox";
25 const char kPrivacyLinkHtml[] =
26 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand('showPrivacy'); "
27 "return false;\" onmousedown=\"return false;\">%s</a>";
28 }
29
18 SecurityInterstitialPage::SecurityInterstitialPage( 30 SecurityInterstitialPage::SecurityInterstitialPage(
19 content::WebContents* web_contents, 31 content::WebContents* web_contents,
20 const GURL& request_url) 32 const GURL& request_url)
21 : web_contents_(web_contents), 33 : web_contents_(web_contents),
22 request_url_(request_url), 34 request_url_(request_url),
23 interstitial_page_(NULL), 35 interstitial_page_(NULL),
24 create_view_(true) { 36 create_view_(true) {
25 // Creating interstitial_page_ without showing it leaks memory, so don't 37 // Creating interstitial_page_ without showing it leaks memory, so don't
26 // create it here. 38 // create it here.
27 } 39 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 base::DictionaryValue load_time_data; 77 base::DictionaryValue load_time_data;
66 PopulateInterstitialStrings(&load_time_data); 78 PopulateInterstitialStrings(&load_time_data);
67 const std::string& app_locale = g_browser_process->GetApplicationLocale(); 79 const std::string& app_locale = g_browser_process->GetApplicationLocale();
68 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); 80 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data);
69 std::string html = ResourceBundle::GetSharedInstance() 81 std::string html = ResourceBundle::GetSharedInstance()
70 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) 82 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML)
71 .as_string(); 83 .as_string();
72 webui::AppendWebUiCssTextDefaults(&html); 84 webui::AppendWebUiCssTextDefaults(&html);
73 return webui::GetI18nTemplateHtml(html, &load_time_data); 85 return webui::GetI18nTemplateHtml(html, &load_time_data);
74 } 86 }
87
88 SecurityInterstitialPageWithExtendedReporting::
89 SecurityInterstitialPageWithExtendedReporting(
90 content::WebContents* web_contents,
91 const GURL& url)
92 : SecurityInterstitialPage(web_contents, url) {
93 }
94
95 void SecurityInterstitialPageWithExtendedReporting::SetReportingPreference(
96 bool report) {
97 Profile* profile =
98 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
99 PrefService* pref = profile->GetPrefs();
100 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report);
101 UMA_HISTOGRAM_BOOLEAN("SB2.SetExtendedReportingEnabled", report);
102 }
103
104 bool SecurityInterstitialPageWithExtendedReporting::IsPrefEnabled(
105 const char* pref) {
106 Profile* profile =
107 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
108 return profile->GetPrefs()->GetBoolean(pref);
109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698