| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/web_view/navigation_controller.h" | 5 #include "components/web_view/navigation_controller.h" |
| 6 | 6 |
| 7 #include "components/web_view/frame.h" | 7 #include "components/web_view/frame.h" |
| 8 #include "components/web_view/navigation_controller_delegate.h" | 8 #include "components/web_view/navigation_controller_delegate.h" |
| 9 #include "components/web_view/navigation_entry.h" | 9 #include "components/web_view/navigation_entry.h" |
| 10 #include "components/web_view/reload_type.h" | 10 #include "components/web_view/reload_type.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 | 70 |
| 71 // Base the navigation on where we are now... | 71 // Base the navigation on where we are now... |
| 72 int current_index = GetCurrentEntryIndex(); | 72 int current_index = GetCurrentEntryIndex(); |
| 73 | 73 |
| 74 DiscardPendingEntry(false); | 74 DiscardPendingEntry(false); |
| 75 | 75 |
| 76 pending_entry_index_ = current_index - 1; | 76 pending_entry_index_ = current_index - 1; |
| 77 // TODO(erg): Transition type handled here. | 77 // TODO(erg): Transition type handled here. |
| 78 NavigateToPendingEntry(ReloadType::NO_RELOAD); | 78 NavigateToPendingEntry(ReloadType::NO_RELOAD, true); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void NavigationController::GoForward() { | 81 void NavigationController::GoForward() { |
| 82 if (!CanGoForward()) { | 82 if (!CanGoForward()) { |
| 83 NOTREACHED(); | 83 NOTREACHED(); |
| 84 return; | 84 return; |
| 85 } | 85 } |
| 86 | 86 |
| 87 // TODO(erg): The upstream version handles transience here. | 87 // TODO(erg): The upstream version handles transience here. |
| 88 | 88 |
| 89 // Base the navigation on where we are now... | 89 // Base the navigation on where we are now... |
| 90 int current_index = GetCurrentEntryIndex(); | 90 int current_index = GetCurrentEntryIndex(); |
| 91 | 91 |
| 92 DiscardPendingEntry(false); | 92 DiscardPendingEntry(false); |
| 93 | 93 |
| 94 pending_entry_index_ = current_index + 1; | 94 pending_entry_index_ = current_index + 1; |
| 95 // TODO(erg): Transition type handled here. | 95 // TODO(erg): Transition type handled here. |
| 96 NavigateToPendingEntry(ReloadType::NO_RELOAD); | 96 NavigateToPendingEntry(ReloadType::NO_RELOAD, true); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void NavigationController::LoadURL(mojo::URLRequestPtr request) { | 99 void NavigationController::LoadURL(mojo::URLRequestPtr request) { |
| 100 // TODO(erg): This mimics part of NavigationControllerImpl::LoadURL(), minus | 100 // TODO(erg): This mimics part of NavigationControllerImpl::LoadURL(), minus |
| 101 // all the error checking. | 101 // all the error checking. |
| 102 SetPendingEntry(make_scoped_ptr(new NavigationEntry(request.Pass()))); | 102 SetPendingEntry(make_scoped_ptr(new NavigationEntry(request.Pass()))); |
| 103 NavigateToPendingEntry(ReloadType::NO_RELOAD); | 103 NavigateToPendingEntry(ReloadType::NO_RELOAD, false); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void NavigationController::NavigateToPendingEntry(ReloadType reload_type) { | 106 void NavigationController::NavigateToPendingEntry( |
| 107 ReloadType reload_type, |
| 108 bool update_navigation_start_time) { |
| 107 // TODO(erg): Deal with session history navigations while trying to navigate | 109 // TODO(erg): Deal with session history navigations while trying to navigate |
| 108 // to a slow-to-commit page. | 110 // to a slow-to-commit page. |
| 109 | 111 |
| 110 // TODO(erg): Deal with interstitials. | 112 // TODO(erg): Deal with interstitials. |
| 111 | 113 |
| 112 // For session history navigations only the pending_entry_index_ is set. | 114 // For session history navigations only the pending_entry_index_ is set. |
| 113 if (!pending_entry_) { | 115 if (!pending_entry_) { |
| 114 CHECK_NE(pending_entry_index_, -1); | 116 CHECK_NE(pending_entry_index_, -1); |
| 115 pending_entry_ = entries_[pending_entry_index_]; | 117 pending_entry_ = entries_[pending_entry_index_]; |
| 116 } | 118 } |
| 117 | 119 |
| 118 // TODO(erg): Eventually, we need to deal with restoring the state of the | 120 // TODO(erg): Eventually, we need to deal with restoring the state of the |
| 119 // full tree. For now, we'll just shell back to the WebView. | 121 // full tree. For now, we'll just shell back to the WebView. |
| 120 delegate_->OnNavigate(pending_entry_->BuildURLRequest()); | 122 delegate_->OnNavigate( |
| 123 pending_entry_->BuildURLRequest(update_navigation_start_time)); |
| 121 } | 124 } |
| 122 | 125 |
| 123 void NavigationController::DiscardPendingEntry(bool was_failure) { | 126 void NavigationController::DiscardPendingEntry(bool was_failure) { |
| 124 // TODO(erg): We might copy the CHECK regarding NavigateToEntry here. | 127 // TODO(erg): We might copy the CHECK regarding NavigateToEntry here. |
| 125 | 128 |
| 126 // TODO(erg): We need to maintain the failed_pending_entry_ during | 129 // TODO(erg): We need to maintain the failed_pending_entry_ during |
| 127 // |was_failure| here. | 130 // |was_failure| here. |
| 128 | 131 |
| 129 if (pending_entry_index_ == -1) | 132 if (pending_entry_index_ == -1) |
| 130 delete pending_entry_; | 133 delete pending_entry_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 int current_size = static_cast<int>(entries_.size()); | 203 int current_size = static_cast<int>(entries_.size()); |
| 201 if (current_size > 0) { | 204 if (current_size > 0) { |
| 202 while (last_committed_entry_index_ < (current_size - 1)) { | 205 while (last_committed_entry_index_ < (current_size - 1)) { |
| 203 entries_.pop_back(); | 206 entries_.pop_back(); |
| 204 current_size--; | 207 current_size--; |
| 205 } | 208 } |
| 206 } | 209 } |
| 207 } | 210 } |
| 208 | 211 |
| 209 } // namespace web_view | 212 } // namespace web_view |
| OLD | NEW |