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: Fix bad rebase and add owners 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 "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_)
Lei Zhang 2014/11/20 01:35:06 Expanding this out, it'll be: if (create_view_ ==
meacer 2014/11/20 01:58:52 SecurityInterstitialPage is a delegate of |interst
Lei Zhang 2014/11/20 02:05:27 Hmm, I see this is essentially moved over from chr
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);
56 return host;
57 }
58
59 std::string SecurityInterstitialPage::GetHTMLContents() {
60 base::DictionaryValue load_time_data;
61 PopulateInterstitialStrings(&load_time_data);
62 webui::SetFontAndTextDirection(&load_time_data);
63 base::StringPiece html(
64 ResourceBundle::GetSharedInstance().GetRawDataResource(
65 IDR_SECURITY_INTERSTITIAL_HTML));
66 return webui::GetI18nTemplateHtml(html, &load_time_data);
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698