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

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

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

Powered by Google App Engine
This is Rietveld 408576698