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

Side by Side Diff: chrome/browser/interstitials/chrome_controller_client.cc

Issue 2603433002: Move SecurityInterstitialPage into component (Closed)
Patch Set: nit, refind comments Created 3 years, 12 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/interstitials/chrome_controller_client.h" 5 #include "chrome/browser/interstitials/chrome_controller_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/process/launch.h" 10 #include "base/process/launch.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/interstitials/chrome_metrics_helper.h" 13 #include "chrome/browser/interstitials/chrome_metrics_helper.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "components/prefs/pref_service.h"
18 #include "components/safe_browsing_db/safe_browsing_prefs.h" 17 #include "components/safe_browsing_db/safe_browsing_prefs.h"
19 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
20 #include "content/public/browser/interstitial_page.h"
21 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/referrer.h"
23 20
24 #if defined(OS_ANDROID) 21 #if defined(OS_ANDROID)
25 #include "chrome/browser/android/intent_helper.h" 22 #include "chrome/browser/android/intent_helper.h"
26 #endif 23 #endif
27 24
28 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
29 #include "chrome/browser/profiles/profile_manager.h" 26 #include "chrome/browser/profiles/profile_manager.h"
30 #include "chrome/browser/ui/chrome_pages.h" 27 #include "chrome/browser/ui/chrome_pages.h"
31 #endif 28 #endif
32 29
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 #endif 113 #endif
117 // Don't add code here! (See the comment at the beginning of the function.) 114 // Don't add code here! (See the comment at the beginning of the function.)
118 } 115 }
119 #endif 116 #endif
120 117
121 } // namespace 118 } // namespace
122 119
123 ChromeControllerClient::ChromeControllerClient( 120 ChromeControllerClient::ChromeControllerClient(
124 content::WebContents* web_contents, 121 content::WebContents* web_contents,
125 std::unique_ptr<security_interstitials::MetricsHelper> metrics_helper) 122 std::unique_ptr<security_interstitials::MetricsHelper> metrics_helper)
126 : ControllerClient(std::move(metrics_helper)), 123 : SecurityInterstitialControllerClient(
127 web_contents_(web_contents), 124 web_contents,
128 interstitial_page_(nullptr) {} 125 std::move(metrics_helper),
126 GURL(chrome::kChromeUINewTabURL)) {}
129 127
130 ChromeControllerClient::~ChromeControllerClient() {} 128 ChromeControllerClient::~ChromeControllerClient() {}
131 129
132 void ChromeControllerClient::set_interstitial_page(
133 content::InterstitialPage* interstitial_page) {
134 interstitial_page_ = interstitial_page;
135 }
136
137 bool ChromeControllerClient::CanLaunchDateAndTimeSettings() { 130 bool ChromeControllerClient::CanLaunchDateAndTimeSettings() {
138 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_LINUX) || \ 131 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_LINUX) || \
139 defined(OS_MACOSX) || defined(OS_WIN) 132 defined(OS_MACOSX) || defined(OS_WIN)
140 return true; 133 return true;
141 #else 134 #else
142 return false; 135 return false;
143 #endif 136 #endif
144 } 137 }
145 138
146 void ChromeControllerClient::LaunchDateAndTimeSettings() { 139 void ChromeControllerClient::LaunchDateAndTimeSettings() {
147 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 140 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
148 141
149 #if defined(OS_CHROMEOS) 142 #if defined(OS_CHROMEOS)
150 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), 143 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(),
151 chrome::kDateTimeSubPage); 144 chrome::kDateTimeSubPage);
152 #else 145 #else
153 content::BrowserThread::PostTask( 146 content::BrowserThread::PostTask(
154 content::BrowserThread::FILE, FROM_HERE, 147 content::BrowserThread::FILE, FROM_HERE,
155 base::Bind(&LaunchDateAndTimeSettingsOnFileThread)); 148 base::Bind(&LaunchDateAndTimeSettingsOnFileThread));
156 #endif 149 #endif
157 } 150 }
158 151
159 void ChromeControllerClient::GoBack() {
160 interstitial_page_->DontProceed();
161 }
162
163 // If the offending entry has committed, go back or to a safe page without
164 // closing the error page. This error page will be closed when the new page
165 // commits.
166 void ChromeControllerClient::GoBackAfterNavigationCommitted() {
167 if (web_contents_->GetController().CanGoBack()) {
168 web_contents_->GetController().GoBack();
169 } else {
170 web_contents_->GetController().LoadURL(
171 GURL(chrome::kChromeUINewTabURL), content::Referrer(),
172 ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
173 }
174 }
175
176 void ChromeControllerClient::Proceed() {
177 interstitial_page_->Proceed();
178 }
179
180 void ChromeControllerClient::Reload() {
181 web_contents_->GetController().Reload(content::ReloadType::NORMAL, true);
182 }
183
184 void ChromeControllerClient::OpenUrlInCurrentTab(const GURL& url) {
185 content::OpenURLParams params(url, Referrer(),
186 WindowOpenDisposition::CURRENT_TAB,
187 ui::PAGE_TRANSITION_LINK, false);
188 web_contents_->OpenURL(params);
189 }
190
191 const std::string& ChromeControllerClient::GetApplicationLocale() { 152 const std::string& ChromeControllerClient::GetApplicationLocale() {
192 return g_browser_process->GetApplicationLocale(); 153 return g_browser_process->GetApplicationLocale();
193 } 154 }
194 155
195 PrefService* ChromeControllerClient::GetPrefService() { 156 PrefService* ChromeControllerClient::GetPrefService() {
196 Profile* profile = 157 Profile* profile =
197 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 158 Profile::FromBrowserContext(web_contents_->GetBrowserContext());
198 return profile->GetPrefs(); 159 return profile->GetPrefs();
meacer 2016/12/27 23:22:34 Seems like you can get rid of these two overrides
Jialiu Lin 2016/12/28 18:30:00 Yes, that's right. Done.
199 } 160 }
200
201 const std::string ChromeControllerClient::GetExtendedReportingPrefName() {
202 return safe_browsing::GetExtendedReportingPrefName(*GetPrefService());
203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698