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 #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 transient NavigationItem, if any. The transient item will be |
59 // SSL interstitials). | 57 // discarded on any navigation, and is used to represent interstitials in the |
| 58 // session history. |
60 @property(nonatomic, readonly) web::NavigationItemImpl* transientItem; | 59 @property(nonatomic, readonly) web::NavigationItemImpl* transientItem; |
61 // Returns the NavigationItem corresponding with the last committed load. | 60 // Returns the NavigationItem corresponding with the last committed load. |
62 @property(nonatomic, readonly) web::NavigationItemImpl* lastCommittedItem; | 61 @property(nonatomic, readonly) web::NavigationItemImpl* lastCommittedItem; |
63 // Returns the NavigationItem corresponding with the previously loaded page. | 62 // Returns the NavigationItem corresponding with the previously loaded page. |
64 @property(nonatomic, readonly) web::NavigationItemImpl* previousItem; | 63 @property(nonatomic, readonly) web::NavigationItemImpl* previousItem; |
65 // Returns most recent NavigationItem that is not a redirect. Returns nil if | 64 // Returns most recent NavigationItem that is not a redirect. Returns nil if |
66 // |items| is empty. | 65 // |items| is empty. |
67 @property(nonatomic, readonly) web::NavigationItemImpl* lastUserItem; | 66 @property(nonatomic, readonly) web::NavigationItemImpl* lastUserItem; |
68 // Returns a list of all non-redirected NavigationItems whose index precedes | 67 // Returns a list of all non-redirected NavigationItems whose index precedes |
69 // |currentNavigationIndex|. | 68 // |currentNavigationIndex|. |
70 @property(nonatomic, readonly) web::NavigationItemList backwardItems; | 69 @property(nonatomic, readonly) web::NavigationItemList backwardItems; |
71 // Returns a list of all non-redirected NavigationItems whose index follow | 70 // Returns a list of all non-redirected NavigationItems whose index follow |
72 // |currentNavigationIndex|. | 71 // |currentNavigationIndex|. |
73 @property(nonatomic, readonly) web::NavigationItemList forwardItems; | 72 @property(nonatomic, readonly) web::NavigationItemList forwardItems; |
74 | 73 |
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 | 74 // CRWSessionController doesn't have public constructors. New |
89 // CRWSessionControllers are created by deserialization, or via a | 75 // CRWSessionControllers are created by deserialization, or via a |
90 // NavigationManager. | 76 // NavigationManager. |
91 | 77 |
92 // Sets the corresponding NavigationManager. | 78 // Sets the corresponding NavigationManager. |
93 - (void)setNavigationManager:(web::NavigationManagerImpl*)navigationManager; | 79 - (void)setNavigationManager:(web::NavigationManagerImpl*)navigationManager; |
94 // Sets the corresponding BrowserState. | 80 // Sets the corresponding BrowserState. |
95 - (void)setBrowserState:(web::BrowserState*)browserState; | 81 - (void)setBrowserState:(web::BrowserState*)browserState; |
96 | 82 |
97 // Add a new item with the given url, referrer, and navigation type, making it | 83 // Add a new item with the given url, referrer, and navigation type, making it |
(...skipping 13 matching lines...) Expand all Loading... |
111 // this process, it is just moved from pending to committed. | 97 // this process, it is just moved from pending to committed. |
112 // TODO(pinkerton): Desktop Chrome broadcasts a notification here, should we? | 98 // TODO(pinkerton): Desktop Chrome broadcasts a notification here, should we? |
113 - (void)commitPendingItem; | 99 - (void)commitPendingItem; |
114 | 100 |
115 // Adds a transient item with the given URL. A transient item will be | 101 // Adds a transient item with the given URL. A transient item will be |
116 // discarded on any navigation. | 102 // discarded on any navigation. |
117 // TODO(stuartmorgan): Make this work more like upstream, where the item can | 103 // TODO(stuartmorgan): Make this work more like upstream, where the item can |
118 // be made from outside and then handed in. | 104 // be made from outside and then handed in. |
119 - (void)addTransientItemWithURL:(const GURL&)URL; | 105 - (void)addTransientItemWithURL:(const GURL&)URL; |
120 | 106 |
121 // Creates a new CRWSessionEntry with the given URL and state object. A state | 107 // 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 | 108 // 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 | 109 // UI's state for a given NavigationItem/URL. The current item's URL is the |
124 // new item's referrer. | 110 // new item's referrer. |
125 - (void)pushNewItemWithURL:(const GURL&)URL | 111 - (void)pushNewItemWithURL:(const GURL&)URL |
126 stateObject:(NSString*)stateObject | 112 stateObject:(NSString*)stateObject |
127 transition:(ui::PageTransition)transition; | 113 transition:(ui::PageTransition)transition; |
128 | 114 |
129 // Updates the URL and state object for the current item. | 115 // Updates the URL and state object for the current item. |
130 - (void)updateCurrentItemWithURL:(const GURL&)url | 116 - (void)updateCurrentItemWithURL:(const GURL&)url |
131 stateObject:(NSString*)stateObject; | 117 stateObject:(NSString*)stateObject; |
132 | 118 |
133 // Removes the pending and transient NavigationItems. | 119 // Removes the pending and transient NavigationItems. |
134 - (void)discardNonCommittedItems; | 120 - (void)discardNonCommittedItems; |
135 | 121 |
136 // Inserts history state from |otherController| to the front of |items|. This | 122 // Inserts history state from |otherController| to the front of |items|. This |
137 // function transfers ownership of |otherController|'s NavigationItems to the | 123 // function will create copies of |otherController|'s NavigationItems. |
138 // receiver. | |
139 - (void)insertStateFromSessionController:(CRWSessionController*)otherController; | 124 - (void)insertStateFromSessionController:(CRWSessionController*)otherController; |
140 | 125 |
141 // Sets |currentNavigationIndex_| to the |index| if it's in the entries bounds. | 126 // Sets |currentNavigationIndex_| to the |index| if it's in the entries bounds. |
142 - (void)goToItemAtIndex:(NSInteger)index; | 127 - (void)goToItemAtIndex:(NSInteger)index; |
143 | 128 |
144 // Removes the item at |index| after discarding any noncomitted entries. | 129 // 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 | 130 // |index| must not be the index of the last committed item, or a noncomitted |
146 // item. | 131 // item. |
147 - (void)removeItemAtIndex:(NSInteger)index; | 132 - (void)removeItemAtIndex:(NSInteger)index; |
148 | 133 |
149 // Determines whether a navigation between |firstEntry| and |secondEntry| is a | 134 // Determines whether a navigation between |firstEntry| and |secondEntry| is a |
150 // same-document navigation. Entries can be passed in any order. | 135 // same-document navigation. Entries can be passed in any order. |
151 - (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem | 136 - (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem |
152 andItem:(web::NavigationItem*)secondItem; | 137 andItem:(web::NavigationItem*)secondItem; |
153 | 138 |
154 // Returns the index of |item| in |items|. | 139 // Returns the index of |item| in |items|. |
155 - (NSInteger)indexOfItem:(const web::NavigationItem*)item; | 140 - (NSInteger)indexOfItem:(const web::NavigationItem*)item; |
156 | 141 |
157 // Returns the item at |index| in |items|. | 142 // Returns the item at |index| in |items|. |
158 - (web::NavigationItemImpl*)itemAtIndex:(NSInteger)index; | 143 - (web::NavigationItemImpl*)itemAtIndex:(NSInteger)index; |
159 | 144 |
160 @end | 145 @end |
161 | 146 |
162 #endif // IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ | 147 #endif // IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ |
OLD | NEW |