| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/content_settings/cookie_settings.h" | 12 #include "chrome/browser/content_settings/cookie_settings.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/prefs/session_startup_pref.h" | 14 #include "chrome/browser/prefs/session_startup_pref.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_list.h" | 17 #include "chrome/browser/ui/browser_list.h" |
| 18 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/content_settings.h" | 20 #include "chrome/common/content_settings.h" |
| 21 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 22 #include "chrome/test/base/in_process_browser_test.h" |
| 23 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
| 26 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
| 27 #include "net/base/upload_data.h" | 27 #include "net/base/upload_bytes_element_reader.h" |
| 28 #include "net/base/upload_element.h" | 28 #include "net/base/upload_data_stream.h" |
| 29 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
| 30 #include "net/url_request/url_request_filter.h" | 30 #include "net/url_request/url_request_filter.h" |
| 31 #include "net/url_request/url_request_test_job.h" | 31 #include "net/url_request/url_request_test_job.h" |
| 32 | 32 |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 // We need to serve the test files so that PRE_Test and Test can access the same | 35 // We need to serve the test files so that PRE_Test and Test can access the same |
| 36 // page using the same URL. In addition, perceived security origin of the page | 36 // page using the same URL. In addition, perceived security origin of the page |
| 37 // needs to stay the same, so e.g., redirecting the URL requests doesn't | 37 // needs to stay the same, so e.g., redirecting the URL requests doesn't |
| 38 // work. (If we used a test server, the PRE_Test and Test would have separate | 38 // work. (If we used a test server, the PRE_Test and Test would have separate |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 g_file_contents.Get()[request->url().path()], true); | 50 g_file_contents.Get()[request->url().path()], true); |
| 51 } | 51 } |
| 52 | 52 |
| 53 base::LazyInstance<std::string> g_last_upload_bytes = LAZY_INSTANCE_INITIALIZER; | 53 base::LazyInstance<std::string> g_last_upload_bytes = LAZY_INSTANCE_INITIALIZER; |
| 54 | 54 |
| 55 net::URLRequestJob* URLRequestFakerForPostRequests( | 55 net::URLRequestJob* URLRequestFakerForPostRequests( |
| 56 net::URLRequest* request, | 56 net::URLRequest* request, |
| 57 net::NetworkDelegate* network_delegate, | 57 net::NetworkDelegate* network_delegate, |
| 58 const std::string& scheme) { | 58 const std::string& scheme) { |
| 59 // Read the uploaded data and store it to g_last_upload_bytes. | 59 // Read the uploaded data and store it to g_last_upload_bytes. |
| 60 const net::UploadData* upload_data = request->get_upload(); | 60 const net::UploadDataStream* upload_data = request->get_upload(); |
| 61 g_last_upload_bytes.Get().clear(); | 61 g_last_upload_bytes.Get().clear(); |
| 62 if (upload_data) { | 62 if (upload_data) { |
| 63 const ScopedVector<net::UploadElement>& elements = upload_data->elements(); | 63 const ScopedVector<net::UploadElementReader>& readers = |
| 64 for (size_t i = 0; i < elements.size(); ++i) { | 64 upload_data->element_readers(); |
| 65 if (elements[i]->type() == net::UploadElement::TYPE_BYTES) { | 65 for (size_t i = 0; i < readers.size(); ++i) { |
| 66 const net::UploadBytesElementReader* bytes_reader = |
| 67 readers[i]->AsBytesReader(); |
| 68 if (bytes_reader) { |
| 66 g_last_upload_bytes.Get() += | 69 g_last_upload_bytes.Get() += |
| 67 std::string(elements[i]->bytes(), elements[i]->bytes_length()); | 70 std::string(bytes_reader->bytes(), bytes_reader->length()); |
| 68 } | 71 } |
| 69 } | 72 } |
| 70 } | 73 } |
| 71 return new net::URLRequestTestJob( | 74 return new net::URLRequestTestJob( |
| 72 request, network_delegate, net::URLRequestTestJob::test_headers(), | 75 request, network_delegate, net::URLRequestTestJob::test_headers(), |
| 73 "<html><head><title>PASS</title></head><body>Data posted</body></html>", | 76 "<html><head><title>PASS</title></head><body>Data posted</body></html>", |
| 74 true); | 77 true); |
| 75 } | 78 } |
| 76 | 79 |
| 77 } // namespace | 80 } // namespace |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 378 |
| 376 IN_PROC_BROWSER_TEST_F(RestartTest, PRE_PostWithPassword) { | 379 IN_PROC_BROWSER_TEST_F(RestartTest, PRE_PostWithPassword) { |
| 377 PostFormWithPage("post_with_password.html", true); | 380 PostFormWithPage("post_with_password.html", true); |
| 378 Restart(); | 381 Restart(); |
| 379 } | 382 } |
| 380 | 383 |
| 381 IN_PROC_BROWSER_TEST_F(RestartTest, PostWithPassword) { | 384 IN_PROC_BROWSER_TEST_F(RestartTest, PostWithPassword) { |
| 382 // The form data contained passwords, so it's removed completely. | 385 // The form data contained passwords, so it's removed completely. |
| 383 CheckFormRestored(false, false); | 386 CheckFormRestored(false, false); |
| 384 } | 387 } |
| OLD | NEW |