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

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

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

Powered by Google App Engine
This is Rietveld 408576698