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

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: also record when users disable extended reporting Created 5 years, 9 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/interstitials/security_interstitial_metrics_helper.h"
14 #include "chrome/browser/net/referrer.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/common/pref_names.h"
11 #include "chrome/grit/browser_resources.h" 17 #include "chrome/grit/browser_resources.h"
18 #include "chrome/grit/generated_resources.h"
19 #include "components/google/core/browser/google_util.h"
12 #include "content/public/browser/interstitial_page.h" 20 #include "content/public/browser/interstitial_page.h"
21 #include "content/public/browser/page_navigator.h"
13 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
23 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 24 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/base/webui/jstemplate_builder.h" 25 #include "ui/base/webui/jstemplate_builder.h"
16 #include "ui/base/webui/web_ui_util.h" 26 #include "ui/base/webui/web_ui_util.h"
17 27
28 namespace interstitials {
29 const char kBoxChecked[] = "boxchecked";
30 const char kDisplayCheckBox[] = "displaycheckbox";
31 const char kOptInLink[] = "optInLink";
32 const char kPrivacyLinkHtml[] =
33 "<a id=\"privacy-link\" href=\"\" onclick=\"sendCommand(%d); "
34 "return false;\" onmousedown=\"return false;\">%s</a>";
35 }
36
37 using content::OpenURLParams;
38 using content::Referrer;
39
18 SecurityInterstitialPage::SecurityInterstitialPage( 40 SecurityInterstitialPage::SecurityInterstitialPage(
19 content::WebContents* web_contents, 41 content::WebContents* web_contents,
20 const GURL& request_url) 42 const GURL& request_url)
21 : web_contents_(web_contents), 43 : web_contents_(web_contents),
22 request_url_(request_url), 44 request_url_(request_url),
23 interstitial_page_(NULL), 45 interstitial_page_(NULL),
24 create_view_(true) { 46 create_view_(true) {
25 // Creating interstitial_page_ without showing it leaks memory, so don't 47 // Creating interstitial_page_ without showing it leaks memory, so don't
26 // create it here. 48 // create it here.
27 } 49 }
(...skipping 19 matching lines...) Expand all
47 69
48 void SecurityInterstitialPage::Show() { 70 void SecurityInterstitialPage::Show() {
49 DCHECK(!interstitial_page_); 71 DCHECK(!interstitial_page_);
50 interstitial_page_ = content::InterstitialPage::Create( 72 interstitial_page_ = content::InterstitialPage::Create(
51 web_contents_, ShouldCreateNewNavigation(), request_url_, this); 73 web_contents_, ShouldCreateNewNavigation(), request_url_, this);
52 if (!create_view_) 74 if (!create_view_)
53 interstitial_page_->DontCreateViewForTesting(); 75 interstitial_page_->DontCreateViewForTesting();
54 interstitial_page_->Show(); 76 interstitial_page_->Show();
55 } 77 }
56 78
79 void SecurityInterstitialPage::SetReportingPreference(bool report) {
80 Profile* profile =
81 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
82 PrefService* pref = profile->GetPrefs();
83 pref->SetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled, report);
84 metrics_helper_->RecordUserInteraction(
85 report
86 ? SecurityInterstitialMetricsHelper::SET_EXTENDED_REPORTING_ENABLED
87 : SecurityInterstitialMetricsHelper::SET_EXTENDED_REPORTING_DISABLED);
88 }
89
90 bool SecurityInterstitialPage::IsPrefEnabled(const char* pref) {
91 Profile* profile =
92 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
93 return profile->GetPrefs()->GetBoolean(pref);
94 }
95
96 void SecurityInterstitialPage::OpenExtendedReportingPrivacyPolicy() {
97 metrics_helper_->RecordUserInteraction(
98 SecurityInterstitialMetricsHelper::SHOW_PRIVACY_POLICY);
99 GURL privacy_url(
100 l10n_util::GetStringUTF8(IDS_SAFE_BROWSING_PRIVACY_POLICY_URL));
101 privacy_url = google_util::AppendGoogleLocaleParam(
102 privacy_url, g_browser_process->GetApplicationLocale());
103 OpenURLParams params(privacy_url, Referrer(), CURRENT_TAB,
104 ui::PAGE_TRANSITION_LINK, false);
105 web_contents()->OpenURL(params);
106 }
107
57 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { 108 base::string16 SecurityInterstitialPage::GetFormattedHostName() const {
58 base::string16 host(base::UTF8ToUTF16(request_url_.host())); 109 base::string16 host(base::UTF8ToUTF16(request_url_.host()));
59 if (base::i18n::IsRTL()) 110 if (base::i18n::IsRTL())
60 base::i18n::WrapStringWithLTRFormatting(&host); 111 base::i18n::WrapStringWithLTRFormatting(&host);
61 return host; 112 return host;
62 } 113 }
63 114
64 std::string SecurityInterstitialPage::GetHTMLContents() { 115 std::string SecurityInterstitialPage::GetHTMLContents() {
65 base::DictionaryValue load_time_data; 116 base::DictionaryValue load_time_data;
66 PopulateInterstitialStrings(&load_time_data); 117 PopulateInterstitialStrings(&load_time_data);
67 const std::string& app_locale = g_browser_process->GetApplicationLocale(); 118 const std::string& app_locale = g_browser_process->GetApplicationLocale();
68 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); 119 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data);
69 std::string html = ResourceBundle::GetSharedInstance() 120 std::string html = ResourceBundle::GetSharedInstance()
70 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) 121 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML)
71 .as_string(); 122 .as_string();
72 webui::AppendWebUiCssTextDefaults(&html); 123 webui::AppendWebUiCssTextDefaults(&html);
73 return webui::GetI18nTemplateHtml(html, &load_time_data); 124 return webui::GetI18nTemplateHtml(html, &load_time_data);
74 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698