| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 16 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 17 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 17 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 18 #include "chrome/browser/google/google_profile_helper.h" | |
| 19 #include "chrome/browser/net/url_request_mock_util.h" | 18 #include "chrome/browser/net/url_request_mock_util.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
| 20 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
| 21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_commands.h" | 22 #include "chrome/browser/ui/browser_commands.h" |
| 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 23 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 24 #include "chrome/common/chrome_paths.h" | 24 #include "chrome/common/chrome_paths.h" |
| 25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
| 28 #include "chrome/test/base/in_process_browser_test.h" | 28 #include "chrome/test/base/in_process_browser_test.h" |
| 29 #include "chrome/test/base/ui_test_utils.h" | 29 #include "chrome/test/base/ui_test_utils.h" |
| 30 #include "components/google/core/browser/google_util.h" | 30 #include "components/google/core/browser/google_util.h" |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 const GURL& search_url, | 272 const GURL& search_url, |
| 273 scoped_ptr<net::URLRequestInterceptor> link_doctor_interceptor) { | 273 scoped_ptr<net::URLRequestInterceptor> link_doctor_interceptor) { |
| 274 chrome_browser_net::SetUrlRequestMocksEnabled(true); | 274 chrome_browser_net::SetUrlRequestMocksEnabled(true); |
| 275 | 275 |
| 276 AddInterceptorForURL(google_util::LinkDoctorBaseURL(), | 276 AddInterceptorForURL(google_util::LinkDoctorBaseURL(), |
| 277 link_doctor_interceptor.Pass()); | 277 link_doctor_interceptor.Pass()); |
| 278 | 278 |
| 279 // Add a mock for the search engine the error page will use. | 279 // Add a mock for the search engine the error page will use. |
| 280 base::FilePath root_http; | 280 base::FilePath root_http; |
| 281 PathService::Get(chrome::DIR_TEST_DATA, &root_http); | 281 PathService::Get(chrome::DIR_TEST_DATA, &root_http); |
| 282 net::URLRequestMockHTTPJob::AddHostnameToFileHandler( | 282 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( |
| 283 search_url.host(), | 283 search_url.scheme(), search_url.host(), |
| 284 root_http.AppendASCII("title3.html"), | 284 net::URLRequestMockHTTPJob::CreateInterceptorForSingleFile( |
| 285 BrowserThread::GetBlockingPool()); | 285 root_http.AppendASCII("title3.html"), |
| 286 BrowserThread::GetBlockingPool())); |
| 286 } | 287 } |
| 287 | 288 |
| 288 class ErrorPageTest : public InProcessBrowserTest { | 289 class ErrorPageTest : public InProcessBrowserTest { |
| 289 public: | 290 public: |
| 290 enum HistoryNavigationDirection { | 291 enum HistoryNavigationDirection { |
| 291 HISTORY_NAVIGATE_BACK, | 292 HISTORY_NAVIGATE_BACK, |
| 292 HISTORY_NAVIGATE_FORWARD, | 293 HISTORY_NAVIGATE_FORWARD, |
| 293 }; | 294 }; |
| 294 | 295 |
| 295 ErrorPageTest() : link_doctor_interceptor_(NULL) {} | 296 ErrorPageTest() : link_doctor_interceptor_(NULL) {} |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 406 } |
| 406 | 407 |
| 407 protected: | 408 protected: |
| 408 void SetUpOnMainThread() override { | 409 void SetUpOnMainThread() override { |
| 409 link_doctor_interceptor_ = new LinkDoctorInterceptor(); | 410 link_doctor_interceptor_ = new LinkDoctorInterceptor(); |
| 410 scoped_ptr<net::URLRequestInterceptor> owned_interceptor( | 411 scoped_ptr<net::URLRequestInterceptor> owned_interceptor( |
| 411 link_doctor_interceptor_); | 412 link_doctor_interceptor_); |
| 412 // Ownership of the |interceptor_| is passed to an object the IO thread, but | 413 // Ownership of the |interceptor_| is passed to an object the IO thread, but |
| 413 // a pointer is kept in the test fixture. As soon as anything calls | 414 // a pointer is kept in the test fixture. As soon as anything calls |
| 414 // URLRequestFilter::ClearHandlers(), |interceptor_| can become invalid. | 415 // URLRequestFilter::ClearHandlers(), |interceptor_| can become invalid. |
| 416 UIThreadSearchTermsData search_terms_data(browser()->profile()); |
| 415 BrowserThread::PostTask( | 417 BrowserThread::PostTask( |
| 416 BrowserThread::IO, FROM_HERE, | 418 BrowserThread::IO, FROM_HERE, |
| 417 base::Bind(&InstallMockInterceptors, | 419 base::Bind(&InstallMockInterceptors, |
| 418 google_util::GetGoogleSearchURL( | 420 GURL(search_terms_data.GoogleBaseURLValue()), |
| 419 google_profile_helper::GetGoogleHomePageURL( | |
| 420 browser()->profile())), | |
| 421 base::Passed(&owned_interceptor))); | 421 base::Passed(&owned_interceptor))); |
| 422 } | 422 } |
| 423 | 423 |
| 424 // Returns a GURL that results in a DNS error. | 424 // Returns a GURL that results in a DNS error. |
| 425 GURL GetDnsErrorURL() const { | 425 GURL GetDnsErrorURL() const { |
| 426 return URLRequestFailedJob::GetMockHttpUrl(net::ERR_NAME_NOT_RESOLVED); | 426 return URLRequestFailedJob::GetMockHttpUrl(net::ERR_NAME_NOT_RESOLVED); |
| 427 } | 427 } |
| 428 | 428 |
| 429 private: | 429 private: |
| 430 // Navigates the browser the indicated direction in the history and waits for | 430 // Navigates the browser the indicated direction in the history and waits for |
| (...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 ui_test_utils::NavigateToURL( | 1117 ui_test_utils::NavigateToURL( |
| 1118 browser(), | 1118 browser(), |
| 1119 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, | 1119 URLRequestFailedJob::GetMockHttpUrlForHostname(net::ERR_UNSAFE_PORT, |
| 1120 kHostname)); | 1120 kHostname)); |
| 1121 | 1121 |
| 1122 ToggleHelpBox(browser()); | 1122 ToggleHelpBox(browser()); |
| 1123 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); | 1123 EXPECT_TRUE(IsDisplayingText(browser(), kHostnameJSUnicode)); |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 } // namespace | 1126 } // namespace |
| OLD | NEW |