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

Side by Side Diff: components/security_interstitials/content/security_interstitial_page.cc

Issue 2627343003: Update prefservice only if it is available. (Closed)
Patch Set: Created 3 years, 11 months 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
« no previous file with comments | « components/security_interstitials/content/security_interstitial_page.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/security_interstitials/content/security_interstitial_page.h " 5 #include "components/security_interstitials/content/security_interstitial_page.h "
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 17 matching lines...) Expand all
28 content::WebContents* web_contents, 28 content::WebContents* web_contents,
29 const GURL& request_url, 29 const GURL& request_url,
30 std::unique_ptr<SecurityInterstitialControllerClient> controller) 30 std::unique_ptr<SecurityInterstitialControllerClient> controller)
31 : web_contents_(web_contents), 31 : web_contents_(web_contents),
32 request_url_(request_url), 32 request_url_(request_url),
33 interstitial_page_(NULL), 33 interstitial_page_(NULL),
34 create_view_(true), 34 create_view_(true),
35 controller_(std::move(controller)) { 35 controller_(std::move(controller)) {
36 // Determine if any prefs need to be updated prior to showing the security 36 // Determine if any prefs need to be updated prior to showing the security
37 // interstitial. 37 // interstitial.
38 safe_browsing::UpdatePrefsBeforeSecurityInterstitial( 38 if (controller_->GetPrefService()) {
meacer 2017/01/12 23:37:12 nit: In which cases can this be null? Might be use
sgurun-gerrit only 2017/01/12 23:52:54 Done.
39 controller_->GetPrefService()); 39 safe_browsing::UpdatePrefsBeforeSecurityInterstitial(
40 controller_->GetPrefService());
41 }
40 42
41 // Creating interstitial_page_ without showing it leaks memory, so don't 43 // Creating interstitial_page_ without showing it leaks memory, so don't
42 // create it here. 44 // create it here.
43 } 45 }
44 46
45 SecurityInterstitialPage::~SecurityInterstitialPage() { 47 SecurityInterstitialPage::~SecurityInterstitialPage() {
46 } 48 }
47 49
48 content::InterstitialPage* SecurityInterstitialPage::interstitial_page() const { 50 content::InterstitialPage* SecurityInterstitialPage::interstitial_page() const {
49 return interstitial_page_; 51 return interstitial_page_;
(...skipping 17 matching lines...) Expand all
67 web_contents_, ShouldCreateNewNavigation(), request_url_, this); 69 web_contents_, ShouldCreateNewNavigation(), request_url_, this);
68 if (!create_view_) 70 if (!create_view_)
69 interstitial_page_->DontCreateViewForTesting(); 71 interstitial_page_->DontCreateViewForTesting();
70 72
71 interstitial_page_->Show(); 73 interstitial_page_->Show();
72 74
73 controller_->set_interstitial_page(interstitial_page_); 75 controller_->set_interstitial_page(interstitial_page_);
74 AfterShow(); 76 AfterShow();
75 } 77 }
76 78
77 bool SecurityInterstitialPage::IsPrefEnabled(const char* pref) {
78 return controller_->GetPrefService()->GetBoolean(pref);
79 }
80
81 SecurityInterstitialControllerClient* SecurityInterstitialPage::controller() { 79 SecurityInterstitialControllerClient* SecurityInterstitialPage::controller() {
82 return controller_.get(); 80 return controller_.get();
83 } 81 }
84 82
85 security_interstitials::MetricsHelper* 83 security_interstitials::MetricsHelper*
86 SecurityInterstitialPage::metrics_helper() { 84 SecurityInterstitialPage::metrics_helper() {
87 return controller_->metrics_helper(); 85 return controller_->metrics_helper();
88 } 86 }
89 87
90 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { 88 base::string16 SecurityInterstitialPage::GetFormattedHostName() const {
91 return security_interstitials::common_string_util::GetFormattedHostName( 89 return security_interstitials::common_string_util::GetFormattedHostName(
92 request_url_); 90 request_url_);
93 } 91 }
94 92
95 std::string SecurityInterstitialPage::GetHTMLContents() { 93 std::string SecurityInterstitialPage::GetHTMLContents() {
96 base::DictionaryValue load_time_data; 94 base::DictionaryValue load_time_data;
97 PopulateInterstitialStrings(&load_time_data); 95 PopulateInterstitialStrings(&load_time_data);
98 webui::SetLoadTimeDataDefaults( 96 webui::SetLoadTimeDataDefaults(
99 controller()->GetApplicationLocale(), &load_time_data); 97 controller()->GetApplicationLocale(), &load_time_data);
100 std::string html = ResourceBundle::GetSharedInstance() 98 std::string html = ResourceBundle::GetSharedInstance()
101 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) 99 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML)
102 .as_string(); 100 .as_string();
103 webui::AppendWebUiCssTextDefaults(&html); 101 webui::AppendWebUiCssTextDefaults(&html);
104 return webui::GetI18nTemplateHtml(html, &load_time_data); 102 return webui::GetI18nTemplateHtml(html, &load_time_data);
105 } 103 }
106 104
107 } // security_interstitials 105 } // security_interstitials
OLDNEW
« no previous file with comments | « components/security_interstitials/content/security_interstitial_page.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698