| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 /* | 5 /* |
| 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * | 10 * |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 HistoryController::HistoryController(RenderViewImpl* render_view) | 54 HistoryController::HistoryController(RenderViewImpl* render_view) |
| 55 : render_view_(render_view) { | 55 : render_view_(render_view) { |
| 56 // We don't use HistoryController in OOPIF enabled modes. | 56 // We don't use HistoryController in OOPIF enabled modes. |
| 57 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); | 57 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 58 } | 58 } |
| 59 | 59 |
| 60 HistoryController::~HistoryController() { | 60 HistoryController::~HistoryController() { |
| 61 } | 61 } |
| 62 | 62 |
| 63 void HistoryController::GoToEntry( | 63 bool HistoryController::GoToEntry( |
| 64 blink::WebLocalFrame* main_frame, | 64 blink::WebLocalFrame* main_frame, |
| 65 scoped_ptr<HistoryEntry> target_entry, | 65 scoped_ptr<HistoryEntry> target_entry, |
| 66 scoped_ptr<NavigationParams> navigation_params, | 66 scoped_ptr<NavigationParams> navigation_params, |
| 67 WebURLRequest::CachePolicy cache_policy) { | 67 WebURLRequest::CachePolicy cache_policy) { |
| 68 DCHECK(!main_frame->parent()); | 68 DCHECK(!main_frame->parent()); |
| 69 HistoryFrameLoadVector same_document_loads; | 69 HistoryFrameLoadVector same_document_loads; |
| 70 HistoryFrameLoadVector different_document_loads; | 70 HistoryFrameLoadVector different_document_loads; |
| 71 | 71 |
| 72 set_provisional_entry(std::move(target_entry)); | 72 set_provisional_entry(std::move(target_entry)); |
| 73 navigation_params_ = std::move(navigation_params); | 73 navigation_params_ = std::move(navigation_params); |
| 74 | 74 |
| 75 if (current_entry_) { | 75 if (current_entry_) { |
| 76 RecursiveGoToEntry( | 76 RecursiveGoToEntry( |
| 77 main_frame, same_document_loads, different_document_loads); | 77 main_frame, same_document_loads, different_document_loads); |
| 78 } | 78 } |
| 79 | 79 |
| 80 if (same_document_loads.empty() && different_document_loads.empty()) { | 80 if (same_document_loads.empty() && different_document_loads.empty()) { |
| 81 // If we don't have any frames to navigate at this point, either | 81 // If we don't have any frames to navigate at this point, either |
| 82 // (1) there is no previous history entry to compare against, or | 82 // (1) there is no previous history entry to compare against, or |
| 83 // (2) we were unable to match any frames by name. In the first case, | 83 // (2) we were unable to match any frames by name. In the first case, |
| 84 // doing a different document navigation to the root item is the only valid | 84 // doing a different document navigation to the root item is the only valid |
| 85 // thing to do. In the second case, we should have been able to find a | 85 // thing to do. In the second case, we should have been able to find a |
| 86 // frame to navigate based on names if this were a same document | 86 // frame to navigate based on names if this were a same document |
| 87 // navigation, so we can safely assume this is the different document case. | 87 // navigation, so we can safely assume this is the different document case. |
| 88 different_document_loads.push_back( | 88 different_document_loads.push_back( |
| 89 std::make_pair(main_frame, provisional_entry_->root())); | 89 std::make_pair(main_frame, provisional_entry_->root())); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool has_main_frame_request = false; |
| 92 for (const auto& item : same_document_loads) { | 93 for (const auto& item : same_document_loads) { |
| 93 WebFrame* frame = item.first; | 94 WebFrame* frame = item.first; |
| 94 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); | 95 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); |
| 95 if (!render_frame) | 96 if (!render_frame) |
| 96 continue; | 97 continue; |
| 97 render_frame->SetPendingNavigationParams(make_scoped_ptr( | 98 render_frame->SetPendingNavigationParams(make_scoped_ptr( |
| 98 new NavigationParams(*navigation_params_.get()))); | 99 new NavigationParams(*navigation_params_.get()))); |
| 99 WebURLRequest request = frame->toWebLocalFrame()->requestFromHistoryItem( | 100 WebURLRequest request = frame->toWebLocalFrame()->requestFromHistoryItem( |
| 100 item.second, cache_policy); | 101 item.second, cache_policy); |
| 101 frame->toWebLocalFrame()->load( | 102 frame->toWebLocalFrame()->load( |
| 102 request, blink::WebFrameLoadType::BackForward, item.second, | 103 request, blink::WebFrameLoadType::BackForward, item.second, |
| 103 blink::WebHistorySameDocumentLoad); | 104 blink::WebHistorySameDocumentLoad); |
| 105 if (frame == main_frame) |
| 106 has_main_frame_request = true; |
| 104 } | 107 } |
| 105 for (const auto& item : different_document_loads) { | 108 for (const auto& item : different_document_loads) { |
| 106 WebFrame* frame = item.first; | 109 WebFrame* frame = item.first; |
| 107 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); | 110 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); |
| 108 if (!render_frame) | 111 if (!render_frame) |
| 109 continue; | 112 continue; |
| 110 render_frame->SetPendingNavigationParams(make_scoped_ptr( | 113 render_frame->SetPendingNavigationParams(make_scoped_ptr( |
| 111 new NavigationParams(*navigation_params_.get()))); | 114 new NavigationParams(*navigation_params_.get()))); |
| 112 WebURLRequest request = frame->toWebLocalFrame()->requestFromHistoryItem( | 115 WebURLRequest request = frame->toWebLocalFrame()->requestFromHistoryItem( |
| 113 item.second, cache_policy); | 116 item.second, cache_policy); |
| 114 frame->toWebLocalFrame()->load( | 117 frame->toWebLocalFrame()->load( |
| 115 request, blink::WebFrameLoadType::BackForward, item.second, | 118 request, blink::WebFrameLoadType::BackForward, item.second, |
| 116 blink::WebHistoryDifferentDocumentLoad); | 119 blink::WebHistoryDifferentDocumentLoad); |
| 120 if (frame == main_frame) |
| 121 has_main_frame_request = true; |
| 117 } | 122 } |
| 123 |
| 124 return has_main_frame_request; |
| 118 } | 125 } |
| 119 | 126 |
| 120 void HistoryController::RecursiveGoToEntry( | 127 void HistoryController::RecursiveGoToEntry( |
| 121 WebFrame* frame, | 128 WebFrame* frame, |
| 122 HistoryFrameLoadVector& same_document_loads, | 129 HistoryFrameLoadVector& same_document_loads, |
| 123 HistoryFrameLoadVector& different_document_loads) { | 130 HistoryFrameLoadVector& different_document_loads) { |
| 124 DCHECK(provisional_entry_); | 131 DCHECK(provisional_entry_); |
| 125 DCHECK(current_entry_); | 132 DCHECK(current_entry_); |
| 126 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); | 133 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); |
| 127 const WebHistoryItem& new_item = | 134 const WebHistoryItem& new_item = |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 bool clone_children_of_target) { | 248 bool clone_children_of_target) { |
| 242 if (!current_entry_) { | 249 if (!current_entry_) { |
| 243 current_entry_.reset(new HistoryEntry(new_item)); | 250 current_entry_.reset(new HistoryEntry(new_item)); |
| 244 } else { | 251 } else { |
| 245 current_entry_.reset(current_entry_->CloneAndReplace( | 252 current_entry_.reset(current_entry_->CloneAndReplace( |
| 246 new_item, clone_children_of_target, target_frame, render_view_)); | 253 new_item, clone_children_of_target, target_frame, render_view_)); |
| 247 } | 254 } |
| 248 } | 255 } |
| 249 | 256 |
| 250 } // namespace content | 257 } // namespace content |
| OLD | NEW |