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

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

Issue 2672723003: Converted CRWSessionController to use NavigationItems. (Closed)
Patch Set: test fixes, 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 #import "ios/web/navigation/navigation_item_impl_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 ScopedNavigationItemImplList used to store the NavigationItemImpls for
49 // this session.
50 @property(nonatomic, readonly) const web::ScopedNavigationItemImplList& 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
60 // CRWSessionController doesn't have public constructors. New 90 // CRWSessionController doesn't have public constructors. New
61 // CRWSessionControllers are created by deserialization, or via a 91 // CRWSessionControllers are created by deserialization, or via a
62 // NavigationManager. 92 // NavigationManager.
63 93
64 // Sets the corresponding NavigationManager. 94 // Sets the corresponding NavigationManager.
65 - (void)setNavigationManager:(web::NavigationManagerImpl*)navigationManager; 95 - (void)setNavigationManager:(web::NavigationManagerImpl*)navigationManager;
96 // Sets the coresponding BrowserState.
97 - (void)setBrowserState:(web::BrowserState*)browserState;
66 98
67 // 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
68 // 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
69 // 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
70 // out as pending, and will be lost unless |-commitPendingEntry| is called. 102 // out as pending, and will be lost unless |-commitPendingItem| is called.
71 - (void)addPendingEntry:(const GURL&)url 103 - (void)addPendingItem:(const GURL&)url
72 referrer:(const web::Referrer&)referrer 104 referrer:(const web::Referrer&)referrer
73 transition:(ui::PageTransition)type 105 transition:(ui::PageTransition)type
74 rendererInitiated:(BOOL)rendererInitiated; 106 rendererInitiated:(BOOL)rendererInitiated;
75 107
76 // 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
77 // redirects. Does nothing if there is no pending entry. 109 // redirects. Does nothing if there is no pending item.
78 - (void)updatePendingEntry:(const GURL&)url; 110 - (void)updatePendingItem:(const GURL&)url;
79 111
80 // 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
81 // this process, it is just moved from pending to committed. 113 // this process, it is just moved from pending to committed.
82 // TODO(pinkerton): Desktop Chrome broadcasts a notification here, should we? 114 // TODO(pinkerton): Desktop Chrome broadcasts a notification here, should we?
83 - (void)commitPendingEntry; 115 - (void)commitPendingItem;
84 116
85 // 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
86 // discarded on any navigation. 118 // discarded on any navigation.
87 // 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
88 // be made from outside and then handed in. 120 // be made from outside and then handed in.
89 - (void)addTransientEntryWithURL:(const GURL&)URL; 121 - (void)addTransientItemWithURL:(const GURL&)URL;
90 122
91 // 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
92 // 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
93 // 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
94 // new entry's referrer. 126 // new item's referrer.
95 - (void)pushNewEntryWithURL:(const GURL&)URL 127 - (void)pushNewItemWithURL:(const GURL&)URL
96 stateObject:(NSString*)stateObject 128 stateObject:(NSString*)stateObject
97 transition:(ui::PageTransition)transition; 129 transition:(ui::PageTransition)transition;
98 130
99 // Updates the URL and state object for the current entry. 131 // Updates the URL and state object for the current item.
100 - (void)updateCurrentEntryWithURL:(const GURL&)url 132 - (void)updateCurrentItemWithURL:(const GURL&)url
101 stateObject:(NSString*)stateObject; 133 stateObject:(NSString*)stateObject;
102 134
103 - (void)discardNonCommittedEntries; 135 // Removes the pending and transient NavigationItems.
136 - (void)discardNonCommittedItems;
104 137
105 // Returns YES if there is a pending entry. 138 // Inserts history state from |otherController| to the front of |items|. This
106 - (BOOL)hasPendingEntry; 139 // function transfers ownership of |otherController|'s NavigationItems to the
107 140 // receiver.
108 // Inserts history state from the given CRWSessionController to the front of
109 // this controller.
110 - (void)insertStateFromSessionController:(CRWSessionController*)otherController; 141 - (void)insertStateFromSessionController:(CRWSessionController*)otherController;
111 142
112 // 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.
113 - (void)goToEntryAtIndex:(NSInteger)index; 144 - (void)goToItemAtIndex:(NSInteger)index;
114 145
115 // Removes the entry at |index| after discarding any noncomitted entries. 146 // 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 147 // |index| must not be the index of the last committed item, or a noncomitted
117 // entry. 148 // item.
118 - (void)removeEntryAtIndex:(NSInteger)index; 149 - (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 150
128 // Determines whether a navigation between |firstEntry| and |secondEntry| is a 151 // Determines whether a navigation between |firstEntry| and |secondEntry| is a
129 // same-document navigation. Entries can be passed in any order. 152 // same-document navigation. Entries can be passed in any order.
130 - (BOOL)isSameDocumentNavigationBetweenEntry:(CRWSessionEntry*)firstEntry 153 - (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem
131 andEntry:(CRWSessionEntry*)secondEntry; 154 andItem:(web::NavigationItem*)secondItem;
132 155
133 // Find the most recent session entry that is not a redirect. Returns nil if 156 // Set |useDesktopUserAgentForNextPendingItem_| to YES if there is no pending
134 // |entries_| is empty. 157 // entry, otherwise set |useDesktopUserAgent| in the pending entry.
135 - (CRWSessionEntry*)lastUserEntry; 158 - (void)useDesktopUserAgentForNextPendingItem;
136 159
137 // Set |useDesktopUserAgentForNextPendingEntry_| to YES if there is no pending 160 // Returns the index of |item| in |items|.
138 // entry, otherwise set |useDesktopUserAgent| in the pending entry. 161 - (NSInteger)indexOfItem:(web::NavigationItem*)item;
139 - (void)useDesktopUserAgentForNextPendingEntry;
140 162
141 @end 163 @end
142 164
143 #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