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

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

Issue 2603433002: Move SecurityInterstitialPage into component (Closed)
Patch Set: missed some changes in rebase 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
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, std::move(metrics_helper),
128 interstitial_page_(nullptr) {} 125 Profile::FromBrowserContext(
126 web_contents->GetBrowserContext())->GetPrefs(),
127 g_browser_process->GetApplicationLocale(),
128 GURL(chrome::kChromeUINewTabURL)) {}
129 129
130 ChromeControllerClient::~ChromeControllerClient() {} 130 ChromeControllerClient::~ChromeControllerClient() {}
131 131
132 void ChromeControllerClient::set_interstitial_page(
133 content::InterstitialPage* interstitial_page) {
134 interstitial_page_ = interstitial_page;
135 }
136
137 bool ChromeControllerClient::CanLaunchDateAndTimeSettings() { 132 bool ChromeControllerClient::CanLaunchDateAndTimeSettings() {
138 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_LINUX) || \ 133 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_LINUX) || \
139 defined(OS_MACOSX) || defined(OS_WIN) 134 defined(OS_MACOSX) || defined(OS_WIN)
140 return true; 135 return true;
141 #else 136 #else
142 return false; 137 return false;
143 #endif 138 #endif
144 } 139 }
145 140
146 void ChromeControllerClient::LaunchDateAndTimeSettings() { 141 void ChromeControllerClient::LaunchDateAndTimeSettings() {
147 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 142 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
148 143
149 #if defined(OS_CHROMEOS) 144 #if defined(OS_CHROMEOS)
150 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), 145 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(),
151 chrome::kDateTimeSubPage); 146 chrome::kDateTimeSubPage);
152 #else 147 #else
153 content::BrowserThread::PostTask( 148 content::BrowserThread::PostTask(
154 content::BrowserThread::FILE, FROM_HERE, 149 content::BrowserThread::FILE, FROM_HERE,
155 base::Bind(&LaunchDateAndTimeSettingsOnFileThread)); 150 base::Bind(&LaunchDateAndTimeSettingsOnFileThread));
156 #endif 151 #endif
157 } 152 }
158
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() {
192 return g_browser_process->GetApplicationLocale();
193 }
194
195 PrefService* ChromeControllerClient::GetPrefService() {
196 Profile* profile =
197 Profile::FromBrowserContext(web_contents_->GetBrowserContext());
198 return profile->GetPrefs();
199 }
200
201 const std::string ChromeControllerClient::GetExtendedReportingPrefName() {
202 return safe_browsing::GetExtendedReportingPrefName(*GetPrefService());
203 }
OLDNEW
« no previous file with comments | « chrome/browser/interstitials/chrome_controller_client.h ('k') | chrome/browser/interstitials/security_interstitial_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698