Chromium Code Reviews| 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 const GURL& default_safe_page) | |
| 24 : ControllerClient(std::move(metrics_helper)), | |
| 25 web_contents_(web_contents), | |
| 26 interstitial_page_(nullptr), | |
| 27 prefs_(nullptr), | |
| 28 default_safe_page_(default_safe_page) {} | |
| 29 | |
| 30 SecurityInterstitialControllerClient::SecurityInterstitialControllerClient( | |
| 31 content::WebContents* web_contents, | |
| 32 std::unique_ptr<MetricsHelper> metrics_helper, | |
| 33 PrefService* prefs, | |
| 34 const std::string& app_locale, | |
| 35 const GURL& default_safe_page) | |
| 36 : ControllerClient(std::move(metrics_helper)), | |
| 37 web_contents_(web_contents), | |
| 38 interstitial_page_(nullptr), | |
| 39 prefs_(prefs), | |
| 40 app_locale_(app_locale), | |
| 41 default_safe_page_(default_safe_page) {} | |
| 42 | |
| 43 SecurityInterstitialControllerClient::~SecurityInterstitialControllerClient() {} | |
| 44 | |
| 45 void SecurityInterstitialControllerClient::set_interstitial_page( | |
| 46 content::InterstitialPage* interstitial_page) { | |
| 47 interstitial_page_ = interstitial_page; | |
| 48 } | |
| 49 | |
| 50 content::InterstitialPage* | |
| 51 SecurityInterstitialControllerClient::interstitial_page() { | |
| 52 return interstitial_page_; | |
| 53 } | |
| 54 | |
| 55 void SecurityInterstitialControllerClient::GoBack() { | |
| 56 interstitial_page_->DontProceed(); | |
| 57 } | |
| 58 | |
| 59 // If the offending entry has committed, go back or to a safe page without | |
| 60 // closing the error page. This error page will be closed when the new page | |
| 61 // commits. | |
|
meacer
2016/12/27 23:22:34
nit: This comment seems to be specific to the impl
Jialiu Lin
2016/12/28 18:30:00
Done.
| |
| 62 void SecurityInterstitialControllerClient::GoBackAfterNavigationCommitted() { | |
| 63 if (web_contents_->GetController().CanGoBack()) { | |
| 64 web_contents_->GetController().GoBack(); | |
| 65 } else { | |
| 66 web_contents_->GetController().LoadURL( | |
| 67 default_safe_page_, content::Referrer(), | |
| 68 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); | |
| 69 } | |
| 70 } | |
| 71 | |
| 72 void SecurityInterstitialControllerClient::Proceed() { | |
| 73 interstitial_page_->Proceed(); | |
| 74 } | |
| 75 | |
| 76 void SecurityInterstitialControllerClient::Reload() { | |
| 77 web_contents_->GetController().Reload(content::ReloadType::NORMAL, true); | |
| 78 } | |
| 79 | |
| 80 void SecurityInterstitialControllerClient::OpenUrlInCurrentTab( | |
| 81 const GURL& url) { | |
| 82 content::OpenURLParams params(url, Referrer(), | |
| 83 WindowOpenDisposition::CURRENT_TAB, | |
| 84 ui::PAGE_TRANSITION_LINK, false); | |
| 85 web_contents_->OpenURL(params); | |
| 86 } | |
| 87 | |
| 88 const std::string& | |
| 89 SecurityInterstitialControllerClient::GetApplicationLocale() { | |
| 90 return app_locale_; | |
| 91 } | |
| 92 | |
| 93 PrefService* | |
| 94 SecurityInterstitialControllerClient::GetPrefService() { | |
| 95 return prefs_; | |
| 96 } | |
| 97 | |
| 98 const std::string | |
| 99 SecurityInterstitialControllerClient::GetExtendedReportingPrefName() { | |
| 100 return safe_browsing::GetExtendedReportingPrefName(*GetPrefService()); | |
| 101 } | |
| 102 | |
| 103 bool SecurityInterstitialControllerClient::CanLaunchDateAndTimeSettings() { | |
| 104 NOTREACHED(); | |
| 105 return false; | |
| 106 } | |
| 107 | |
| 108 void SecurityInterstitialControllerClient::LaunchDateAndTimeSettings() { | |
| 109 NOTREACHED(); | |
| 110 } | |
| 111 | |
| 112 } // namespace security_interstitials | |
| OLD | NEW |