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

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

Issue 622683006: Refactor security interstitials, add SecurityInterstitialPage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: thestig comments Created 6 years, 1 month 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
(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 "chrome/grit/browser_resources.h"
11 #include "content/public/browser/interstitial_page.h"
12 #include "content/public/browser/web_contents.h"
13 #include "ui/base/resource/resource_bundle.h"
14 #include "ui/base/webui/jstemplate_builder.h"
15 #include "ui/base/webui/web_ui_util.h"
16
17 SecurityInterstitialPage::SecurityInterstitialPage(
18 content::WebContents* web_contents,
19 const GURL& request_url)
20 : web_contents_(web_contents),
21 request_url_(request_url),
22 interstitial_page_(NULL),
23 create_view_(true) {
24 // Creating interstitial_page_ without showing it leaks memory, so don't
25 // create it here.
26 }
27
28 SecurityInterstitialPage::~SecurityInterstitialPage() {
29 }
30
31 content::InterstitialPage* SecurityInterstitialPage::interstitial_page() const {
32 return interstitial_page_;
33 }
34
35 content::WebContents* SecurityInterstitialPage::web_contents() const {
36 return web_contents_;
37 }
38
39 GURL SecurityInterstitialPage::request_url() const {
40 return request_url_;
41 }
42
43 void SecurityInterstitialPage::DontCreateViewForTesting() {
44 create_view_ = false;
45 }
46
47 void SecurityInterstitialPage::Show() {
48 DCHECK(!interstitial_page_);
49 interstitial_page_ = content::InterstitialPage::Create(
50 web_contents_, ShouldCreateNewNavigation(), request_url_, this);
51 if (!create_view_)
52 interstitial_page_->DontCreateViewForTesting();
53 interstitial_page_->Show();
54 }
55
56 base::string16 SecurityInterstitialPage::GetFormattedHostName() const {
57 base::string16 host(base::UTF8ToUTF16(request_url_.host()));
58 if (base::i18n::IsRTL())
59 base::i18n::WrapStringWithLTRFormatting(&host);
60 return host;
61 }
62
63 std::string SecurityInterstitialPage::GetHTMLContents() {
64 base::DictionaryValue load_time_data;
65 PopulateInterstitialStrings(&load_time_data);
66 webui::SetFontAndTextDirection(&load_time_data);
67 base::StringPiece html(
68 ResourceBundle::GetSharedInstance().GetRawDataResource(
69 IDR_SECURITY_INTERSTITIAL_HTML));
70 return webui::GetI18nTemplateHtml(html, &load_time_data);
71 }
OLDNEW
« no previous file with comments | « chrome/browser/interstitials/security_interstitial_page.h ('k') | chrome/browser/safe_browsing/safe_browsing_blocking_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698