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

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

Issue 2737203002: Remove CRWSessionEntry. (Closed)
Patch Set: self review Created 3 years, 9 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 #ifndef IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ 5 #ifndef IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_
6 #define IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ 6 #define IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_
7 7
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 #include <vector> 9 #include <vector>
10 10
11 #include "ios/web/public/navigation_item_list.h" 11 #import "ios/web/navigation/navigation_item_impl_list.h"
12 #include "ui/base/page_transition_types.h" 12 #include "ui/base/page_transition_types.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 14
15 @class CRWSessionEntry;
16 @class CRWSessionCertificatePolicyManager; 15 @class CRWSessionCertificatePolicyManager;
17 16
18 namespace web { 17 namespace web {
19 class BrowserState; 18 class BrowserState;
20 class NavigationItemImpl; 19 class NavigationItemImpl;
21 class NavigationManagerImpl; 20 class NavigationManagerImpl;
22 enum class NavigationInitiationType; 21 enum class NavigationInitiationType;
23 struct Referrer; 22 struct Referrer;
24 } 23 }
25 24
26 // A CRWSessionController is similar to a NavigationController object in desktop 25 // A CRWSessionController is similar to a NavigationController object in desktop
27 // Chrome. It maintains information needed to save/restore a tab with its 26 // Chrome. It maintains information needed to save/restore a tab with its
28 // complete session history. There is one of these for each tab. 27 // complete session history. There is one of these for each tab.
29 // DEPRECATED, do not use this class and do not add any methods to it. 28 // DEPRECATED, do not use this class and do not add any methods to it.
30 // Use web::NavigationManager instead. 29 // Use web::NavigationManager instead.
31 // TODO(crbug.com/454984): Remove this class. 30 // TODO(crbug.com/454984): Remove this class.
32 @interface CRWSessionController : NSObject<NSCopying> 31 @interface CRWSessionController : NSObject<NSCopying>
33 32
34 @property(nonatomic, readonly, assign) NSInteger currentNavigationIndex; 33 @property(nonatomic, readonly, assign) NSInteger currentNavigationIndex;
35 @property(nonatomic, readonly, assign) NSInteger previousNavigationIndex; 34 @property(nonatomic, readonly, assign) NSInteger previousNavigationIndex;
36 // The index of the pending item if it is in |items|, or -1 if |pendingItem| 35 // The index of the pending item if it is in |items|, or -1 if |pendingItem|
37 // corresponds with a new navigation (created by addPendingItem:). 36 // corresponds with a new navigation (created by addPendingItem:).
38 @property(nonatomic, readwrite, assign) NSInteger pendingItemIndex; 37 @property(nonatomic, readwrite, assign) NSInteger pendingItemIndex;
39 // Indicates whether the page was opened by DOM (e.g. with |window.open| 38 // Indicates whether the page was opened by DOM (e.g. with |window.open|
40 // JavaScript call or by clicking a link with |_blank| target). 39 // JavaScript call or by clicking a link with |_blank| target).
41 @property(nonatomic, readonly, getter=isOpenedByDOM) BOOL openedByDOM; 40 @property(nonatomic, readonly, getter=isOpenedByDOM) BOOL openedByDOM;
42 @property(nonatomic, readonly, strong) 41 @property(nonatomic, readonly, strong)
43 CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager; 42 CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager;
44 43
45 // The list of CRWSessionEntries in |_entries|'s NavigationItemImpls. 44 // The ScopedNavigationItemImplList used to store the NavigationItemImpls for
46 @property(nonatomic, readonly) web::NavigationItemList items; 45 // this session.
47 // The number of elements in |self.items|. 46 @property(nonatomic, readonly) const web::ScopedNavigationItemImplList& items;
48 @property(nonatomic, readonly) NSUInteger itemCount;
49 // The current NavigationItem. During a pending navigation, returns the 47 // The current NavigationItem. During a pending navigation, returns the
50 // NavigationItem for that navigation. If a transient NavigationItem exists, 48 // NavigationItem for that navigation. If a transient NavigationItem exists,
51 // this NavigationItem will be returned. 49 // this NavigationItem will be returned.
52 @property(nonatomic, readonly) web::NavigationItemImpl* currentItem; 50 @property(nonatomic, readonly) web::NavigationItemImpl* currentItem;
53 // Returns the NavigationItem whose URL should be displayed to the user. 51 // Returns the NavigationItem whose URL should be displayed to the user.
54 @property(nonatomic, readonly) web::NavigationItemImpl* visibleItem; 52 @property(nonatomic, readonly) web::NavigationItemImpl* visibleItem;
55 // Returns the NavigationItem corresponding to a load for which no data has yet 53 // Returns the NavigationItem corresponding to a load for which no data has yet
56 // been received. 54 // been received.
57 @property(nonatomic, readonly) web::NavigationItemImpl* pendingItem; 55 @property(nonatomic, readonly) web::NavigationItemImpl* pendingItem;
58 // Returns the NavigationItem corresponding with a transient navigation (i.e. 56 // Returns the NavigationItem corresponding with a transient navigation (i.e.
59 // SSL interstitials). 57 // SSL interstitials).
60 @property(nonatomic, readonly) web::NavigationItemImpl* transientItem; 58 @property(nonatomic, readonly) web::NavigationItemImpl* transientItem;
61 // Returns the NavigationItem corresponding with the last committed load. 59 // Returns the NavigationItem corresponding with the last committed load.
62 @property(nonatomic, readonly) web::NavigationItemImpl* lastCommittedItem; 60 @property(nonatomic, readonly) web::NavigationItemImpl* lastCommittedItem;
63 // Returns the NavigationItem corresponding with the previously loaded page. 61 // Returns the NavigationItem corresponding with the previously loaded page.
64 @property(nonatomic, readonly) web::NavigationItemImpl* previousItem; 62 @property(nonatomic, readonly) web::NavigationItemImpl* previousItem;
65 // Returns most recent NavigationItem that is not a redirect. Returns nil if 63 // Returns most recent NavigationItem that is not a redirect. Returns nil if
66 // |items| is empty. 64 // |items| is empty.
67 @property(nonatomic, readonly) web::NavigationItemImpl* lastUserItem; 65 @property(nonatomic, readonly) web::NavigationItemImpl* lastUserItem;
68 // Returns a list of all non-redirected NavigationItems whose index precedes 66 // Returns a list of all non-redirected NavigationItems whose index precedes
69 // |currentNavigationIndex|. 67 // |currentNavigationIndex|.
70 @property(nonatomic, readonly) web::NavigationItemList backwardItems; 68 @property(nonatomic, readonly) web::NavigationItemList backwardItems;
71 // Returns a list of all non-redirected NavigationItems whose index follow 69 // Returns a list of all non-redirected NavigationItems whose index follow
72 // |currentNavigationIndex|. 70 // |currentNavigationIndex|.
73 @property(nonatomic, readonly) web::NavigationItemList forwardItems; 71 @property(nonatomic, readonly) web::NavigationItemList forwardItems;
74 72
75 // DEPRECATED: Don't add new usage of these properties. Instead, use the
76 // NavigationItem versions of these properties above.
77 @property(nonatomic, readonly, strong) NSArray* entries;
78 @property(nonatomic, readonly, strong) CRWSessionEntry* currentEntry;
79 @property(nonatomic, readonly, strong) CRWSessionEntry* visibleEntry;
80 @property(nonatomic, readonly, strong) CRWSessionEntry* pendingEntry;
81 @property(nonatomic, readonly, strong) CRWSessionEntry* transientEntry;
82 @property(nonatomic, readonly, strong) CRWSessionEntry* lastCommittedEntry;
83 @property(nonatomic, readonly, strong) CRWSessionEntry* previousEntry;
84 @property(nonatomic, readonly, strong) CRWSessionEntry* lastUserEntry;
85 @property(nonatomic, readonly, weak) NSArray* backwardEntries;
86 @property(nonatomic, readonly, weak) NSArray* forwardEntries;
87
88 // CRWSessionController doesn't have public constructors. New 73 // CRWSessionController doesn't have public constructors. New
89 // CRWSessionControllers are created by deserialization, or via a 74 // CRWSessionControllers are created by deserialization, or via a
90 // NavigationManager. 75 // NavigationManager.
91 76
92 // Sets the corresponding NavigationManager. 77 // Sets the corresponding NavigationManager.
93 - (void)setNavigationManager:(web::NavigationManagerImpl*)navigationManager; 78 - (void)setNavigationManager:(web::NavigationManagerImpl*)navigationManager;
94 // Sets the corresponding BrowserState. 79 // Sets the corresponding BrowserState.
95 - (void)setBrowserState:(web::BrowserState*)browserState; 80 - (void)setBrowserState:(web::BrowserState*)browserState;
96 81
97 // Add a new item with the given url, referrer, and navigation type, making it 82 // Add a new item with the given url, referrer, and navigation type, making it
(...skipping 13 matching lines...) Expand all
111 // this process, it is just moved from pending to committed. 96 // this process, it is just moved from pending to committed.
112 // TODO(pinkerton): Desktop Chrome broadcasts a notification here, should we? 97 // TODO(pinkerton): Desktop Chrome broadcasts a notification here, should we?
113 - (void)commitPendingItem; 98 - (void)commitPendingItem;
114 99
115 // Adds a transient item with the given URL. A transient item will be 100 // Adds a transient item with the given URL. A transient item will be
116 // discarded on any navigation. 101 // discarded on any navigation.
117 // TODO(stuartmorgan): Make this work more like upstream, where the item can 102 // TODO(stuartmorgan): Make this work more like upstream, where the item can
118 // be made from outside and then handed in. 103 // be made from outside and then handed in.
119 - (void)addTransientItemWithURL:(const GURL&)URL; 104 - (void)addTransientItemWithURL:(const GURL&)URL;
120 105
121 // Creates a new CRWSessionEntry with the given URL and state object. A state 106 // Creates a new NavigationItem with the given URL and state object. A state
122 // object is a serialized generic JavaScript object that contains details of the 107 // object is a serialized generic JavaScript object that contains details of the
123 // UI's state for a given CRWSessionEntry/URL. The current item's URL is the 108 // UI's state for a given NavigationItem/URL. The current item's URL is the
124 // new item's referrer. 109 // new item's referrer.
125 - (void)pushNewItemWithURL:(const GURL&)URL 110 - (void)pushNewItemWithURL:(const GURL&)URL
126 stateObject:(NSString*)stateObject 111 stateObject:(NSString*)stateObject
127 transition:(ui::PageTransition)transition; 112 transition:(ui::PageTransition)transition;
128 113
129 // Updates the URL and state object for the current item. 114 // Updates the URL and state object for the current item.
130 - (void)updateCurrentItemWithURL:(const GURL&)url 115 - (void)updateCurrentItemWithURL:(const GURL&)url
131 stateObject:(NSString*)stateObject; 116 stateObject:(NSString*)stateObject;
132 117
133 // Removes the pending and transient NavigationItems. 118 // Removes the pending and transient NavigationItems.
134 - (void)discardNonCommittedItems; 119 - (void)discardNonCommittedItems;
135 120
136 // Inserts history state from |otherController| to the front of |items|. This 121 // Inserts history state from |otherController| to the front of |items|. This
137 // function transfers ownership of |otherController|'s NavigationItems to the 122 // function will create copies of |otherController|'s NavigationItems.
138 // receiver.
139 - (void)insertStateFromSessionController:(CRWSessionController*)otherController; 123 - (void)insertStateFromSessionController:(CRWSessionController*)otherController;
140 124
141 // Sets |currentNavigationIndex_| to the |index| if it's in the entries bounds. 125 // Sets |currentNavigationIndex_| to the |index| if it's in the entries bounds.
142 - (void)goToItemAtIndex:(NSInteger)index; 126 - (void)goToItemAtIndex:(NSInteger)index;
143 127
144 // Removes the item at |index| after discarding any noncomitted entries. 128 // Removes the item at |index| after discarding any noncomitted entries.
145 // |index| must not be the index of the last committed item, or a noncomitted 129 // |index| must not be the index of the last committed item, or a noncomitted
146 // item. 130 // item.
147 - (void)removeItemAtIndex:(NSInteger)index; 131 - (void)removeItemAtIndex:(NSInteger)index;
148 132
149 // Determines whether a navigation between |firstEntry| and |secondEntry| is a 133 // Determines whether a navigation between |firstEntry| and |secondEntry| is a
150 // same-document navigation. Entries can be passed in any order. 134 // same-document navigation. Entries can be passed in any order.
151 - (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem 135 - (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem
152 andItem:(web::NavigationItem*)secondItem; 136 andItem:(web::NavigationItem*)secondItem;
153 137
154 // Returns the index of |item| in |items|. 138 // Returns the index of |item| in |items|.
155 - (NSInteger)indexOfItem:(const web::NavigationItem*)item; 139 - (NSInteger)indexOfItem:(const web::NavigationItem*)item;
156 140
157 // Returns the item at |index| in |items|. 141 // Returns the item at |index| in |items|.
158 - (web::NavigationItemImpl*)itemAtIndex:(NSInteger)index; 142 - (web::NavigationItemImpl*)itemAtIndex:(NSInteger)index;
159 143
160 @end 144 @end
161 145
162 #endif // IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ 146 #endif // IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698