OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "config.h" | 5 #include "config.h" |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 | 10 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 } else { | 182 } else { |
183 return ResourceRequest::TargetIsSubFrame; | 183 return ResourceRequest::TargetIsSubFrame; |
184 } | 184 } |
185 } | 185 } |
186 return ResourceRequest::TargetIsSubResource; | 186 return ResourceRequest::TargetIsSubResource; |
187 } | 187 } |
188 | 188 |
189 void WebFrameLoaderClient::dispatchWillSendRequest( | 189 void WebFrameLoaderClient::dispatchWillSendRequest( |
190 DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, | 190 DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, |
191 const ResourceResponse& redirectResponse) { | 191 const ResourceResponse& redirectResponse) { |
192 // We set the Frame on the ResourceRequest to provide load context to the | |
193 // ResourceHandle implementation. | |
194 request.setFrame(webframe_->frame()); | |
195 | 192 |
196 // We want to distinguish between a request for a document to be loaded into | 193 if (loader) { |
197 // the main frame, a sub-frame, or the sub-objects in that document. | 194 // We want to distinguish between a request for a document to be loaded into |
198 request.setTargetType(DetermineTargetTypeFromLoader(loader)); | 195 // the main frame, a sub-frame, or the sub-objects in that document. |
| 196 request.setTargetType(DetermineTargetTypeFromLoader(loader)); |
| 197 } |
| 198 |
| 199 // Inherit the policy URL from the request's frame. However, if the request |
| 200 // is for a main frame, the current document's policyBaseURL is the old |
| 201 // document, so we leave policyURL empty to indicate that the request is a |
| 202 // first-party request. |
| 203 if (request.targetType() != ResourceRequest::TargetIsMainFrame && |
| 204 webframe_->frame()->document()) { |
| 205 request.setPolicyURL(webframe_->frame()->document()->policyBaseURL()); |
| 206 } |
199 | 207 |
200 // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document | 208 // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document |
201 // with no URL. We don't like that, so we'll rename it to about:blank. | 209 // with no URL. We don't like that, so we'll rename it to about:blank. |
202 if (request.url().isEmpty()) | 210 if (request.url().isEmpty()) |
203 request.setURL(KURL("about:blank")); | 211 request.setURL(KURL("about:blank")); |
204 if (request.mainDocumentURL().isEmpty()) | 212 if (request.mainDocumentURL().isEmpty()) |
205 request.setMainDocumentURL(KURL("about:blank")); | 213 request.setMainDocumentURL(KURL("about:blank")); |
206 | 214 |
207 // Give the delegate a crack at the request. | 215 // Give the delegate a crack at the request. |
208 WebViewImpl* webview = webframe_->webview_impl(); | 216 WebViewImpl* webview = webframe_->webview_impl(); |
(...skipping 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 if (!middle_or_ctrl && !shift && !alt) | 1521 if (!middle_or_ctrl && !shift && !alt) |
1514 return false; | 1522 return false; |
1515 | 1523 |
1516 DCHECK(disposition); | 1524 DCHECK(disposition); |
1517 if (middle_or_ctrl) | 1525 if (middle_or_ctrl) |
1518 *disposition = shift ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; | 1526 *disposition = shift ? NEW_FOREGROUND_TAB : NEW_BACKGROUND_TAB; |
1519 else | 1527 else |
1520 *disposition = shift ? NEW_WINDOW : SAVE_TO_DISK; | 1528 *disposition = shift ? NEW_WINDOW : SAVE_TO_DISK; |
1521 return true; | 1529 return true; |
1522 } | 1530 } |
OLD | NEW |