| 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 28 matching lines...) Expand all Loading... |
| 39 #include "base/command_line.h" | 39 #include "base/command_line.h" |
| 40 #include "base/logging.h" | 40 #include "base/logging.h" |
| 41 #include "base/string_util.h" | 41 #include "base/string_util.h" |
| 42 #include "net/base/mime_util.h" | 42 #include "net/base/mime_util.h" |
| 43 #include "net/base/net_errors.h" | 43 #include "net/base/net_errors.h" |
| 44 #if defined(OS_WIN) | 44 #if defined(OS_WIN) |
| 45 #include "webkit/activex_shim/activex_shared.h" | 45 #include "webkit/activex_shim/activex_shared.h" |
| 46 #endif | 46 #endif |
| 47 #include "webkit/glue/autofill_form.h" | 47 #include "webkit/glue/autofill_form.h" |
| 48 #include "webkit/glue/alt_404_page_resource_fetcher.h" | 48 #include "webkit/glue/alt_404_page_resource_fetcher.h" |
| 49 #include "webkit/glue/devtools/net_agent_impl.h" | |
| 50 #include "webkit/glue/glue_util.h" | 49 #include "webkit/glue/glue_util.h" |
| 51 #include "webkit/glue/password_form_dom_manager.h" | 50 #include "webkit/glue/password_form_dom_manager.h" |
| 52 #include "webkit/glue/plugins/plugin_list.h" | 51 #include "webkit/glue/plugins/plugin_list.h" |
| 53 #include "webkit/glue/searchable_form_data.h" | 52 #include "webkit/glue/searchable_form_data.h" |
| 54 #include "webkit/glue/webappcachecontext.h" | 53 #include "webkit/glue/webappcachecontext.h" |
| 55 #include "webkit/glue/webdatasource_impl.h" | 54 #include "webkit/glue/webdatasource_impl.h" |
| 56 #include "webkit/glue/webdevtoolsagent_impl.h" | 55 #include "webkit/glue/webdevtoolsagent_impl.h" |
| 57 #include "webkit/glue/weberror_impl.h" | 56 #include "webkit/glue/weberror_impl.h" |
| 58 #include "webkit/glue/webframeloaderclient_impl.h" | 57 #include "webkit/glue/webframeloaderclient_impl.h" |
| 59 #include "webkit/glue/webkit_glue.h" | 58 #include "webkit/glue/webkit_glue.h" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 // WebFrame. | 173 // WebFrame. |
| 175 void WebFrameLoaderClient::assignIdentifierToInitialRequest( | 174 void WebFrameLoaderClient::assignIdentifierToInitialRequest( |
| 176 unsigned long identifier, DocumentLoader* loader, | 175 unsigned long identifier, DocumentLoader* loader, |
| 177 const ResourceRequest& request) { | 176 const ResourceRequest& request) { |
| 178 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 177 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 179 WebViewDelegate* d = webview->delegate(); | 178 WebViewDelegate* d = webview->delegate(); |
| 180 if (d) { | 179 if (d) { |
| 181 WebRequestImpl webreq(request); | 180 WebRequestImpl webreq(request); |
| 182 d->AssignIdentifierToRequest(webview, identifier, webreq); | 181 d->AssignIdentifierToRequest(webview, identifier, webreq); |
| 183 } | 182 } |
| 184 NetAgentImpl* net_agent = GetNetAgentImpl(); | |
| 185 if (net_agent) { | |
| 186 net_agent->AssignIdentifierToRequest(loader, identifier, request); | |
| 187 } | |
| 188 } | 183 } |
| 189 | 184 |
| 190 // Determines whether the request being loaded by |loader| is a frame or a | 185 // Determines whether the request being loaded by |loader| is a frame or a |
| 191 // subresource. A subresource in this context is anything other than a frame -- | 186 // subresource. A subresource in this context is anything other than a frame -- |
| 192 // this includes images and xmlhttp requests. It is important to note that a | 187 // this includes images and xmlhttp requests. It is important to note that a |
| 193 // subresource is NOT limited to stuff loaded through the frame's subresource | 188 // subresource is NOT limited to stuff loaded through the frame's subresource |
| 194 // loader. Synchronous xmlhttp requests for example, do not go through the | 189 // loader. Synchronous xmlhttp requests for example, do not go through the |
| 195 // subresource loader, but we still label them as TargetIsSubResource. | 190 // subresource loader, but we still label them as TargetIsSubResource. |
| 196 // | 191 // |
| 197 // The important edge cases to consider when modifying this function are | 192 // The important edge cases to consider when modifying this function are |
| (...skipping 28 matching lines...) Expand all Loading... |
| 226 request.setFirstPartyForCookies(KURL("about:blank")); | 221 request.setFirstPartyForCookies(KURL("about:blank")); |
| 227 | 222 |
| 228 // Give the delegate a crack at the request. | 223 // Give the delegate a crack at the request. |
| 229 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 224 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 230 WebViewDelegate* d = webview->delegate(); | 225 WebViewDelegate* d = webview->delegate(); |
| 231 if (d) { | 226 if (d) { |
| 232 WebRequestImpl webreq(request); | 227 WebRequestImpl webreq(request); |
| 233 d->WillSendRequest(webview, identifier, &webreq); | 228 d->WillSendRequest(webview, identifier, &webreq); |
| 234 request = webreq.resource_request(); | 229 request = webreq.resource_request(); |
| 235 } | 230 } |
| 236 NetAgentImpl* net_agent = GetNetAgentImpl(); | |
| 237 if (net_agent) { | |
| 238 net_agent->WillSendRequest(loader, identifier, request); | |
| 239 } | |
| 240 | 231 |
| 241 request.setAppCacheContextID( | 232 request.setAppCacheContextID( |
| 242 webframe_->GetAppCacheContext()->GetContextID()); | 233 webframe_->GetAppCacheContext()->GetContextID()); |
| 243 } | 234 } |
| 244 | 235 |
| 245 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, | 236 bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, |
| 246 unsigned long identifier) { | 237 unsigned long identifier) { |
| 247 // FIXME | 238 // FIXME |
| 248 // Intended to pass through to a method on the resource load delegate. | 239 // Intended to pass through to a method on the resource load delegate. |
| 249 // If implemented, that method controls whether the browser should ask the | 240 // If implemented, that method controls whether the browser should ask the |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 postpone_loading_data_ = | 288 postpone_loading_data_ = |
| 298 ResourceRequest::TargetIsMainFrame == target_type && | 289 ResourceRequest::TargetIsMainFrame == target_type && |
| 299 !is_substitute_data && | 290 !is_substitute_data && |
| 300 response.httpStatusCode() == 404 && | 291 response.httpStatusCode() == 404 && |
| 301 GetAlt404PageUrl(loader).is_valid(); | 292 GetAlt404PageUrl(loader).is_valid(); |
| 302 if (postpone_loading_data_) | 293 if (postpone_loading_data_) |
| 303 postponed_data_.clear(); | 294 postponed_data_.clear(); |
| 304 | 295 |
| 305 // Cancel any pending loads. | 296 // Cancel any pending loads. |
| 306 alt_404_page_fetcher_.reset(NULL); | 297 alt_404_page_fetcher_.reset(NULL); |
| 307 | |
| 308 NetAgentImpl* net_agent = GetNetAgentImpl(); | |
| 309 if (net_agent) { | |
| 310 net_agent->DidReceiveResponse(loader, identifier, response); | |
| 311 } | |
| 312 } | 298 } |
| 313 | 299 |
| 314 void WebFrameLoaderClient::dispatchDidReceiveContentLength( | 300 void WebFrameLoaderClient::dispatchDidReceiveContentLength( |
| 315 DocumentLoader* loader, | 301 DocumentLoader* loader, |
| 316 unsigned long identifier, | 302 unsigned long identifier, |
| 317 int length_received) { | 303 int length_received) { |
| 318 NetAgentImpl* net_agent = GetNetAgentImpl(); | |
| 319 if (net_agent) { | |
| 320 net_agent->DidReceiveContentLength(loader, identifier, length_received); | |
| 321 } | |
| 322 } | 304 } |
| 323 | 305 |
| 324 // Called when a particular resource load completes | 306 // Called when a particular resource load completes |
| 325 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, | 307 void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader* loader, |
| 326 unsigned long identifier) { | 308 unsigned long identifier) { |
| 327 if (postpone_loading_data_) { | 309 if (postpone_loading_data_) { |
| 328 // The server returned a 404 and the content was < 512 bytes (which we | 310 // The server returned a 404 and the content was < 512 bytes (which we |
| 329 // suppressed). Go ahead and fetch the alternate page content. | 311 // suppressed). Go ahead and fetch the alternate page content. |
| 330 const GURL& url = GetAlt404PageUrl(loader); | 312 const GURL& url = GetAlt404PageUrl(loader); |
| 331 DCHECK(url.is_valid()) << | 313 DCHECK(url.is_valid()) << |
| 332 "URL changed? It was valid in dispatchDidReceiveResponse."; | 314 "URL changed? It was valid in dispatchDidReceiveResponse."; |
| 333 alt_404_page_fetcher_.reset(new Alt404PageResourceFetcher(this, | 315 alt_404_page_fetcher_.reset(new Alt404PageResourceFetcher(this, |
| 334 webframe_->frame(), loader, url)); | 316 webframe_->frame(), loader, url)); |
| 335 } | 317 } |
| 336 | 318 |
| 337 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 319 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 338 WebViewDelegate* d = webview->delegate(); | 320 WebViewDelegate* d = webview->delegate(); |
| 339 if (d) | 321 if (d) |
| 340 d->DidFinishLoading(webview, identifier); | 322 d->DidFinishLoading(webview, identifier); |
| 341 | |
| 342 NetAgentImpl* net_agent = GetNetAgentImpl(); | |
| 343 if (net_agent) { | |
| 344 net_agent->DidFinishLoading(loader, identifier); | |
| 345 } | |
| 346 } | 323 } |
| 347 | 324 |
| 348 GURL WebFrameLoaderClient::GetAlt404PageUrl(DocumentLoader* loader) { | 325 GURL WebFrameLoaderClient::GetAlt404PageUrl(DocumentLoader* loader) { |
| 349 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 326 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 350 WebViewDelegate* d = webview->delegate(); | 327 WebViewDelegate* d = webview->delegate(); |
| 351 if (!d) | 328 if (!d) |
| 352 return GURL(); | 329 return GURL(); |
| 353 | 330 |
| 354 const GURL& failedURL = webkit_glue::KURLToGURL(loader->url()); | 331 const GURL& failedURL = webkit_glue::KURLToGURL(loader->url()); |
| 355 | 332 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 377 } | 354 } |
| 378 | 355 |
| 379 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, | 356 void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, |
| 380 unsigned long identifier, | 357 unsigned long identifier, |
| 381 const ResourceError& error) { | 358 const ResourceError& error) { |
| 382 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 359 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 383 if (webview && webview->delegate()) { | 360 if (webview && webview->delegate()) { |
| 384 webview->delegate()->DidFailLoadingWithError(webview, identifier, | 361 webview->delegate()->DidFailLoadingWithError(webview, identifier, |
| 385 WebErrorImpl(error)); | 362 WebErrorImpl(error)); |
| 386 } | 363 } |
| 387 NetAgentImpl* net_agent = GetNetAgentImpl(); | |
| 388 if (net_agent) { | |
| 389 net_agent->DidFailLoading(loader, identifier, error); | |
| 390 } | |
| 391 } | 364 } |
| 392 | 365 |
| 393 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { | 366 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad() { |
| 394 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 367 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 395 WebViewDelegate* d = webview->delegate(); | 368 WebViewDelegate* d = webview->delegate(); |
| 396 DocumentLoader* documentLoader = | 369 DocumentLoader* documentLoader = |
| 397 webframe_->frame()->loader()->activeDocumentLoader(); | 370 webframe_->frame()->loader()->activeDocumentLoader(); |
| 398 WebDataSourceImpl* data_source = | 371 WebDataSourceImpl* data_source = |
| 399 WebDataSourceImpl::FromLoader(documentLoader); | 372 WebDataSourceImpl::FromLoader(documentLoader); |
| 400 | 373 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 417 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 445 WebViewDelegate* d = webview->delegate(); | 418 WebViewDelegate* d = webview->delegate(); |
| 446 | 419 |
| 447 bool result = false; | 420 bool result = false; |
| 448 if (d) { | 421 if (d) { |
| 449 WebRequestImpl webreq(request); | 422 WebRequestImpl webreq(request); |
| 450 WebResponseImpl webresp(response); | 423 WebResponseImpl webresp(response); |
| 451 result = d->DidLoadResourceFromMemoryCache(webview, webreq, webresp, | 424 result = d->DidLoadResourceFromMemoryCache(webview, webreq, webresp, |
| 452 webframe_); | 425 webframe_); |
| 453 } | 426 } |
| 454 NetAgentImpl* net_agent = GetNetAgentImpl(); | |
| 455 if (net_agent) { | |
| 456 net_agent->DidLoadResourceFromMemoryCache( | |
| 457 loader, | |
| 458 request, | |
| 459 response, | |
| 460 length); | |
| 461 } | |
| 462 return result; | 427 return result; |
| 463 } | 428 } |
| 464 | 429 |
| 465 void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest( | 430 void WebFrameLoaderClient::dispatchDidLoadResourceByXMLHttpRequest( |
| 466 unsigned long identifier, | 431 unsigned long identifier, |
| 467 const ScriptString& source) { | 432 const ScriptString& source) { |
| 468 NetAgentImpl* net_agent = GetNetAgentImpl(); | |
| 469 if (net_agent) { | |
| 470 net_agent->DidLoadResourceByXMLHttpRequest( | |
| 471 identifier, | |
| 472 source); | |
| 473 } | |
| 474 } | 433 } |
| 475 | 434 |
| 476 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() { | 435 void WebFrameLoaderClient::dispatchDidHandleOnloadEvents() { |
| 477 // During the onload event of a subframe, the subframe can be removed. In | 436 // During the onload event of a subframe, the subframe can be removed. In |
| 478 // that case, it has no page. This is covered by | 437 // that case, it has no page. This is covered by |
| 479 // LayoutTests/fast/dom/replaceChild.html | 438 // LayoutTests/fast/dom/replaceChild.html |
| 480 if (!webframe_->frame()->page()) | 439 if (!webframe_->frame()->page()) |
| 481 return; | 440 return; |
| 482 WebViewImpl* webview = webframe_->GetWebViewImpl(); | 441 WebViewImpl* webview = webframe_->GetWebViewImpl(); |
| 483 WebViewDelegate* d = webview->delegate(); | 442 WebViewDelegate* d = webview->delegate(); |
| (...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 | 1595 |
| 1637 std::string offset_str = url.ExtractFileName(); | 1596 std::string offset_str = url.ExtractFileName(); |
| 1638 int offset; | 1597 int offset; |
| 1639 if (!StringToInt(offset_str, &offset)) | 1598 if (!StringToInt(offset_str, &offset)) |
| 1640 return; | 1599 return; |
| 1641 | 1600 |
| 1642 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); | 1601 WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); |
| 1643 if (d) | 1602 if (d) |
| 1644 d->NavigateBackForwardSoon(offset); | 1603 d->NavigateBackForwardSoon(offset); |
| 1645 } | 1604 } |
| 1646 | |
| 1647 NetAgentImpl* WebFrameLoaderClient::GetNetAgentImpl() { | |
| 1648 WebViewImpl* web_view = webframe_->GetWebViewImpl(); | |
| 1649 if (!web_view) { | |
| 1650 return NULL; | |
| 1651 } | |
| 1652 WebDevToolsAgentImpl* tools_agent = web_view->GetWebDevToolsAgentImpl(); | |
| 1653 if (tools_agent) { | |
| 1654 return tools_agent->net_agent_impl(); | |
| 1655 } else { | |
| 1656 return NULL; | |
| 1657 } | |
| 1658 } | |
| OLD | NEW |