OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "components/security_interstitials/content/security_interstitial_contro
ller_client.h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "components/prefs/pref_service.h" |
| 10 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 11 #include "components/security_interstitials/core/metrics_helper.h" |
| 12 #include "content/public/browser/interstitial_page.h" |
| 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/common/referrer.h" |
| 15 |
| 16 using content::Referrer; |
| 17 |
| 18 namespace security_interstitials { |
| 19 |
| 20 SecurityInterstitialControllerClient::SecurityInterstitialControllerClient( |
| 21 content::WebContents* web_contents, |
| 22 std::unique_ptr<MetricsHelper> metrics_helper, |
| 23 PrefService* prefs, |
| 24 const std::string& app_locale, |
| 25 const GURL& default_safe_page) |
| 26 : ControllerClient(std::move(metrics_helper)), |
| 27 web_contents_(web_contents), |
| 28 interstitial_page_(nullptr), |
| 29 prefs_(prefs), |
| 30 app_locale_(app_locale), |
| 31 default_safe_page_(default_safe_page) {} |
| 32 |
| 33 SecurityInterstitialControllerClient::~SecurityInterstitialControllerClient() {} |
| 34 |
| 35 void SecurityInterstitialControllerClient::set_interstitial_page( |
| 36 content::InterstitialPage* interstitial_page) { |
| 37 interstitial_page_ = interstitial_page; |
| 38 } |
| 39 |
| 40 content::InterstitialPage* |
| 41 SecurityInterstitialControllerClient::interstitial_page() { |
| 42 return interstitial_page_; |
| 43 } |
| 44 |
| 45 void SecurityInterstitialControllerClient::GoBack() { |
| 46 interstitial_page_->DontProceed(); |
| 47 } |
| 48 |
| 49 void SecurityInterstitialControllerClient::GoBackAfterNavigationCommitted() { |
| 50 // If the offending entry has committed, go back or to a safe page without |
| 51 // closing the error page. This error page will be closed when the new page |
| 52 // commits. |
| 53 if (web_contents_->GetController().CanGoBack()) { |
| 54 web_contents_->GetController().GoBack(); |
| 55 } else { |
| 56 web_contents_->GetController().LoadURL( |
| 57 default_safe_page_, content::Referrer(), |
| 58 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); |
| 59 } |
| 60 } |
| 61 |
| 62 void SecurityInterstitialControllerClient::Proceed() { |
| 63 interstitial_page_->Proceed(); |
| 64 } |
| 65 |
| 66 void SecurityInterstitialControllerClient::Reload() { |
| 67 web_contents_->GetController().Reload(content::ReloadType::NORMAL, true); |
| 68 } |
| 69 |
| 70 void SecurityInterstitialControllerClient::OpenUrlInCurrentTab( |
| 71 const GURL& url) { |
| 72 content::OpenURLParams params(url, Referrer(), |
| 73 WindowOpenDisposition::CURRENT_TAB, |
| 74 ui::PAGE_TRANSITION_LINK, false); |
| 75 web_contents_->OpenURL(params); |
| 76 } |
| 77 |
| 78 const std::string& |
| 79 SecurityInterstitialControllerClient::GetApplicationLocale() const { |
| 80 return app_locale_; |
| 81 } |
| 82 |
| 83 PrefService* |
| 84 SecurityInterstitialControllerClient::GetPrefService() { |
| 85 return prefs_; |
| 86 } |
| 87 |
| 88 const std::string |
| 89 SecurityInterstitialControllerClient::GetExtendedReportingPrefName() const { |
| 90 return safe_browsing::GetExtendedReportingPrefName(*prefs_); |
| 91 } |
| 92 |
| 93 bool SecurityInterstitialControllerClient::CanLaunchDateAndTimeSettings() { |
| 94 NOTREACHED(); |
| 95 return false; |
| 96 } |
| 97 |
| 98 void SecurityInterstitialControllerClient::LaunchDateAndTimeSettings() { |
| 99 NOTREACHED(); |
| 100 } |
| 101 |
| 102 } // namespace security_interstitials |
OLD | NEW |