| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ios/web/navigation/navigation_manager_impl.h" | 5 #include "ios/web/navigation/navigation_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "ios/web/navigation/crw_session_controller+private_constructors.h" | 8 #import "ios/web/navigation/crw_session_controller+private_constructors.h" |
| 9 #import "ios/web/navigation/crw_session_controller.h" | 9 #import "ios/web/navigation/crw_session_controller.h" |
| 10 #import "ios/web/navigation/crw_session_entry.h" | 10 #import "ios/web/navigation/crw_session_entry.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 136 |
| 137 NavigationItem* NavigationManagerImpl::GetTransientItem() const { | 137 NavigationItem* NavigationManagerImpl::GetTransientItem() const { |
| 138 return [[session_controller_ transientEntry] navigationItem]; | 138 return [[session_controller_ transientEntry] navigationItem]; |
| 139 } | 139 } |
| 140 | 140 |
| 141 NavigationItem* NavigationManagerImpl::GetLastCommittedItem() const { | 141 NavigationItem* NavigationManagerImpl::GetLastCommittedItem() const { |
| 142 CRWSessionEntry* entry = [session_controller_ lastCommittedEntry]; | 142 CRWSessionEntry* entry = [session_controller_ lastCommittedEntry]; |
| 143 return [entry navigationItem]; | 143 return [entry navigationItem]; |
| 144 } | 144 } |
| 145 | 145 |
| 146 NavigationItem* NavigationManagerImpl::GetItemAtIndex(size_t index) const { | |
| 147 NSArray* entries = [session_controller_ entries]; | |
| 148 return index < entries.count ? [entries[index] navigationItem] : nullptr; | |
| 149 } | |
| 150 | |
| 151 int NavigationManagerImpl::GetCurrentEntryIndex() const { | |
| 152 return [session_controller_ currentNavigationIndex]; | |
| 153 } | |
| 154 | |
| 155 int NavigationManagerImpl::GetLastCommittedEntryIndex() const { | 146 int NavigationManagerImpl::GetLastCommittedEntryIndex() const { |
| 156 if (![[session_controller_ entries] count]) | 147 if (![[session_controller_ entries] count]) |
| 157 return -1; | 148 return -1; |
| 158 return [session_controller_ currentNavigationIndex]; | 149 return [session_controller_ currentNavigationIndex]; |
| 159 } | 150 } |
| 160 | 151 |
| 161 int NavigationManagerImpl::GetEntryCount() const { | |
| 162 return [[session_controller_ entries] count]; | |
| 163 } | |
| 164 | |
| 165 bool NavigationManagerImpl::RemoveEntryAtIndex(int index) { | 152 bool NavigationManagerImpl::RemoveEntryAtIndex(int index) { |
| 166 if (index == GetLastCommittedEntryIndex() || | 153 if (index == GetLastCommittedEntryIndex() || |
| 167 index == GetPendingEntryIndex()) | 154 index == GetPendingEntryIndex()) |
| 168 return false; | 155 return false; |
| 169 | 156 |
| 170 NSUInteger idx = static_cast<NSUInteger>(index); | 157 NSUInteger idx = static_cast<NSUInteger>(index); |
| 171 NSArray* entries = [session_controller_ entries]; | 158 NSArray* entries = [session_controller_ entries]; |
| 172 if (idx >= entries.count) | 159 if (idx >= entries.count) |
| 173 return false; | 160 return false; |
| 174 | 161 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 195 void NavigationManagerImpl::AddTransientURLRewriter( | 182 void NavigationManagerImpl::AddTransientURLRewriter( |
| 196 BrowserURLRewriter::URLRewriter rewriter) { | 183 BrowserURLRewriter::URLRewriter rewriter) { |
| 197 DCHECK(rewriter); | 184 DCHECK(rewriter); |
| 198 if (!transient_url_rewriters_) { | 185 if (!transient_url_rewriters_) { |
| 199 transient_url_rewriters_.reset( | 186 transient_url_rewriters_.reset( |
| 200 new std::vector<BrowserURLRewriter::URLRewriter>()); | 187 new std::vector<BrowserURLRewriter::URLRewriter>()); |
| 201 } | 188 } |
| 202 transient_url_rewriters_->push_back(rewriter); | 189 transient_url_rewriters_->push_back(rewriter); |
| 203 } | 190 } |
| 204 | 191 |
| 192 int NavigationManagerImpl::GetEntryCount() const { |
| 193 return [[session_controller_ entries] count]; |
| 194 } |
| 195 |
| 196 NavigationItem* NavigationManagerImpl::GetItemAtIndex(size_t index) const { |
| 197 NSArray* entries = [session_controller_ entries]; |
| 198 return index < entries.count ? [entries[index] navigationItem] : nullptr; |
| 199 } |
| 200 |
| 201 int NavigationManagerImpl::GetCurrentEntryIndex() const { |
| 202 return [session_controller_ currentNavigationIndex]; |
| 203 } |
| 204 |
| 205 scoped_ptr<std::vector<BrowserURLRewriter::URLRewriter>> | 205 scoped_ptr<std::vector<BrowserURLRewriter::URLRewriter>> |
| 206 NavigationManagerImpl::GetTransientURLRewriters() { | 206 NavigationManagerImpl::GetTransientURLRewriters() { |
| 207 return transient_url_rewriters_.Pass(); | 207 return transient_url_rewriters_.Pass(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 void NavigationManagerImpl::RemoveTransientURLRewriters() { | 210 void NavigationManagerImpl::RemoveTransientURLRewriters() { |
| 211 transient_url_rewriters_.reset(); | 211 transient_url_rewriters_.reset(); |
| 212 } | 212 } |
| 213 | 213 |
| 214 void NavigationManagerImpl::LoadURL(const GURL& url, | 214 void NavigationManagerImpl::LoadURL(const GURL& url, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 261 } |
| 262 | 262 |
| 263 void NavigationManagerImpl::CopyState( | 263 void NavigationManagerImpl::CopyState( |
| 264 NavigationManagerImpl* navigation_manager) { | 264 NavigationManagerImpl* navigation_manager) { |
| 265 SetSessionController( | 265 SetSessionController( |
| 266 [[navigation_manager->GetSessionController() copy] autorelease]); | 266 [[navigation_manager->GetSessionController() copy] autorelease]); |
| 267 } | 267 } |
| 268 | 268 |
| 269 } // namespace web | 269 } // namespace web |
| 270 | 270 |
| OLD | NEW |