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

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

Issue 2627343003: Update prefservice only if it is available. (Closed)
Patch Set: address code review 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 16 matching lines...) Expand all
27 SecurityInterstitialPage::SecurityInterstitialPage( 27 SecurityInterstitialPage::SecurityInterstitialPage(
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. Note that some content embedders (such as Android WebView)
38 safe_browsing::UpdatePrefsBeforeSecurityInterstitial( 38 // uses security interstitials without a prefservice.
39 controller_->GetPrefService()); 39 if (controller_->GetPrefService()) {
40 safe_browsing::UpdatePrefsBeforeSecurityInterstitial(
41 controller_->GetPrefService());
42 }
40 43
41 // Creating interstitial_page_ without showing it leaks memory, so don't 44 // Creating interstitial_page_ without showing it leaks memory, so don't
42 // create it here. 45 // create it here.
43 } 46 }
44 47
45 SecurityInterstitialPage::~SecurityInterstitialPage() { 48 SecurityInterstitialPage::~SecurityInterstitialPage() {
46 } 49 }
47 50
48 content::InterstitialPage* SecurityInterstitialPage::interstitial_page() const { 51 content::InterstitialPage* SecurityInterstitialPage::interstitial_page() const {
49 return interstitial_page_; 52 return interstitial_page_;
(...skipping 17 matching lines...) Expand all
67 web_contents_, ShouldCreateNewNavigation(), request_url_, this); 70 web_contents_, ShouldCreateNewNavigation(), request_url_, this);
68 if (!create_view_) 71 if (!create_view_)
69 interstitial_page_->DontCreateViewForTesting(); 72 interstitial_page_->DontCreateViewForTesting();
70 73
71 interstitial_page_->Show(); 74 interstitial_page_->Show();
72 75
73 controller_->set_interstitial_page(interstitial_page_); 76 controller_->set_interstitial_page(interstitial_page_);
74 AfterShow(); 77 AfterShow();
75 } 78 }
76 79
77 bool SecurityInterstitialPage::IsPrefEnabled(const char* pref) {
78 return controller_->GetPrefService()->GetBoolean(pref);
79 }
80
81 SecurityInterstitialControllerClient* SecurityInterstitialPage::controller() { 80 SecurityInterstitialControllerClient* SecurityInterstitialPage::controller() {
82 return controller_.get(); 81 return controller_.get();
83 } 82 }
84 83
85 security_interstitials::MetricsHelper* 84 security_interstitials::MetricsHelper*
86 SecurityInterstitialPage::metrics_helper() { 85 SecurityInterstitialPage::metrics_helper() {
87 return controller_->metrics_helper(); 86 return controller_->metrics_helper();
88 } 87 }
89 88
90 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { 89 base::string16 SecurityInterstitialPage::GetFormattedHostName() const {
91 return security_interstitials::common_string_util::GetFormattedHostName( 90 return security_interstitials::common_string_util::GetFormattedHostName(
92 request_url_); 91 request_url_);
93 } 92 }
94 93
95 std::string SecurityInterstitialPage::GetHTMLContents() { 94 std::string SecurityInterstitialPage::GetHTMLContents() {
96 base::DictionaryValue load_time_data; 95 base::DictionaryValue load_time_data;
97 PopulateInterstitialStrings(&load_time_data); 96 PopulateInterstitialStrings(&load_time_data);
98 webui::SetLoadTimeDataDefaults( 97 webui::SetLoadTimeDataDefaults(
99 controller()->GetApplicationLocale(), &load_time_data); 98 controller()->GetApplicationLocale(), &load_time_data);
100 std::string html = ResourceBundle::GetSharedInstance() 99 std::string html = ResourceBundle::GetSharedInstance()
101 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) 100 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML)
102 .as_string(); 101 .as_string();
103 webui::AppendWebUiCssTextDefaults(&html); 102 webui::AppendWebUiCssTextDefaults(&html);
104 return webui::GetI18nTemplateHtml(html, &load_time_data); 103 return webui::GetI18nTemplateHtml(html, &load_time_data);
105 } 104 }
106 105
107 } // security_interstitials 106 } // 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