Chromium Code Reviews| Index: chrome/browser/ssl/ssl_blocking_page.cc |
| diff --git a/chrome/browser/ssl/ssl_blocking_page.cc b/chrome/browser/ssl/ssl_blocking_page.cc |
| index 615c4c602e0dba48a844820a4d53a8a0d1fd661e..6f16f15a65d39a1a24fbf30b76d16a6d4ceb50af 100644 |
| --- a/chrome/browser/ssl/ssl_blocking_page.cc |
| +++ b/chrome/browser/ssl/ssl_blocking_page.cc |
| @@ -5,6 +5,7 @@ |
| #include "chrome/browser/ssl/ssl_blocking_page.h" |
| #include "base/i18n/rtl.h" |
| +#include "base/metrics/field_trial.h" |
| #include "base/metrics/histogram.h" |
| #include "base/strings/string_piece.h" |
| #include "base/utf_string_conversions.h" |
| @@ -24,6 +25,7 @@ |
| #include "content/public/browser/render_view_host.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/common/ssl_status.h" |
| +#include "grit/app_locale_settings.h" |
| #include "grit/browser_resources.h" |
| #include "grit/generated_resources.h" |
| #include "net/base/net_errors.h" |
| @@ -31,6 +33,10 @@ |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/webui/jstemplate_builder.h" |
| +#if defined(OS_WIN) |
| +#include "base/win/windows_version.h" |
| +#endif |
| + |
| using base::TimeDelta; |
| using base::TimeTicks; |
| using content::InterstitialPage; |
| @@ -59,6 +65,7 @@ enum SSLBlockingPageCommands { |
| CMD_PROCEED, |
| CMD_FOCUS, |
| CMD_MORE, |
| + CMD_UNDERSTAND, // Used by the Finch trial. |
| }; |
| // Events for UMA. |
| @@ -74,7 +81,8 @@ enum SSLBlockingPageEvent { |
| DONT_PROCEED_DATE, |
| DONT_PROCEED_AUTHORITY, |
| MORE, |
| - UNUSED_BLOCKING_PAGE_EVENT, |
| + UNDERSTAND, |
| + UNUSED_BLOCKING_PAGE_EVENT |
| }; |
| void RecordSSLBlockingPageEventStats(SSLBlockingPageEvent event) { |
| @@ -144,6 +152,16 @@ void RecordSSLBlockingPageTimeStats( |
| } |
| } |
| +// These are the conditions for the Finch experiment. |
| +static const std::string kCondition15Control = "Condition15SSLControl"; |
|
agl
2013/05/01 18:54:12
static const char kFoo[] = "...";
felt
2013/05/01 19:39:45
Done.
|
| +static const std::string kCondition16Firefox = "Condition16SSLFirefox"; |
| +static const std::string kCondition17FancyFirefox = |
| + "Condition17SSLFancyFirefox"; |
| +static const std::string kCondition18NoImages = "Condition18SSLNoImages"; |
| +static const std::string kCondition19Policeman = "Condition19SSLPoliceman"; |
| +static const std::string kCondition20Stoplight = "Condition20SSLStoplight"; |
| +static const std::string kCondition21BadGuy = "Condition21SSLBadGuy"; |
| + |
| } // namespace |
| // Note that we always create a navigation entry with SSL errors. |
| @@ -163,6 +181,12 @@ SSLBlockingPage::SSLBlockingPage( |
| request_url_(request_url), |
| overridable_(overridable), |
| strict_enforcement_(strict_enforcement) { |
| + |
| + // Only assign to a group if the warning can be clicked through. |
| + trial_ = ""; |
|
agl
2013/05/01 18:54:12
doesn't need to be initially cleared.
felt
2013/05/01 19:39:45
Done.
|
| + if (overridable_ && !strict_enforcement_) |
| + trial_ = base::FieldTrialList::FindFullName("InterstitialSSL"); |
| + |
| RecordSSLBlockingPageEventStats(SHOW_ALL); |
| if (overridable_ && !strict_enforcement_) |
| RecordSSLBlockingPageEventStats(SHOW_OVERRIDABLE); |
| @@ -175,6 +199,9 @@ SSLBlockingPage::SSLBlockingPage( |
| SSLBlockingPage::~SSLBlockingPage() { |
| if (!callback_.is_null()) { |
| + RecordSSLBlockingPageTimeStats(false, cert_error_, |
| + overridable_ && !strict_enforcement_, display_start_time_, |
| + base::TimeTicks::Now()); |
| // The page is closed without the user having chosen what to do, default to |
| // deny. |
| NotifyDenyCertificate(); |
| @@ -188,6 +215,7 @@ std::string SSLBlockingPage::GetHTMLContents() { |
| SSLErrorInfo::NetErrorToErrorType(cert_error_), ssl_info_.cert, |
| request_url_); |
| + int resource_id = IDR_SSL_ROAD_BLOCK_HTML; |
| strings.SetString("headLine", error_info.title()); |
| strings.SetString("description", error_info.details()); |
| strings.SetString("moreInfoTitle", |
| @@ -197,7 +225,6 @@ std::string SSLBlockingPage::GetHTMLContents() { |
| strings.SetString("exit", |
| l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_EXIT)); |
| - int resource_id = IDR_SSL_ROAD_BLOCK_HTML; |
| if (overridable_ && !strict_enforcement_) { |
| strings.SetString("title", |
| l10n_util::GetStringUTF16(IDS_SSL_BLOCKING_PAGE_TITLE)); |
| @@ -225,6 +252,26 @@ std::string SSLBlockingPage::GetHTMLContents() { |
| strings.SetString("textdirection", base::i18n::IsRTL() ? "rtl" : "ltr"); |
| + // Set up the Finch trial layouts. |
| + strings.SetString("trialType", trial_); |
| + if (trial_ == kCondition16Firefox || trial_ == kCondition17FancyFirefox) { |
| + strings.SetString("domain", request_url_.host()); |
| + std::string font_family = l10n_util::GetStringUTF8(IDS_WEB_FONT_FAMILY); |
| +#if defined(OS_WIN) |
| + if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| + font_family = l10n_util::GetStringUTF8(IDS_WEB_FONT_FAMILY_XP); |
| +#endif |
| +#if defined(TOOLKIT_GTK) |
| + font_family = ui::ResourceBundle::GetSharedInstance().GetFont( |
| + ui::ResourceBundle::BaseFont).GetFontName() + ", " + font_family; |
| +#endif |
| + strings.SetString("fontfamily", font_family); |
| + if (trial_ == kCondition16Firefox) |
|
agl
2013/05/01 18:54:12
braces needed I think.
felt
2013/05/01 19:39:45
Done.
felt
2013/05/01 19:39:45
Done.
|
| + resource_id = IDR_SSL_FIREFOX_HTML; |
| + else if (trial_ == kCondition17FancyFirefox) |
| + resource_id = IDR_SSL_FANCY_FIREFOX_HTML; |
| + } |
| + |
| base::StringPiece html( |
| ResourceBundle::GetSharedInstance().GetRawDataResource( |
| resource_id)); |
| @@ -260,6 +307,9 @@ void SSLBlockingPage::CommandReceived(const std::string& command) { |
| display_start_time_ = base::TimeTicks::Now(); |
| } else if (cmd == CMD_MORE) { |
| RecordSSLBlockingPageEventStats(MORE); |
| + } else if (cmd == CMD_UNDERSTAND) { |
| + // Used in the Finch experiment. |
| + RecordSSLBlockingPageEventStats(UNDERSTAND); |
| } |
| } |