| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Convenience helper for frame tree helpers in FrameClient to reduce the amount | 117 // Convenience helper for frame tree helpers in FrameClient to reduce the amount |
| 118 // of null-checking boilerplate code. Since the frame tree is maintained in the | 118 // of null-checking boilerplate code. Since the frame tree is maintained in the |
| 119 // web/ layer, the frame tree helpers often have to deal with null WebFrames: | 119 // web/ layer, the frame tree helpers often have to deal with null WebFrames: |
| 120 // for example, a frame with no parent will return null for WebFrame::parent(). | 120 // for example, a frame with no parent will return null for WebFrame::parent(). |
| 121 // TODO(dcheng): Remove duplication between LocalFrameClientImpl and | 121 // TODO(dcheng): Remove duplication between LocalFrameClientImpl and |
| 122 // RemoteFrameClientImpl somehow... | 122 // RemoteFrameClientImpl somehow... |
| 123 Frame* ToCoreFrame(WebFrame* frame) { | 123 Frame* ToCoreFrame(WebFrame* frame) { |
| 124 return frame ? WebFrame::ToCoreFrame(*frame) : nullptr; | 124 return frame ? WebFrame::ToCoreFrame(*frame) : nullptr; |
| 125 } | 125 } |
| 126 | 126 |
| 127 // Return the parent of |frame| as a LocalFrame, nullptr when there is no |
| 128 // parent or when the parent is a remote frame. |
| 129 LocalFrame* GetLocalParentFrame(WebLocalFrameImpl* frame) { |
| 130 WebFrame* parent = frame->Parent(); |
| 131 if (!parent || !parent->IsWebLocalFrame()) |
| 132 return nullptr; |
| 133 |
| 134 return ToWebLocalFrameImpl(parent)->GetFrame(); |
| 135 } |
| 136 |
| 137 // Returns whether the |local_frame| has been loaded using an MHTMLArchive. When |
| 138 // it is the case, each subframe must use it for loading. |
| 139 bool IsLoadedAsMHTMLArchive(LocalFrame* local_frame) { |
| 140 return local_frame && local_frame->GetDocument()->Fetcher()->Archive(); |
| 141 } |
| 142 |
| 143 // Returns whether the |local_frame| is in a middle of a back/forward |
| 144 // navigation. |
| 145 bool IsBackForwardNavigationInProgress(LocalFrame* local_frame) { |
| 146 return local_frame && |
| 147 IsBackForwardLoadType( |
| 148 local_frame->Loader().GetDocumentLoader()->LoadType()) && |
| 149 !local_frame->GetDocument()->LoadEventFinished(); |
| 150 } |
| 151 |
| 127 } // namespace | 152 } // namespace |
| 128 | 153 |
| 129 LocalFrameClientImpl::LocalFrameClientImpl(WebLocalFrameImpl* frame) | 154 LocalFrameClientImpl::LocalFrameClientImpl(WebLocalFrameImpl* frame) |
| 130 : web_frame_(frame) {} | 155 : web_frame_(frame) {} |
| 131 | 156 |
| 132 LocalFrameClientImpl* LocalFrameClientImpl::Create(WebLocalFrameImpl* frame) { | 157 LocalFrameClientImpl* LocalFrameClientImpl::Create(WebLocalFrameImpl* frame) { |
| 133 return new LocalFrameClientImpl(frame); | 158 return new LocalFrameClientImpl(frame); |
| 134 } | 159 } |
| 135 | 160 |
| 136 LocalFrameClientImpl::~LocalFrameClientImpl() {} | 161 LocalFrameClientImpl::~LocalFrameClientImpl() {} |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 if (!web_frame_->Client()) | 501 if (!web_frame_->Client()) |
| 477 return kNavigationPolicyIgnore; | 502 return kNavigationPolicyIgnore; |
| 478 | 503 |
| 479 if (policy == kNavigationPolicyNewBackgroundTab && | 504 if (policy == kNavigationPolicyNewBackgroundTab && |
| 480 !AllowCreatingBackgroundTabs() && | 505 !AllowCreatingBackgroundTabs() && |
| 481 !UIEventWithKeyState::NewTabModifierSetFromIsolatedWorld()) | 506 !UIEventWithKeyState::NewTabModifierSetFromIsolatedWorld()) |
| 482 policy = kNavigationPolicyNewForegroundTab; | 507 policy = kNavigationPolicyNewForegroundTab; |
| 483 | 508 |
| 484 WebDataSourceImpl* ds = WebDataSourceImpl::FromDocumentLoader(loader); | 509 WebDataSourceImpl* ds = WebDataSourceImpl::FromDocumentLoader(loader); |
| 485 | 510 |
| 486 // Newly created child frames may need to be navigated to a history item | |
| 487 // during a back/forward navigation. This will only happen when the parent | |
| 488 // is a LocalFrame doing a back/forward navigation that has not completed. | |
| 489 // (If the load has completed and the parent later adds a frame with script, | |
| 490 // we do not want to use a history item for it.) | |
| 491 bool is_history_navigation_in_new_child_frame = | |
| 492 web_frame_->Parent() && web_frame_->Parent()->IsWebLocalFrame() && | |
| 493 IsBackForwardLoadType(ToWebLocalFrameImpl(web_frame_->Parent()) | |
| 494 ->GetFrame() | |
| 495 ->Loader() | |
| 496 .GetDocumentLoader() | |
| 497 ->LoadType()) && | |
| 498 !ToWebLocalFrameImpl(web_frame_->Parent()) | |
| 499 ->GetFrame() | |
| 500 ->GetDocument() | |
| 501 ->LoadEventFinished(); | |
| 502 | |
| 503 WrappedResourceRequest wrapped_resource_request(request); | 511 WrappedResourceRequest wrapped_resource_request(request); |
| 504 WebFrameClient::NavigationPolicyInfo navigation_info( | 512 WebFrameClient::NavigationPolicyInfo navigation_info( |
| 505 wrapped_resource_request); | 513 wrapped_resource_request); |
| 506 navigation_info.navigation_type = static_cast<WebNavigationType>(type); | 514 navigation_info.navigation_type = static_cast<WebNavigationType>(type); |
| 507 navigation_info.default_policy = static_cast<WebNavigationPolicy>(policy); | 515 navigation_info.default_policy = static_cast<WebNavigationPolicy>(policy); |
| 508 navigation_info.extra_data = ds ? ds->GetExtraData() : nullptr; | 516 navigation_info.extra_data = ds ? ds->GetExtraData() : nullptr; |
| 509 navigation_info.replaces_current_history_item = replaces_current_history_item; | 517 navigation_info.replaces_current_history_item = replaces_current_history_item; |
| 510 navigation_info.is_history_navigation_in_new_child_frame = | |
| 511 is_history_navigation_in_new_child_frame; | |
| 512 navigation_info.is_client_redirect = is_client_redirect; | 518 navigation_info.is_client_redirect = is_client_redirect; |
| 513 navigation_info.should_check_main_world_content_security_policy = | 519 navigation_info.should_check_main_world_content_security_policy = |
| 514 should_check_main_world_content_security_policy == | 520 should_check_main_world_content_security_policy == |
| 515 kCheckContentSecurityPolicy | 521 kCheckContentSecurityPolicy |
| 516 ? kWebContentSecurityPolicyDispositionCheck | 522 ? kWebContentSecurityPolicyDispositionCheck |
| 517 : kWebContentSecurityPolicyDispositionDoNotCheck; | 523 : kWebContentSecurityPolicyDispositionDoNotCheck; |
| 518 | 524 |
| 519 if (IsLoadedAsMHTMLArchive()) { | 525 // Can be null. |
| 520 navigation_info.archive_status = | 526 LocalFrame* local_parent_frame = GetLocalParentFrame(web_frame_); |
| 521 WebFrameClient::NavigationPolicyInfo::ArchiveStatus::Present; | 527 |
| 522 } | 528 // Newly created child frames may need to be navigated to a history item |
| 529 // during a back/forward navigation. This will only happen when the parent |
| 530 // is a LocalFrame doing a back/forward navigation that has not completed. |
| 531 // (If the load has completed and the parent later adds a frame with script, |
| 532 // we do not want to use a history item for it.) |
| 533 navigation_info.is_history_navigation_in_new_child_frame = |
| 534 IsBackForwardNavigationInProgress(local_parent_frame); |
| 535 |
| 536 // TODO(nasko): How should this work with OOPIF? |
| 537 // The MHTMLArchive is parsed as a whole, but can be constructed from frames |
| 538 // in multiple processes. In that case, which process should parse it and how |
| 539 // should the output be spread back across multiple processes? |
| 540 navigation_info.archive_status = |
| 541 IsLoadedAsMHTMLArchive(local_parent_frame) |
| 542 ? WebFrameClient::NavigationPolicyInfo::ArchiveStatus::Present |
| 543 : WebFrameClient::NavigationPolicyInfo::ArchiveStatus::Absent; |
| 523 | 544 |
| 524 // Caching could be disabled for requests initiated by DevTools. | 545 // Caching could be disabled for requests initiated by DevTools. |
| 525 // TODO(ananta) | 546 // TODO(ananta) |
| 526 // We should extract the network cache state into a global component which | 547 // We should extract the network cache state into a global component which |
| 527 // can be queried here and wherever necessary. | 548 // can be queried here and wherever necessary. |
| 528 navigation_info.is_cache_disabled = | 549 navigation_info.is_cache_disabled = |
| 529 DevToolsAgent() ? DevToolsAgent()->CacheDisabled() : false; | 550 DevToolsAgent() ? DevToolsAgent()->CacheDisabled() : false; |
| 530 if (form) | 551 if (form) |
| 531 navigation_info.form = WebFormElement(form); | 552 navigation_info.form = WebFormElement(form); |
| 532 | 553 |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 WrappedResourceRequest(request)); | 1001 WrappedResourceRequest(request)); |
| 981 } | 1002 } |
| 982 return false; | 1003 return false; |
| 983 } | 1004 } |
| 984 | 1005 |
| 985 WebDevToolsAgentImpl* LocalFrameClientImpl::DevToolsAgent() { | 1006 WebDevToolsAgentImpl* LocalFrameClientImpl::DevToolsAgent() { |
| 986 return WebLocalFrameImpl::FromFrame(web_frame_->GetFrame()->LocalFrameRoot()) | 1007 return WebLocalFrameImpl::FromFrame(web_frame_->GetFrame()->LocalFrameRoot()) |
| 987 ->DevToolsAgentImpl(); | 1008 ->DevToolsAgentImpl(); |
| 988 } | 1009 } |
| 989 | 1010 |
| 990 bool LocalFrameClientImpl::IsLoadedAsMHTMLArchive() const { | |
| 991 WebFrame* parent_frame = web_frame_->Parent(); | |
| 992 if (!parent_frame) | |
| 993 return false; | |
| 994 | |
| 995 // TODO(nasko): How should this work with OOPIF? | |
| 996 // The MHTMLArchive is parsed as a whole, but can be constructed from frames | |
| 997 // in multiple processes. In that case, which process should parse it and how | |
| 998 // should the output be spread back across multiple processes? | |
| 999 if (!parent_frame->IsWebLocalFrame()) | |
| 1000 return false; | |
| 1001 | |
| 1002 return ToWebLocalFrameImpl(parent_frame) | |
| 1003 ->GetFrame() | |
| 1004 ->Loader() | |
| 1005 .GetDocumentLoader() | |
| 1006 ->Fetcher() | |
| 1007 ->Archive(); | |
| 1008 } | |
| 1009 | |
| 1010 KURL LocalFrameClientImpl::OverrideFlashEmbedWithHTML(const KURL& url) { | 1011 KURL LocalFrameClientImpl::OverrideFlashEmbedWithHTML(const KURL& url) { |
| 1011 return web_frame_->Client()->OverrideFlashEmbedWithHTML(WebURL(url)); | 1012 return web_frame_->Client()->OverrideFlashEmbedWithHTML(WebURL(url)); |
| 1012 } | 1013 } |
| 1013 | 1014 |
| 1014 void LocalFrameClientImpl::SetHasReceivedUserGesture(bool received_previously) { | 1015 void LocalFrameClientImpl::SetHasReceivedUserGesture(bool received_previously) { |
| 1015 // The client potentially needs to dispatch the event to other processes only | 1016 // The client potentially needs to dispatch the event to other processes only |
| 1016 // for the first time. | 1017 // for the first time. |
| 1017 if (!received_previously && web_frame_->Client()) | 1018 if (!received_previously && web_frame_->Client()) |
| 1018 web_frame_->Client()->SetHasReceivedUserGesture(); | 1019 web_frame_->Client()->SetHasReceivedUserGesture(); |
| 1019 // WebAutofillClient reacts only to the user gestures for this particular | 1020 // WebAutofillClient reacts only to the user gestures for this particular |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1031 void LocalFrameClientImpl::AbortClientNavigation() { | 1032 void LocalFrameClientImpl::AbortClientNavigation() { |
| 1032 if (web_frame_->Client()) | 1033 if (web_frame_->Client()) |
| 1033 web_frame_->Client()->AbortClientNavigation(); | 1034 web_frame_->Client()->AbortClientNavigation(); |
| 1034 } | 1035 } |
| 1035 | 1036 |
| 1036 TextCheckerClient& LocalFrameClientImpl::GetTextCheckerClient() const { | 1037 TextCheckerClient& LocalFrameClientImpl::GetTextCheckerClient() const { |
| 1037 return web_frame_->GetTextCheckerClient(); | 1038 return web_frame_->GetTextCheckerClient(); |
| 1038 } | 1039 } |
| 1039 | 1040 |
| 1040 } // namespace blink | 1041 } // namespace blink |
| OLD | NEW |