Chromium Code Reviews| Index: chrome/browser/interstitials/security_interstitial_page.cc |
| diff --git a/chrome/browser/interstitials/security_interstitial_page.cc b/chrome/browser/interstitials/security_interstitial_page.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b33281f9b16e60e8e51694901814040260657eef |
| --- /dev/null |
| +++ b/chrome/browser/interstitials/security_interstitial_page.cc |
| @@ -0,0 +1,67 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/interstitials/security_interstitial_page.h" |
| + |
| +#include "base/i18n/rtl.h" |
| +#include "base/strings/utf_string_conversions.h" |
| +#include "base/values.h" |
| +#include "content/public/browser/interstitial_page.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "ui/base/resource/resource_bundle.h" |
| +#include "ui/base/webui/jstemplate_builder.h" |
| +#include "ui/base/webui/web_ui_util.h" |
| + |
| +SecurityInterstitialPage::SecurityInterstitialPage( |
| + content::WebContents* web_contents, |
| + const GURL& request_url) |
| + : web_contents_(web_contents), |
| + request_url_(request_url), |
| + interstitial_page_(NULL), |
| + create_view_(true) { |
| + // Creating interstitial_page_ without showing it leaks memory, so don't |
| + // create it here. |
| +} |
| + |
| +content::InterstitialPage* SecurityInterstitialPage::interstitial_page() const { |
| + return interstitial_page_; |
| +} |
| + |
| +content::WebContents* SecurityInterstitialPage::web_contents() const { |
| + return web_contents_; |
| +} |
| + |
| +GURL SecurityInterstitialPage::request_url() const { |
| + return request_url_; |
| +} |
| + |
| +void SecurityInterstitialPage::DontCreateViewForTesting() { |
| + create_view_ = false; |
| +} |
| + |
| +void SecurityInterstitialPage::Show() { |
| + DCHECK(!interstitial_page_); |
| + interstitial_page_ = content::InterstitialPage::Create( |
| + web_contents_, ShouldCreateNewNavigation(), request_url_, this); |
| + if (!create_view_) |
| + interstitial_page_->DontCreateViewForTesting(); |
| + interstitial_page_->Show(); |
| +} |
| + |
| +base::string16 SecurityInterstitialPage::GetFormattedHostName() { |
| + base::string16 host(base::UTF8ToUTF16(request_url_.host())); |
| + if (base::i18n::IsRTL()) |
| + base::i18n::WrapStringWithLTRFormatting(&host); |
|
felt
2014/10/02 19:39:03
^ isn't this wrapping causing the bug with URLs on
meacer
2014/10/02 19:42:48
I'm going to do that in a separate CL. It's not cl
mattm
2014/10/14 08:39:19
Seems like it would be better to fix that first an
meacer
2014/10/20 22:43:15
This part is blocked on https://codereview.chromiu
meacer
2014/11/19 21:29:59
Done, since crrev/643963004 is closed.
|
| + return host; |
| +} |
| + |
| +std::string SecurityInterstitialPage::GetHTMLContents() { |
| + base::DictionaryValue load_time_data; |
| + PopulateLoadTimeData(&load_time_data); |
|
mmenke
2014/11/10 16:42:58
"LoadTime" is overloaded (See, for example, LoadTi
meacer
2014/11/19 21:29:59
Done.
|
| + webui::SetFontAndTextDirection(&load_time_data); |
| + base::StringPiece html( |
| + ResourceBundle::GetSharedInstance().GetRawDataResource( |
| + IRD_SECURITY_INTERSTITIAL_HTML)); |
| + return webui::GetI18nTemplateHtml(html, &load_time_data); |
| +} |