Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: ios/web/navigation/crw_session_controller.mm

Issue 2600583002: Remove ScopedVector from components/sessions. (Closed)
Patch Set: include Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <utility>
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 _lastVisitedTimestamp = [[NSDate date] timeIntervalSince1970]; 157 _lastVisitedTimestamp = [[NSDate date] timeIntervalSince1970];
158 _currentNavigationIndex = -1; 158 _currentNavigationIndex = -1;
159 _previousNavigationIndex = -1; 159 _previousNavigationIndex = -1;
160 _pendingEntryIndex = -1; 160 _pendingEntryIndex = -1;
161 _sessionCertificatePolicyManager = 161 _sessionCertificatePolicyManager =
162 [[CRWSessionCertificatePolicyManager alloc] init]; 162 [[CRWSessionCertificatePolicyManager alloc] init];
163 } 163 }
164 return self; 164 return self;
165 } 165 }
166 166
167 - (id)initWithNavigationItems:(ScopedVector<web::NavigationItem>)scoped_items 167 - (id)initWithNavigationItems:
168 (std::vector<std::unique_ptr<web::NavigationItem>>)items
168 currentIndex:(NSUInteger)currentIndex 169 currentIndex:(NSUInteger)currentIndex
169 browserState:(web::BrowserState*)browserState { 170 browserState:(web::BrowserState*)browserState {
170 self = [super init]; 171 self = [super init];
171 if (self) { 172 if (self) {
172 _tabId = [[self uniqueID] copy]; 173 _tabId = [[self uniqueID] copy];
173 _openerId = nil; 174 _openerId = nil;
174 _browserState = browserState; 175 _browserState = browserState;
175 176
176 // Create entries array from list of navigations. 177 // Create entries array from list of navigations.
177 _entries = [[NSMutableArray alloc] initWithCapacity:scoped_items.size()]; 178 _entries = [[NSMutableArray alloc] initWithCapacity:items.size()];
178 std::vector<web::NavigationItem*> items;
179 scoped_items.release(&items);
180 179
181 for (size_t i = 0; i < items.size(); ++i) { 180 for (auto& item : items) {
182 std::unique_ptr<web::NavigationItem> item(items[i]);
183 base::scoped_nsobject<CRWSessionEntry> entry( 181 base::scoped_nsobject<CRWSessionEntry> entry(
184 [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]); 182 [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]);
185 [_entries addObject:entry]; 183 [_entries addObject:entry];
186 } 184 }
187 self.currentNavigationIndex = currentIndex; 185 self.currentNavigationIndex = currentIndex;
188 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that. 186 // Prior to M34, 0 was used as "no index" instead of -1; adjust for that.
189 if (![_entries count]) 187 if (![_entries count])
190 self.currentNavigationIndex = -1; 188 self.currentNavigationIndex = -1;
191 if (_currentNavigationIndex >= static_cast<NSInteger>(items.size())) { 189 if (_currentNavigationIndex >= static_cast<NSInteger>(items.size())) {
192 self.currentNavigationIndex = static_cast<NSInteger>(items.size()) - 1; 190 self.currentNavigationIndex = static_cast<NSInteger>(items.size()) - 1;
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]; 771 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)];
774 } 772 }
775 773
776 - (BOOL)isRedirectTransitionForEntryAtIndex:(NSInteger)index { 774 - (BOOL)isRedirectTransitionForEntryAtIndex:(NSInteger)index {
777 ui::PageTransition transition = 775 ui::PageTransition transition =
778 [_entries[index] navigationItem]->GetTransitionType(); 776 [_entries[index] navigationItem]->GetTransitionType();
779 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; 777 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO;
780 } 778 }
781 779
782 @end 780 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/tab.mm ('k') | ios/web/navigation/crw_session_controller+private_constructors.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698