| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/loader/cross_site_resource_handler.h" | 7 #include "content/browser/loader/cross_site_resource_handler.h" |
| 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 8 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
| 8 #include "content/browser/loader/resource_request_info_impl.h" | 9 #include "content/browser/loader/resource_request_info_impl.h" |
| 9 #include "content/browser/transition_request_manager.h" | 10 #include "content/browser/transition_request_manager.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 11 #include "content/browser/web_contents/web_contents_impl.h" |
| 11 #include "content/public/browser/web_contents_observer.h" | 12 #include "content/public/browser/web_contents_observer.h" |
| 13 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
| 13 #include "content/public/test/content_browser_test.h" | 15 #include "content/public/test/content_browser_test.h" |
| 14 #include "content/public/test/content_browser_test_utils.h" | 16 #include "content/public/test/content_browser_test_utils.h" |
| 15 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
| 16 #include "content/shell/browser/shell.h" | 18 #include "content/shell/browser/shell.h" |
| 17 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 19 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
| 18 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 19 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
| 20 | 22 |
| 21 namespace content { | 23 namespace content { |
| 22 | 24 |
| 23 class TransitionBrowserTest : public ContentBrowserTest { | 25 class TransitionBrowserTest : public ContentBrowserTest { |
| 24 public: | 26 public: |
| 25 TransitionBrowserTest() {} | 27 TransitionBrowserTest() {} |
| 26 | 28 |
| 29 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 30 command_line->AppendSwitch( |
| 31 switches::kEnableExperimentalWebPlatformFeatures); |
| 32 } |
| 33 |
| 27 private: | 34 private: |
| 28 DISALLOW_COPY_AND_ASSIGN(TransitionBrowserTest); | 35 DISALLOW_COPY_AND_ASSIGN(TransitionBrowserTest); |
| 29 }; | 36 }; |
| 30 | 37 |
| 31 class TransitionBrowserTestObserver | 38 class TransitionBrowserTestObserver |
| 32 : public WebContentsObserver, | 39 : public WebContentsObserver, |
| 33 public ShellResourceDispatcherHostDelegate { | 40 public ShellResourceDispatcherHostDelegate { |
| 34 public: | 41 public: |
| 35 TransitionBrowserTestObserver(WebContents* web_contents) | 42 TransitionBrowserTestObserver(WebContents* web_contents) |
| 36 : WebContentsObserver(web_contents), | 43 : WebContentsObserver(web_contents), |
| (...skipping 16 matching lines...) Expand all Loading... |
| 53 appcache_service, | 60 appcache_service, |
| 54 resource_type, | 61 resource_type, |
| 55 child_id, | 62 child_id, |
| 56 route_id, | 63 route_id, |
| 57 throttles); | 64 throttles); |
| 58 request_ = request; | 65 request_ = request; |
| 59 | 66 |
| 60 ResourceRequestInfoImpl* info = | 67 ResourceRequestInfoImpl* info = |
| 61 ResourceRequestInfoImpl::ForRequest(request_); | 68 ResourceRequestInfoImpl::ForRequest(request_); |
| 62 | 69 |
| 63 TransitionRequestManager::GetInstance()->SetHasPendingTransitionRequest( | 70 if (is_transition_request_) { |
| 64 child_id, info->GetRenderFrameID(), is_transition_request_); | 71 TransitionRequestManager::GetInstance()->AddPendingTransitionRequestData( |
| 72 child_id, info->GetRenderFrameID(), "*", "", ""); |
| 73 } |
| 65 } | 74 } |
| 66 | 75 |
| 67 virtual void OnResponseStarted( | 76 virtual void OnResponseStarted( |
| 68 net::URLRequest* request, | 77 net::URLRequest* request, |
| 69 ResourceContext* resource_context, | 78 ResourceContext* resource_context, |
| 70 ResourceResponse* response, | 79 ResourceResponse* response, |
| 71 IPC::Sender* sender) OVERRIDE { | 80 IPC::Sender* sender) OVERRIDE { |
| 72 ResourceRequestInfoImpl* info = | 81 ResourceRequestInfoImpl* info = |
| 73 ResourceRequestInfoImpl::ForRequest(request_); | 82 ResourceRequestInfoImpl::ForRequest(request_); |
| 74 | 83 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 149 |
| 141 WaitForLoadStop(transition_web_contents.get()); | 150 WaitForLoadStop(transition_web_contents.get()); |
| 142 | 151 |
| 143 int transition_process_id = | 152 int transition_process_id = |
| 144 transition_web_contents->GetRenderProcessHost()->GetID(); | 153 transition_web_contents->GetRenderProcessHost()->GetID(); |
| 145 | 154 |
| 146 EXPECT_EQ(outgoing_process_id, transition_process_id); | 155 EXPECT_EQ(outgoing_process_id, transition_process_id); |
| 147 } | 156 } |
| 148 | 157 |
| 149 } // namespace content | 158 } // namespace content |
| OLD | NEW |