OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 #import "ios/web/navigation/crw_session_controller.h" | 5 #import "ios/web/navigation/crw_session_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> |
10 #include <vector> | 11 #include <vector> |
11 | 12 |
12 #include "base/format_macros.h" | 13 #include "base/format_macros.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/mac/objc_property_releaser.h" | 15 #include "base/mac/objc_property_releaser.h" |
15 #import "base/mac/scoped_nsobject.h" | 16 #import "base/mac/scoped_nsobject.h" |
16 #include "base/metrics/user_metrics_action.h" | 17 #include "base/metrics/user_metrics_action.h" |
17 #include "base/strings/sys_string_conversions.h" | 18 #include "base/strings/sys_string_conversions.h" |
18 #import "ios/web/history_state_util.h" | 19 #import "ios/web/history_state_util.h" |
19 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" | 20 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 _browserState = browserState; | 183 _browserState = browserState; |
183 | 184 |
184 // Create entries array from list of navigations. | 185 // Create entries array from list of navigations. |
185 _entries = [[NSMutableArray alloc] initWithCapacity:scoped_items.size()]; | 186 _entries = [[NSMutableArray alloc] initWithCapacity:scoped_items.size()]; |
186 std::vector<web::NavigationItem*> items; | 187 std::vector<web::NavigationItem*> items; |
187 scoped_items.release(&items); | 188 scoped_items.release(&items); |
188 | 189 |
189 for (size_t i = 0; i < items.size(); ++i) { | 190 for (size_t i = 0; i < items.size(); ++i) { |
190 scoped_ptr<web::NavigationItem> item(items[i]); | 191 scoped_ptr<web::NavigationItem> item(items[i]); |
191 base::scoped_nsobject<CRWSessionEntry> entry( | 192 base::scoped_nsobject<CRWSessionEntry> entry( |
192 [[CRWSessionEntry alloc] initWithNavigationItem:item.Pass()]); | 193 [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]); |
193 [_entries addObject:entry]; | 194 [_entries addObject:entry]; |
194 } | 195 } |
195 self.currentNavigationIndex = currentIndex; | 196 self.currentNavigationIndex = currentIndex; |
196 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that. | 197 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that. |
197 if (![_entries count]) | 198 if (![_entries count]) |
198 self.currentNavigationIndex = -1; | 199 self.currentNavigationIndex = -1; |
199 if (_currentNavigationIndex >= static_cast<NSInteger>(items.size())) { | 200 if (_currentNavigationIndex >= static_cast<NSInteger>(items.size())) { |
200 self.currentNavigationIndex = static_cast<NSInteger>(items.size()) - 1; | 201 self.currentNavigationIndex = static_cast<NSInteger>(items.size()) - 1; |
201 } | 202 } |
202 _previousNavigationIndex = -1; | 203 _previousNavigationIndex = -1; |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 if (!urlWasRewritten) { | 883 if (!urlWasRewritten) { |
883 web::BrowserURLRewriter::GetInstance()->RewriteURLIfNecessary( | 884 web::BrowserURLRewriter::GetInstance()->RewriteURLIfNecessary( |
884 &loaded_url, _browserState); | 885 &loaded_url, _browserState); |
885 } | 886 } |
886 scoped_ptr<web::NavigationItemImpl> item(new web::NavigationItemImpl()); | 887 scoped_ptr<web::NavigationItemImpl> item(new web::NavigationItemImpl()); |
887 item->SetURL(loaded_url); | 888 item->SetURL(loaded_url); |
888 item->SetReferrer(referrer); | 889 item->SetReferrer(referrer); |
889 item->SetTransitionType(transition); | 890 item->SetTransitionType(transition); |
890 item->SetIsOverridingUserAgent(useDesktopUserAgent); | 891 item->SetIsOverridingUserAgent(useDesktopUserAgent); |
891 item->set_is_renderer_initiated(rendererInitiated); | 892 item->set_is_renderer_initiated(rendererInitiated); |
892 return [ | 893 return [[[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)] |
893 [[CRWSessionEntry alloc] initWithNavigationItem:item.Pass()] autorelease]; | 894 autorelease]; |
894 } | 895 } |
895 | 896 |
896 @end | 897 @end |
OLD | NEW |