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 |
(...skipping 23 matching lines...) Expand all Loading... |
34 @property(nonatomic, readonly, assign) NSInteger previousNavigationIndex; | 34 @property(nonatomic, readonly, assign) NSInteger previousNavigationIndex; |
35 // 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| |
36 // corresponds with a new navigation (created by addPendingItem:). | 36 // corresponds with a new navigation (created by addPendingItem:). |
37 @property(nonatomic, readwrite, assign) NSInteger pendingItemIndex; | 37 @property(nonatomic, readwrite, assign) NSInteger pendingItemIndex; |
38 // 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| |
39 // JavaScript call or by clicking a link with |_blank| target). | 39 // JavaScript call or by clicking a link with |_blank| target). |
40 @property(nonatomic, readonly, getter=isOpenedByDOM) BOOL openedByDOM; | 40 @property(nonatomic, readonly, getter=isOpenedByDOM) BOOL openedByDOM; |
41 @property(nonatomic, readonly, strong) | 41 @property(nonatomic, readonly, strong) |
42 CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager; | 42 CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager; |
43 | 43 |
| 44 // Whether the CRWSessionController can prune all but the last committed item. |
| 45 // This is true when all the following conditions are met: |
| 46 // - There is a last committed NavigationItem |
| 47 // - There is not currently a pending history navigation |
| 48 // - There is no transient NavigationItem. |
| 49 @property(nonatomic, readonly) BOOL canPruneAllButLastCommittedItem; |
| 50 |
44 // The ScopedNavigationItemImplList used to store the NavigationItemImpls for | 51 // The ScopedNavigationItemImplList used to store the NavigationItemImpls for |
45 // this session. | 52 // this session. |
46 @property(nonatomic, readonly) const web::ScopedNavigationItemImplList& items; | 53 @property(nonatomic, readonly) const web::ScopedNavigationItemImplList& items; |
47 // The current NavigationItem. During a pending navigation, returns the | 54 // The current NavigationItem. During a pending navigation, returns the |
48 // NavigationItem for that navigation. If a transient NavigationItem exists, | 55 // NavigationItem for that navigation. If a transient NavigationItem exists, |
49 // this NavigationItem will be returned. | 56 // this NavigationItem will be returned. |
50 @property(nonatomic, readonly) web::NavigationItemImpl* currentItem; | 57 @property(nonatomic, readonly) web::NavigationItemImpl* currentItem; |
51 // Returns the NavigationItem whose URL should be displayed to the user. | 58 // Returns the NavigationItem whose URL should be displayed to the user. |
52 @property(nonatomic, readonly) web::NavigationItemImpl* visibleItem; | 59 @property(nonatomic, readonly) web::NavigationItemImpl* visibleItem; |
53 // Returns the NavigationItem corresponding to a load for which no data has yet | 60 // Returns the NavigationItem corresponding to a load for which no data has yet |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 stateObject:(NSString*)stateObject | 119 stateObject:(NSString*)stateObject |
113 transition:(ui::PageTransition)transition; | 120 transition:(ui::PageTransition)transition; |
114 | 121 |
115 // Updates the URL and state object for the current item. | 122 // Updates the URL and state object for the current item. |
116 - (void)updateCurrentItemWithURL:(const GURL&)url | 123 - (void)updateCurrentItemWithURL:(const GURL&)url |
117 stateObject:(NSString*)stateObject; | 124 stateObject:(NSString*)stateObject; |
118 | 125 |
119 // Removes the pending and transient NavigationItems. | 126 // Removes the pending and transient NavigationItems. |
120 - (void)discardNonCommittedItems; | 127 - (void)discardNonCommittedItems; |
121 | 128 |
122 // Inserts history state from |otherController| to the front of |items|. This | 129 // Removes all items from this except the last committed item, and inserts |
123 // function will create copies of |otherController|'s NavigationItems. | 130 // copies of all items from |source| at the beginning of the session history. |
124 - (void)insertStateFromSessionController:(CRWSessionController*)otherController; | 131 // |
| 132 // For example: |
| 133 // source: A B *C* D |
| 134 // this: E F *G* |
| 135 // result: A B C *G* |
| 136 // |
| 137 // If there is a pending item after *G* in |this|, it is also preserved. |
| 138 // This ignores any pending or transient entries in |source|. No-op if |
| 139 // |canPruneAllButLastCommittedItem| is false. |
| 140 - (void)copyStateFromSessionControllerAndPrune:(CRWSessionController*)source; |
125 | 141 |
126 // Sets |currentNavigationIndex_| to the |index| if it's in the entries bounds. | 142 // Sets |currentNavigationIndex_| to the |index| if it's in the entries bounds. |
127 - (void)goToItemAtIndex:(NSInteger)index; | 143 - (void)goToItemAtIndex:(NSInteger)index; |
128 | 144 |
129 // Removes the item at |index| after discarding any noncomitted entries. | 145 // Removes the item at |index| after discarding any noncomitted entries. |
130 // |index| must not be the index of the last committed item, or a noncomitted | 146 // |index| must not be the index of the last committed item, or a noncomitted |
131 // item. | 147 // item. |
132 - (void)removeItemAtIndex:(NSInteger)index; | 148 - (void)removeItemAtIndex:(NSInteger)index; |
133 | 149 |
134 // Determines whether a navigation between |firstEntry| and |secondEntry| is a | 150 // Determines whether a navigation between |firstEntry| and |secondEntry| is a |
135 // same-document navigation. Entries can be passed in any order. | 151 // same-document navigation. Entries can be passed in any order. |
136 - (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem | 152 - (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem |
137 andItem:(web::NavigationItem*)secondItem; | 153 andItem:(web::NavigationItem*)secondItem; |
138 | 154 |
139 // Returns the index of |item| in |items|. | 155 // Returns the index of |item| in |items|. |
140 - (NSInteger)indexOfItem:(const web::NavigationItem*)item; | 156 - (NSInteger)indexOfItem:(const web::NavigationItem*)item; |
141 | 157 |
142 // Returns the item at |index| in |items|. | 158 // Returns the item at |index| in |items|. |
143 - (web::NavigationItemImpl*)itemAtIndex:(NSInteger)index; | 159 - (web::NavigationItemImpl*)itemAtIndex:(NSInteger)index; |
144 | 160 |
145 @end | 161 @end |
146 | 162 |
147 #endif // IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ | 163 #endif // IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ |
OLD | NEW |