Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
| 17 #include "components/safe_browsing_db/safe_browsing_prefs.h" | 18 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 18 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/interstitial_page.h" | 20 #include "content/public/browser/interstitial_page.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/common/referrer.h" | 22 #include "content/public/common/referrer.h" |
| 22 | 23 |
| 23 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
| 24 #include "chrome/browser/android/intent_helper.h" | 25 #include "chrome/browser/android/intent_helper.h" |
| 25 #endif | 26 #endif |
| 26 | 27 |
| 27 #if defined(OS_CHROMEOS) | 28 #if defined(OS_CHROMEOS) |
| 28 #include "chrome/browser/profiles/profile_manager.h" | 29 #include "chrome/browser/profiles/profile_manager.h" |
| 29 #include "chrome/browser/ui/chrome_pages.h" | 30 #include "chrome/browser/ui/chrome_pages.h" |
| 30 #include "chrome/common/url_constants.h" | |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
| 34 #include "base/base_paths_win.h" | 34 #include "base/base_paths_win.h" |
| 35 #include "base/path_service.h" | 35 #include "base/path_service.h" |
| 36 #include "base/strings/string16.h" | 36 #include "base/strings/string16.h" |
| 37 #include "base/win/windows_version.h" | 37 #include "base/win/windows_version.h" |
| 38 #endif | 38 #endif |
| 39 | 39 |
| 40 using content::Referrer; | 40 using content::Referrer; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 content::BrowserThread::PostTask( | 153 content::BrowserThread::PostTask( |
| 154 content::BrowserThread::FILE, FROM_HERE, | 154 content::BrowserThread::FILE, FROM_HERE, |
| 155 base::Bind(&LaunchDateAndTimeSettingsOnFileThread)); | 155 base::Bind(&LaunchDateAndTimeSettingsOnFileThread)); |
| 156 #endif | 156 #endif |
| 157 } | 157 } |
| 158 | 158 |
| 159 void ChromeControllerClient::GoBack() { | 159 void ChromeControllerClient::GoBack() { |
| 160 interstitial_page_->DontProceed(); | 160 interstitial_page_->DontProceed(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 // If the offending entry has committed, go back or to a safe page without | |
| 164 // closing th error page. This error page will be closed when the new page | |
|
estark
2016/12/15 21:16:34
typo: th => the
Jialiu Lin
2016/12/15 22:12:53
Oops. Thanks for catching this.
| |
| 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 | |
| 163 void ChromeControllerClient::Proceed() { | 176 void ChromeControllerClient::Proceed() { |
| 164 interstitial_page_->Proceed(); | 177 interstitial_page_->Proceed(); |
| 165 } | 178 } |
| 166 | 179 |
| 167 void ChromeControllerClient::Reload() { | 180 void ChromeControllerClient::Reload() { |
| 168 web_contents_->GetController().Reload(true); | 181 web_contents_->GetController().Reload(true); |
| 169 } | 182 } |
| 170 | 183 |
| 171 void ChromeControllerClient::OpenUrlInCurrentTab(const GURL& url) { | 184 void ChromeControllerClient::OpenUrlInCurrentTab(const GURL& url) { |
| 172 content::OpenURLParams params(url, Referrer(), | 185 content::OpenURLParams params(url, Referrer(), |
| 173 WindowOpenDisposition::CURRENT_TAB, | 186 WindowOpenDisposition::CURRENT_TAB, |
| 174 ui::PAGE_TRANSITION_LINK, false); | 187 ui::PAGE_TRANSITION_LINK, false); |
| 175 web_contents_->OpenURL(params); | 188 web_contents_->OpenURL(params); |
| 176 } | 189 } |
| 177 | 190 |
| 178 const std::string& ChromeControllerClient::GetApplicationLocale() { | 191 const std::string& ChromeControllerClient::GetApplicationLocale() { |
| 179 return g_browser_process->GetApplicationLocale(); | 192 return g_browser_process->GetApplicationLocale(); |
| 180 } | 193 } |
| 181 | 194 |
| 182 PrefService* ChromeControllerClient::GetPrefService() { | 195 PrefService* ChromeControllerClient::GetPrefService() { |
| 183 Profile* profile = | 196 Profile* profile = |
| 184 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 197 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 185 return profile->GetPrefs(); | 198 return profile->GetPrefs(); |
| 186 } | 199 } |
| 187 | 200 |
| 188 const std::string ChromeControllerClient::GetExtendedReportingPrefName() { | 201 const std::string ChromeControllerClient::GetExtendedReportingPrefName() { |
| 189 return safe_browsing::GetExtendedReportingPrefName(*GetPrefService()); | 202 return safe_browsing::GetExtendedReportingPrefName(*GetPrefService()); |
| 190 } | 203 } |
| OLD | NEW |