| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 6 * (http://www.torchmobile.com/) | 6 * (http://www.torchmobile.com/) |
| 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
| 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. | 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. |
| 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> | 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> |
| 10 * Copyright (C) 2011 Google Inc. All rights reserved. | 10 * Copyright (C) 2011 Google Inc. All rights reserved. |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 kFrameLoadTypeReloadBypassingCache | 232 kFrameLoadTypeReloadBypassingCache |
| 233 ? WebURLRequest::ServiceWorkerMode::kNone | 233 ? WebURLRequest::ServiceWorkerMode::kNone |
| 234 : WebURLRequest::ServiceWorkerMode::kAll); | 234 : WebURLRequest::ServiceWorkerMode::kAll); |
| 235 return request; | 235 return request; |
| 236 } | 236 } |
| 237 | 237 |
| 238 FrameLoader::FrameLoader(LocalFrame* frame) | 238 FrameLoader::FrameLoader(LocalFrame* frame) |
| 239 : frame_(frame), | 239 : frame_(frame), |
| 240 progress_tracker_(ProgressTracker::Create(frame)), | 240 progress_tracker_(ProgressTracker::Create(frame)), |
| 241 in_stop_all_loaders_(false), | 241 in_stop_all_loaders_(false), |
| 242 check_timer_(TaskRunnerHelper::Get(TaskType::kNetworking, frame), |
| 243 this, |
| 244 &FrameLoader::CheckTimerFired), |
| 242 forced_sandbox_flags_(kSandboxNone), | 245 forced_sandbox_flags_(kSandboxNone), |
| 243 dispatching_did_clear_window_object_in_main_world_(false), | 246 dispatching_did_clear_window_object_in_main_world_(false), |
| 244 protect_provisional_loader_(false), | 247 protect_provisional_loader_(false), |
| 245 detached_(false) { | 248 detached_(false) { |
| 246 DCHECK(frame_); | 249 DCHECK(frame_); |
| 247 TRACE_EVENT_OBJECT_CREATED_WITH_ID("loading", "FrameLoader", this); | 250 TRACE_EVENT_OBJECT_CREATED_WITH_ID("loading", "FrameLoader", this); |
| 248 TakeObjectSnapshot(); | 251 TakeObjectSnapshot(); |
| 249 } | 252 } |
| 250 | 253 |
| 251 FrameLoader::~FrameLoader() { | 254 FrameLoader::~FrameLoader() { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 provisional_document_loader_->Fetcher()->SetDefersLoading(defers); | 296 provisional_document_loader_->Fetcher()->SetDefersLoading(defers); |
| 294 | 297 |
| 295 if (Document* document = frame_->GetDocument()) { | 298 if (Document* document = frame_->GetDocument()) { |
| 296 document->Fetcher()->SetDefersLoading(defers); | 299 document->Fetcher()->SetDefersLoading(defers); |
| 297 if (defers) | 300 if (defers) |
| 298 document->SuspendScheduledTasks(); | 301 document->SuspendScheduledTasks(); |
| 299 else | 302 else |
| 300 document->ResumeScheduledTasks(); | 303 document->ResumeScheduledTasks(); |
| 301 } | 304 } |
| 302 | 305 |
| 303 if (!defers) | 306 if (!defers) { |
| 304 frame_->GetNavigationScheduler().StartTimer(); | 307 frame_->GetNavigationScheduler().StartTimer(); |
| 308 ScheduleCheckCompleted(); |
| 309 } |
| 305 } | 310 } |
| 306 | 311 |
| 307 void FrameLoader::SaveScrollState() { | 312 void FrameLoader::SaveScrollState() { |
| 308 if (!document_loader_ || !document_loader_->GetHistoryItem() || | 313 if (!document_loader_ || !document_loader_->GetHistoryItem() || |
| 309 !frame_->View()) | 314 !frame_->View()) |
| 310 return; | 315 return; |
| 311 | 316 |
| 312 // Shouldn't clobber anything if we might still restore later. | 317 // Shouldn't clobber anything if we might still restore later. |
| 313 if (NeedsHistoryItemRestore(document_loader_->LoadType()) && | 318 if (NeedsHistoryItemRestore(document_loader_->LoadType()) && |
| 314 !document_loader_->GetInitialScrollState().was_scrolled_by_user) | 319 !document_loader_->GetInitialScrollState().was_scrolled_by_user) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 367 } |
| 363 | 368 |
| 364 void FrameLoader::Clear() { | 369 void FrameLoader::Clear() { |
| 365 // clear() is called during (Local)Frame detachment or when reusing a | 370 // clear() is called during (Local)Frame detachment or when reusing a |
| 366 // FrameLoader by putting a new Document within it | 371 // FrameLoader by putting a new Document within it |
| 367 // (DocumentLoader::ensureWriter().) | 372 // (DocumentLoader::ensureWriter().) |
| 368 if (state_machine_.CreatingInitialEmptyDocument()) | 373 if (state_machine_.CreatingInitialEmptyDocument()) |
| 369 return; | 374 return; |
| 370 | 375 |
| 371 frame_->GetEditor().Clear(); | 376 frame_->GetEditor().Clear(); |
| 377 frame_->GetDocument()->RemoveFocusedElementOfSubtree(frame_->GetDocument()); |
| 372 frame_->GetEventHandler().Clear(); | 378 frame_->GetEventHandler().Clear(); |
| 373 if (frame_->View()) | 379 if (frame_->View()) |
| 374 frame_->View()->Clear(); | 380 frame_->View()->Clear(); |
| 375 | 381 |
| 382 frame_->GetScriptController().EnableEval(); |
| 383 |
| 384 frame_->GetNavigationScheduler().Cancel(); |
| 385 |
| 386 check_timer_.Stop(); |
| 387 |
| 376 if (state_machine_.IsDisplayingInitialEmptyDocument()) | 388 if (state_machine_.IsDisplayingInitialEmptyDocument()) |
| 377 state_machine_.AdvanceTo(FrameLoaderStateMachine::kCommittedFirstRealLoad); | 389 state_machine_.AdvanceTo(FrameLoaderStateMachine::kCommittedFirstRealLoad); |
| 378 | 390 |
| 379 TakeObjectSnapshot(); | 391 TakeObjectSnapshot(); |
| 380 } | 392 } |
| 381 | 393 |
| 382 // This is only called by ScriptController::executeScriptIfJavaScriptURL and | 394 // This is only called by ScriptController::executeScriptIfJavaScriptURL and |
| 383 // always contains the result of evaluating a javascript: url. This is the | 395 // always contains the result of evaluating a javascript: url. This is the |
| 384 // <iframe src="javascript:'html'"> case. | 396 // <iframe src="javascript:'html'"> case. |
| 385 void FrameLoader::ReplaceDocumentWhileExecutingJavaScriptURL( | 397 void FrameLoader::ReplaceDocumentWhileExecutingJavaScriptURL( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 if (document_loader_) | 483 if (document_loader_) |
| 472 document_loader_->SetLoadType(kFrameLoadTypeStandard); | 484 document_loader_->SetLoadType(kFrameLoadTypeStandard); |
| 473 frame_->DomWindow()->FinishedLoading(); | 485 frame_->DomWindow()->FinishedLoading(); |
| 474 } | 486 } |
| 475 | 487 |
| 476 Frame* parent = frame_->Tree().Parent(); | 488 Frame* parent = frame_->Tree().Parent(); |
| 477 if (parent && parent->IsLocalFrame()) | 489 if (parent && parent->IsLocalFrame()) |
| 478 ToLocalFrame(parent)->GetDocument()->CheckCompleted(); | 490 ToLocalFrame(parent)->GetDocument()->CheckCompleted(); |
| 479 } | 491 } |
| 480 | 492 |
| 493 void FrameLoader::CheckTimerFired(TimerBase*) { |
| 494 if (Page* page = frame_->GetPage()) { |
| 495 if (page->Suspended()) |
| 496 return; |
| 497 } |
| 498 frame_->GetDocument()->CheckCompleted(); |
| 499 } |
| 500 |
| 501 void FrameLoader::ScheduleCheckCompleted() { |
| 502 if (!check_timer_.IsActive()) |
| 503 check_timer_.StartOneShot(0, BLINK_FROM_HERE); |
| 504 } |
| 505 |
| 481 Frame* FrameLoader::Opener() { | 506 Frame* FrameLoader::Opener() { |
| 482 return Client() ? Client()->Opener() : 0; | 507 return Client() ? Client()->Opener() : 0; |
| 483 } | 508 } |
| 484 | 509 |
| 485 void FrameLoader::SetOpener(LocalFrame* opener) { | 510 void FrameLoader::SetOpener(LocalFrame* opener) { |
| 486 // If the frame is already detached, the opener has already been cleared. | 511 // If the frame is already detached, the opener has already been cleared. |
| 487 if (Client()) | 512 if (Client()) |
| 488 Client()->SetOpener(opener); | 513 Client()->SetOpener(opener); |
| 489 } | 514 } |
| 490 | 515 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 if (child->IsLocalFrame()) | 974 if (child->IsLocalFrame()) |
| 950 ToLocalFrame(child)->Loader().StopAllLoaders(); | 975 ToLocalFrame(child)->Loader().StopAllLoaders(); |
| 951 } | 976 } |
| 952 | 977 |
| 953 frame_->GetDocument()->CancelParsing(); | 978 frame_->GetDocument()->CancelParsing(); |
| 954 if (document_loader_) | 979 if (document_loader_) |
| 955 document_loader_->Fetcher()->StopFetching(); | 980 document_loader_->Fetcher()->StopFetching(); |
| 956 if (!protect_provisional_loader_) | 981 if (!protect_provisional_loader_) |
| 957 DetachDocumentLoader(provisional_document_loader_); | 982 DetachDocumentLoader(provisional_document_loader_); |
| 958 | 983 |
| 984 check_timer_.Stop(); |
| 959 frame_->GetNavigationScheduler().Cancel(); | 985 frame_->GetNavigationScheduler().Cancel(); |
| 960 | 986 |
| 961 // It's possible that the above actions won't have stopped loading if load | 987 // It's possible that the above actions won't have stopped loading if load |
| 962 // completion had been blocked on parsing or if we were in the middle of | 988 // completion had been blocked on parsing or if we were in the middle of |
| 963 // committing an empty document. In that case, emulate a failed navigation. | 989 // committing an empty document. In that case, emulate a failed navigation. |
| 964 if (!provisional_document_loader_ && document_loader_ && | 990 if (!provisional_document_loader_ && document_loader_ && |
| 965 frame_->IsLoading()) { | 991 frame_->IsLoading()) { |
| 966 document_loader_->LoadFailed( | 992 document_loader_->LoadFailed( |
| 967 ResourceError::CancelledError(document_loader_->Url())); | 993 ResourceError::CancelledError(document_loader_->Url())); |
| 968 } | 994 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 String FrameLoader::UserAgent() const { | 1202 String FrameLoader::UserAgent() const { |
| 1177 String user_agent = Client()->UserAgent(); | 1203 String user_agent = Client()->UserAgent(); |
| 1178 probe::applyUserAgentOverride(frame_, &user_agent); | 1204 probe::applyUserAgentOverride(frame_, &user_agent); |
| 1179 return user_agent; | 1205 return user_agent; |
| 1180 } | 1206 } |
| 1181 | 1207 |
| 1182 void FrameLoader::Detach() { | 1208 void FrameLoader::Detach() { |
| 1183 DetachDocumentLoader(document_loader_); | 1209 DetachDocumentLoader(document_loader_); |
| 1184 DetachDocumentLoader(provisional_document_loader_); | 1210 DetachDocumentLoader(provisional_document_loader_); |
| 1185 | 1211 |
| 1212 Frame* parent = frame_->Tree().Parent(); |
| 1213 if (parent && parent->IsLocalFrame()) |
| 1214 ToLocalFrame(parent)->Loader().ScheduleCheckCompleted(); |
| 1186 if (progress_tracker_) { | 1215 if (progress_tracker_) { |
| 1187 progress_tracker_->Dispose(); | 1216 progress_tracker_->Dispose(); |
| 1188 progress_tracker_.Clear(); | 1217 progress_tracker_.Clear(); |
| 1189 } | 1218 } |
| 1190 | 1219 |
| 1191 TRACE_EVENT_OBJECT_DELETED_WITH_ID("loading", "FrameLoader", this); | 1220 TRACE_EVENT_OBJECT_DELETED_WITH_ID("loading", "FrameLoader", this); |
| 1192 detached_ = true; | 1221 detached_ = true; |
| 1193 } | 1222 } |
| 1194 | 1223 |
| 1195 void FrameLoader::DetachProvisionalDocumentLoader(DocumentLoader* loader) { | 1224 void FrameLoader::DetachProvisionalDocumentLoader(DocumentLoader* loader) { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1454 navigation_policy == kNavigationPolicyHandledByClient); | 1483 navigation_policy == kNavigationPolicyHandledByClient); |
| 1455 | 1484 |
| 1456 provisional_document_loader_ = CreateDocumentLoader( | 1485 provisional_document_loader_ = CreateDocumentLoader( |
| 1457 resource_request, frame_load_request, type, navigation_type); | 1486 resource_request, frame_load_request, type, navigation_type); |
| 1458 | 1487 |
| 1459 // PlzNavigate: We need to ensure that script initiated navigations are | 1488 // PlzNavigate: We need to ensure that script initiated navigations are |
| 1460 // honored. | 1489 // honored. |
| 1461 if (!had_placeholder_client_document_loader || | 1490 if (!had_placeholder_client_document_loader || |
| 1462 navigation_policy == kNavigationPolicyHandledByClient) { | 1491 navigation_policy == kNavigationPolicyHandledByClient) { |
| 1463 frame_->GetNavigationScheduler().Cancel(); | 1492 frame_->GetNavigationScheduler().Cancel(); |
| 1493 check_timer_.Stop(); |
| 1464 } | 1494 } |
| 1465 | 1495 |
| 1466 if (frame_load_request.Form()) | 1496 if (frame_load_request.Form()) |
| 1467 Client()->DispatchWillSubmitForm(frame_load_request.Form()); | 1497 Client()->DispatchWillSubmitForm(frame_load_request.Form()); |
| 1468 | 1498 |
| 1469 provisional_document_loader_->AppendRedirect( | 1499 provisional_document_loader_->AppendRedirect( |
| 1470 provisional_document_loader_->GetRequest().Url()); | 1500 provisional_document_loader_->GetRequest().Url()); |
| 1471 | 1501 |
| 1472 if (IsBackForwardLoadType(type)) { | 1502 if (IsBackForwardLoadType(type)) { |
| 1473 DCHECK(history_item); | 1503 DCHECK(history_item); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1714 // TODO(japhet): This is needed because the browser process DCHECKs if the | 1744 // TODO(japhet): This is needed because the browser process DCHECKs if the |
| 1715 // first entry we commit in a new frame has replacement set. It's unclear | 1745 // first entry we commit in a new frame has replacement set. It's unclear |
| 1716 // whether the DCHECK is right, investigate removing this special case. | 1746 // whether the DCHECK is right, investigate removing this special case. |
| 1717 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem && | 1747 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem && |
| 1718 (!Opener() || !request.Url().IsEmpty()); | 1748 (!Opener() || !request.Url().IsEmpty()); |
| 1719 loader->SetReplacesCurrentHistoryItem(replace_current_item); | 1749 loader->SetReplacesCurrentHistoryItem(replace_current_item); |
| 1720 return loader; | 1750 return loader; |
| 1721 } | 1751 } |
| 1722 | 1752 |
| 1723 } // namespace blink | 1753 } // namespace blink |
| OLD | NEW |