Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/interstitials/security_interstitial_page.h" | |
| 6 | |
| 7 #include "base/i18n/rtl.h" | |
| 8 #include "base/strings/utf_string_conversions.h" | |
| 9 #include "base/values.h" | |
| 10 #include "content/public/browser/interstitial_page.h" | |
| 11 #include "content/public/browser/web_contents.h" | |
| 12 #include "ui/base/resource/resource_bundle.h" | |
| 13 #include "ui/base/webui/jstemplate_builder.h" | |
| 14 #include "ui/base/webui/web_ui_util.h" | |
| 15 | |
| 16 SecurityInterstitialPage::SecurityInterstitialPage( | |
| 17 content::WebContents* web_contents, | |
| 18 const GURL& request_url) | |
| 19 : web_contents_(web_contents), | |
| 20 request_url_(request_url), | |
| 21 interstitial_page_(NULL), | |
| 22 create_view_(true) { | |
| 23 // Creating interstitial_page_ without showing it leaks memory, so don't | |
| 24 // create it here. | |
| 25 } | |
| 26 | |
| 27 content::InterstitialPage* SecurityInterstitialPage::interstitial_page() const { | |
| 28 return interstitial_page_; | |
| 29 } | |
| 30 | |
| 31 content::WebContents* SecurityInterstitialPage::web_contents() const { | |
| 32 return web_contents_; | |
| 33 } | |
| 34 | |
| 35 GURL SecurityInterstitialPage::request_url() const { | |
| 36 return request_url_; | |
| 37 } | |
| 38 | |
| 39 void SecurityInterstitialPage::DontCreateViewForTesting() { | |
| 40 create_view_ = false; | |
| 41 } | |
| 42 | |
| 43 void SecurityInterstitialPage::Show() { | |
| 44 DCHECK(!interstitial_page_); | |
| 45 interstitial_page_ = content::InterstitialPage::Create( | |
| 46 web_contents_, ShouldCreateNewNavigation(), request_url_, this); | |
| 47 if (!create_view_) | |
| 48 interstitial_page_->DontCreateViewForTesting(); | |
| 49 interstitial_page_->Show(); | |
| 50 } | |
| 51 | |
| 52 base::string16 SecurityInterstitialPage::GetFormattedHostName() { | |
| 53 base::string16 host(base::UTF8ToUTF16(request_url_.host())); | |
| 54 if (base::i18n::IsRTL()) | |
| 55 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.
| |
| 56 return host; | |
| 57 } | |
| 58 | |
| 59 std::string SecurityInterstitialPage::GetHTMLContents() { | |
| 60 base::DictionaryValue load_time_data; | |
| 61 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.
| |
| 62 webui::SetFontAndTextDirection(&load_time_data); | |
| 63 base::StringPiece html( | |
| 64 ResourceBundle::GetSharedInstance().GetRawDataResource( | |
| 65 IRD_SECURITY_INTERSTITIAL_HTML)); | |
| 66 return webui::GetI18nTemplateHtml(html, &load_time_data); | |
| 67 } | |
| OLD | NEW |