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 "content/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.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/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/process/kill.h" | 10 #include "base/process/kill.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_piece.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
15 #include "base/test/test_timeouts.h" | 16 #include "base/test/test_timeouts.h" |
16 #include "base/values.h" | 17 #include "base/values.h" |
17 #include "content/browser/renderer_host/render_widget_host_impl.h" | 18 #include "content/browser/renderer_host/render_widget_host_impl.h" |
18 #include "content/browser/web_contents/web_contents_impl.h" | 19 #include "content/browser/web_contents/web_contents_impl.h" |
19 #include "content/browser/web_contents/web_contents_view.h" | 20 #include "content/browser/web_contents/web_contents_view.h" |
20 #include "content/common/input/synthetic_web_input_event_builders.h" | 21 #include "content/common/input/synthetic_web_input_event_builders.h" |
21 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
22 #include "content/public/browser/dom_operation_notification_details.h" | 23 #include "content/public/browser/dom_operation_notification_details.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 234 |
234 std::string params = request.relative_url.substr(prefix.length()); | 235 std::string params = request.relative_url.substr(prefix.length()); |
235 | 236 |
236 // A hostname to redirect to must be included in the URL, therefore at least | 237 // A hostname to redirect to must be included in the URL, therefore at least |
237 // one '/' character is expected. | 238 // one '/' character is expected. |
238 size_t slash = params.find('/'); | 239 size_t slash = params.find('/'); |
239 if (slash == std::string::npos) | 240 if (slash == std::string::npos) |
240 return scoped_ptr<net::test_server::HttpResponse>(); | 241 return scoped_ptr<net::test_server::HttpResponse>(); |
241 | 242 |
242 // Replace the host of the URL with the one passed in the URL. | 243 // Replace the host of the URL with the one passed in the URL. |
243 std::string host = params.substr(0, slash); | |
244 GURL::Replacements replace_host; | 244 GURL::Replacements replace_host; |
245 replace_host.SetHostStr(host); | 245 replace_host.SetHostStr(base::StringPiece(params).substr(0, slash)); |
246 GURL redirect_server = server_base_url.ReplaceComponents(replace_host); | 246 GURL redirect_server = server_base_url.ReplaceComponents(replace_host); |
247 | 247 |
248 // Append the real part of the path to the new URL. | 248 // Append the real part of the path to the new URL. |
249 std::string path = params.substr(slash + 1); | 249 std::string path = params.substr(slash + 1); |
250 GURL redirect_target(redirect_server.Resolve(path)); | 250 GURL redirect_target(redirect_server.Resolve(path)); |
251 DCHECK(redirect_target.is_valid()); | 251 DCHECK(redirect_target.is_valid()); |
252 | 252 |
253 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 253 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
254 new net::test_server::BasicHttpResponse); | 254 new net::test_server::BasicHttpResponse); |
255 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 255 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 | 939 |
940 bool WebContentsAddedObserver::RenderViewCreatedCalled() { | 940 bool WebContentsAddedObserver::RenderViewCreatedCalled() { |
941 if (child_observer_) { | 941 if (child_observer_) { |
942 return child_observer_->render_view_created_called_ && | 942 return child_observer_->render_view_created_called_ && |
943 child_observer_->main_frame_created_called_; | 943 child_observer_->main_frame_created_called_; |
944 } | 944 } |
945 return false; | 945 return false; |
946 } | 946 } |
947 | 947 |
948 } // namespace content | 948 } // namespace content |
OLD | NEW |