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