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/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
8 #include "content/public/browser/navigation_entry.h" | 8 #include "content/public/browser/navigation_entry.h" |
9 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 9 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
10 #include "content/public/browser/resource_throttle.h" | 10 #include "content/public/browser/resource_throttle.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 137 |
138 DISALLOW_COPY_AND_ASSIGN(TrackingResourceDispatcherHostDelegate); | 138 DISALLOW_COPY_AND_ASSIGN(TrackingResourceDispatcherHostDelegate); |
139 }; | 139 }; |
140 | 140 |
141 // WebContentsDelegate that fails to open a URL when there's a request that | 141 // WebContentsDelegate that fails to open a URL when there's a request that |
142 // needs to be transferred between renderers. | 142 // needs to be transferred between renderers. |
143 class NoTransferRequestDelegate : public WebContentsDelegate { | 143 class NoTransferRequestDelegate : public WebContentsDelegate { |
144 public: | 144 public: |
145 NoTransferRequestDelegate() {} | 145 NoTransferRequestDelegate() {} |
146 | 146 |
147 WebContents* OpenURLFromTab(WebContents* source, | 147 bool ShouldTransferNavigation() override { |
148 const OpenURLParams& params) override { | 148 // Intentionally cancel the transfer. |
149 bool is_transfer = | 149 return false; |
150 (params.transferred_global_request_id != GlobalRequestID()); | |
151 if (is_transfer) | |
152 return nullptr; | |
153 NavigationController::LoadURLParams load_url_params(params.url); | |
154 load_url_params.referrer = params.referrer; | |
155 load_url_params.frame_tree_node_id = params.frame_tree_node_id; | |
156 load_url_params.transition_type = params.transition; | |
157 load_url_params.extra_headers = params.extra_headers; | |
158 load_url_params.should_replace_current_entry = | |
159 params.should_replace_current_entry; | |
160 load_url_params.is_renderer_initiated = true; | |
161 source->GetController().LoadURLWithParams(load_url_params); | |
162 return source; | |
163 } | 150 } |
164 | 151 |
165 private: | 152 private: |
166 DISALLOW_COPY_AND_ASSIGN(NoTransferRequestDelegate); | 153 DISALLOW_COPY_AND_ASSIGN(NoTransferRequestDelegate); |
167 }; | 154 }; |
168 | 155 |
169 class CrossSiteTransferTest : public ContentBrowserTest { | 156 class CrossSiteTransferTest : public ContentBrowserTest { |
170 public: | 157 public: |
171 CrossSiteTransferTest() : old_delegate_(nullptr) {} | 158 CrossSiteTransferTest() : old_delegate_(nullptr) {} |
172 | 159 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); | 411 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); |
425 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); | 412 EXPECT_EQ(url1, controller.GetEntryAtIndex(0)->GetURL()); |
426 | 413 |
427 // Make sure the request for url2 did not complete. | 414 // Make sure the request for url2 did not complete. |
428 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); | 415 EXPECT_FALSE(tracking_delegate().WaitForTrackedURLAndGetCompleted()); |
429 | 416 |
430 shell()->web_contents()->SetDelegate(old_delegate); | 417 shell()->web_contents()->SetDelegate(old_delegate); |
431 } | 418 } |
432 | 419 |
433 } // namespace content | 420 } // namespace content |
OLD | NEW |