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 "base/command_line.h" |
7 #include "content/browser/loader/cross_site_resource_handler.h" | 7 #include "content/browser/loader/cross_site_resource_handler.h" |
8 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 8 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
9 #include "content/browser/loader/resource_request_info_impl.h" | 9 #include "content/browser/loader/resource_request_info_impl.h" |
10 #include "content/browser/transition_request_manager.h" | 10 #include "content/browser/transition_request_manager.h" |
11 #include "content/browser/web_contents/web_contents_impl.h" | 11 #include "content/browser/web_contents/web_contents_impl.h" |
12 #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" | 13 #include "content/public/common/content_switches.h" |
14 #include "content/public/test/browser_test_utils.h" | 14 #include "content/public/test/browser_test_utils.h" |
15 #include "content/public/test/content_browser_test.h" | 15 #include "content/public/test/content_browser_test.h" |
16 #include "content/public/test/content_browser_test_utils.h" | 16 #include "content/public/test/content_browser_test_utils.h" |
17 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
18 #include "content/shell/browser/shell.h" | 18 #include "content/shell/browser/shell.h" |
19 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" | 19 #include "content/shell/browser/shell_resource_dispatcher_host_delegate.h" |
20 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
21 #include "net/url_request/url_request.h" | 21 #include "net/url_request/url_request.h" |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 class TransitionBrowserTest : public ContentBrowserTest { | 25 class TransitionBrowserTest : public ContentBrowserTest { |
26 public: | 26 public: |
27 TransitionBrowserTest() {} | 27 TransitionBrowserTest() {} |
28 | 28 |
29 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 29 virtual void SetUpCommandLine(CommandLine* command_line) override { |
30 command_line->AppendSwitch( | 30 command_line->AppendSwitch( |
31 switches::kEnableExperimentalWebPlatformFeatures); | 31 switches::kEnableExperimentalWebPlatformFeatures); |
32 } | 32 } |
33 | 33 |
34 private: | 34 private: |
35 DISALLOW_COPY_AND_ASSIGN(TransitionBrowserTest); | 35 DISALLOW_COPY_AND_ASSIGN(TransitionBrowserTest); |
36 }; | 36 }; |
37 | 37 |
38 class TransitionBrowserTestObserver | 38 class TransitionBrowserTestObserver |
39 : public WebContentsObserver, | 39 : public WebContentsObserver, |
40 public ShellResourceDispatcherHostDelegate { | 40 public ShellResourceDispatcherHostDelegate { |
41 public: | 41 public: |
42 TransitionBrowserTestObserver(WebContents* web_contents) | 42 TransitionBrowserTestObserver(WebContents* web_contents) |
43 : WebContentsObserver(web_contents), | 43 : WebContentsObserver(web_contents), |
44 request_(NULL), | 44 request_(NULL), |
45 did_defer_response_(false), | 45 did_defer_response_(false), |
46 is_transition_request_(false) { | 46 is_transition_request_(false) { |
47 } | 47 } |
48 | 48 |
49 virtual void RequestBeginning( | 49 virtual void RequestBeginning( |
50 net::URLRequest* request, | 50 net::URLRequest* request, |
51 ResourceContext* resource_context, | 51 ResourceContext* resource_context, |
52 AppCacheService* appcache_service, | 52 AppCacheService* appcache_service, |
53 ResourceType resource_type, | 53 ResourceType resource_type, |
54 ScopedVector<ResourceThrottle>* throttles) OVERRIDE { | 54 ScopedVector<ResourceThrottle>* throttles) override { |
55 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 55 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
56 ShellResourceDispatcherHostDelegate::RequestBeginning(request, | 56 ShellResourceDispatcherHostDelegate::RequestBeginning(request, |
57 resource_context, | 57 resource_context, |
58 appcache_service, | 58 appcache_service, |
59 resource_type, | 59 resource_type, |
60 throttles); | 60 throttles); |
61 request_ = request; | 61 request_ = request; |
62 | 62 |
63 ResourceRequestInfoImpl* info = | 63 ResourceRequestInfoImpl* info = |
64 ResourceRequestInfoImpl::ForRequest(request_); | 64 ResourceRequestInfoImpl::ForRequest(request_); |
65 | 65 |
66 if (is_transition_request_) { | 66 if (is_transition_request_) { |
67 TransitionRequestManager::GetInstance()->AddPendingTransitionRequestData( | 67 TransitionRequestManager::GetInstance()->AddPendingTransitionRequestData( |
68 info->GetChildID(), info->GetRenderFrameID(), "*", "", ""); | 68 info->GetChildID(), info->GetRenderFrameID(), "*", "", ""); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 virtual void OnResponseStarted( | 72 virtual void OnResponseStarted( |
73 net::URLRequest* request, | 73 net::URLRequest* request, |
74 ResourceContext* resource_context, | 74 ResourceContext* resource_context, |
75 ResourceResponse* response, | 75 ResourceResponse* response, |
76 IPC::Sender* sender) OVERRIDE { | 76 IPC::Sender* sender) override { |
77 ResourceRequestInfoImpl* info = | 77 ResourceRequestInfoImpl* info = |
78 ResourceRequestInfoImpl::ForRequest(request_); | 78 ResourceRequestInfoImpl::ForRequest(request_); |
79 | 79 |
80 did_defer_response_ = info->cross_site_handler()->did_defer_for_testing(); | 80 did_defer_response_ = info->cross_site_handler()->did_defer_for_testing(); |
81 } | 81 } |
82 | 82 |
83 void set_pending_transition_request(bool is_transition_request) { | 83 void set_pending_transition_request(bool is_transition_request) { |
84 is_transition_request_ = is_transition_request; | 84 is_transition_request_ = is_transition_request; |
85 } | 85 } |
86 | 86 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 WaitForLoadStop(transition_web_contents.get()); | 152 WaitForLoadStop(transition_web_contents.get()); |
153 | 153 |
154 int transition_process_id = | 154 int transition_process_id = |
155 transition_web_contents->GetRenderProcessHost()->GetID(); | 155 transition_web_contents->GetRenderProcessHost()->GetID(); |
156 | 156 |
157 EXPECT_EQ(outgoing_process_id, transition_process_id); | 157 EXPECT_EQ(outgoing_process_id, transition_process_id); |
158 } | 158 } |
159 | 159 |
160 } // namespace content | 160 } // namespace content |
OLD | NEW |