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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/navigation/crw_session_controller.h
diff --git a/ios/web/navigation/crw_session_controller.h b/ios/web/navigation/crw_session_controller.h
index bdfd83484113abaf30a237265e51ad6cafde40ed..f5fb9a1e5c7bf219f929cce108c126fadcde8471 100644
--- a/ios/web/navigation/crw_session_controller.h
+++ b/ios/web/navigation/crw_session_controller.h
@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
#include <vector>
+#import "ios/web/navigation/navigation_item_impl_list.h"
#include "ui/base/page_transition_types.h"
#include "url/gurl.h"
@@ -15,6 +16,7 @@
@class CRWSessionCertificatePolicyManager;
namespace web {
+class BrowserState;
class NavigationManagerImpl;
struct Referrer;
}
@@ -30,32 +32,60 @@ struct Referrer;
@property(nonatomic, readonly, copy) NSString* tabId;
@property(nonatomic, readonly, assign) NSInteger currentNavigationIndex;
@property(nonatomic, readonly, assign) NSInteger previousNavigationIndex;
-// The index of the pending entry if it is in entries_, or -1 if pendingEntry is
-// a new entry (created by addPendingEntry:).
-@property(nonatomic, readwrite, assign) NSInteger pendingEntryIndex;
-@property(nonatomic, readonly, strong) NSArray* entries;
+// The index of the pending item if it is in |items|, or -1 if |pendingItem|
+// corresponds with a new navigation (created by addPendingItem:).
+@property(nonatomic, readwrite, assign) NSInteger pendingItemIndex;
@property(nonatomic, copy) NSString* windowName;
// Indicates whether the page was opened by DOM (e.g. with |window.open|
// JavaScript call or by clicking a link with |_blank| target).
@property(nonatomic, readonly, getter=isOpenedByDOM) BOOL openedByDOM;
@property(nonatomic, readonly, strong)
CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager;
-// Returns the current entry in the session list, or the pending entry if there
-// is a navigation in progress.
+@property(nonatomic, assign) NSTimeInterval lastVisitedTimestamp;
+@property(nonatomic, readonly, copy) NSString* openerId;
+@property(nonatomic, readonly, assign) NSInteger openerNavigationIndex;
+
+// The ScopedNavigationItemImplList used to store the NavigationItemImpls for
+// this session.
+@property(nonatomic, readonly) const web::ScopedNavigationItemImplList& items;
+// The current NavigationItem. During a pending navigation, returns the
+// NavigationItem for that navigation. If a transient NavigationItem exists,
+// this NavigationItem will be returned.
+@property(nonatomic, readonly) web::NavigationItemImpl* currentItem;
+// Returns the NavigationItem whose URL should be displayed to the user.
+@property(nonatomic, readonly) web::NavigationItemImpl* visibleItem;
+// Returns the NavigationItem corresponding to a load for which no data has yet
+// been received.
+@property(nonatomic, readonly) web::NavigationItemImpl* pendingItem;
+// Returns the NavigationItem corresponding with a transient navigation (i.e.
+// SSL interstitials).
+@property(nonatomic, readonly) web::NavigationItemImpl* transientItem;
+// Returns the NavigationItem corresponding with the last committed load.
+@property(nonatomic, readonly) web::NavigationItemImpl* lastCommittedItem;
+// Returns the NavigationItem corresponding with the previously loaded page.
+@property(nonatomic, readonly) web::NavigationItemImpl* previousItem;
+// Returns most recent NavigationItem that is not a redirect. Returns nil if
+// |items| is empty.
+@property(nonatomic, readonly) web::NavigationItemImpl* lastUserItem;
+// Returns a list of all non-redirected NavigationItems whose index precedes
+// |currentNavigationIndex|.
+@property(nonatomic, readonly) web::NavigationItemList backwardItems;
+// Returns a list of all non-redirected NavigationItems whose index follow
+// |currentNavigationIndex|.
+@property(nonatomic, readonly) web::NavigationItemList forwardItems;
+
+// DEPRECATED: Don't add new usage of these properties. Instead, use the
+// NavigationItem versions of these properties above.
+@property(nonatomic, readonly, strong) NSArray* entries;
@property(nonatomic, readonly, strong) CRWSessionEntry* currentEntry;
-// Returns the entry that should be displayed to users (e.g., in the omnibox).
@property(nonatomic, readonly, strong) CRWSessionEntry* visibleEntry;
-// Returns the pending entry, if any.
@property(nonatomic, readonly, strong) CRWSessionEntry* pendingEntry;
-// Returns the transient entry, if any.
@property(nonatomic, readonly, strong) CRWSessionEntry* transientEntry;
-// Returns the last committed entry.
@property(nonatomic, readonly, strong) CRWSessionEntry* lastCommittedEntry;
-// Returns the previous entry in the session list, or nil if there isn't any.
@property(nonatomic, readonly, strong) CRWSessionEntry* previousEntry;
-@property(nonatomic, assign) NSTimeInterval lastVisitedTimestamp;
-@property(nonatomic, readonly, copy) NSString* openerId;
-@property(nonatomic, readonly, assign) NSInteger openerNavigationIndex;
+@property(nonatomic, readonly, strong) CRWSessionEntry* lastUserEntry;
+@property(nonatomic, readonly, weak) NSArray* backwardEntries;
+@property(nonatomic, readonly, weak) NSArray* forwardEntries;
// CRWSessionController doesn't have public constructors. New
// CRWSessionControllers are created by deserialization, or via a
@@ -63,80 +93,72 @@ struct Referrer;
// Sets the corresponding NavigationManager.
- (void)setNavigationManager:(web::NavigationManagerImpl*)navigationManager;
-
-// Add a new entry with the given url, referrer, and navigation type, making it
-// the current entry. If |url| is the same as the current entry's url, this
-// does nothing. |referrer| may be nil if there isn't one. The entry starts
-// out as pending, and will be lost unless |-commitPendingEntry| is called.
-- (void)addPendingEntry:(const GURL&)url
- referrer:(const web::Referrer&)referrer
- transition:(ui::PageTransition)type
- rendererInitiated:(BOOL)rendererInitiated;
-
-// Updates the URL of the yet to be committed pending entry. Useful for page
-// redirects. Does nothing if there is no pending entry.
-- (void)updatePendingEntry:(const GURL&)url;
-
-// Commits the current pending entry. No changes are made to the entry during
+// Sets the coresponding BrowserState.
+- (void)setBrowserState:(web::BrowserState*)browserState;
+
+// Add a new item with the given url, referrer, and navigation type, making it
+// the current item. If |url| is the same as the current item's url, this
+// does nothing. |referrer| may be nil if there isn't one. The item starts
+// out as pending, and will be lost unless |-commitPendingItem| is called.
+- (void)addPendingItem:(const GURL&)url
+ referrer:(const web::Referrer&)referrer
+ transition:(ui::PageTransition)type
+ rendererInitiated:(BOOL)rendererInitiated;
+
+// Updates the URL of the yet to be committed pending item. Useful for page
+// redirects. Does nothing if there is no pending item.
+- (void)updatePendingItem:(const GURL&)url;
+
+// Commits the current pending item. No changes are made to the item during
// this process, it is just moved from pending to committed.
// TODO(pinkerton): Desktop Chrome broadcasts a notification here, should we?
-- (void)commitPendingEntry;
+- (void)commitPendingItem;
-// Adds a transient entry with the given URL. A transient entry will be
+// Adds a transient item with the given URL. A transient item will be
// discarded on any navigation.
-// TODO(stuartmorgan): Make this work more like upstream, where the entry can
+// TODO(stuartmorgan): Make this work more like upstream, where the item can
// be made from outside and then handed in.
-- (void)addTransientEntryWithURL:(const GURL&)URL;
+- (void)addTransientItemWithURL:(const GURL&)URL;
// Creates a new CRWSessionEntry with the given URL and state object. A state
// object is a serialized generic JavaScript object that contains details of the
-// UI's state for a given CRWSessionEntry/URL. The current entry's URL is the
-// new entry's referrer.
-- (void)pushNewEntryWithURL:(const GURL&)URL
- stateObject:(NSString*)stateObject
- transition:(ui::PageTransition)transition;
-
-// Updates the URL and state object for the current entry.
-- (void)updateCurrentEntryWithURL:(const GURL&)url
- stateObject:(NSString*)stateObject;
-
-- (void)discardNonCommittedEntries;
-
-// Returns YES if there is a pending entry.
-- (BOOL)hasPendingEntry;
-
-// Inserts history state from the given CRWSessionController to the front of
-// this controller.
+// UI's state for a given CRWSessionEntry/URL. The current item's URL is the
+// new item's referrer.
+- (void)pushNewItemWithURL:(const GURL&)URL
+ stateObject:(NSString*)stateObject
+ transition:(ui::PageTransition)transition;
+
+// Updates the URL and state object for the current item.
+- (void)updateCurrentItemWithURL:(const GURL&)url
+ stateObject:(NSString*)stateObject;
+
+// Removes the pending and transient NavigationItems.
+- (void)discardNonCommittedItems;
+
+// Inserts history state from |otherController| to the front of |items|. This
+// function transfers ownership of |otherController|'s NavigationItems to the
+// receiver.
- (void)insertStateFromSessionController:(CRWSessionController*)otherController;
// Sets |currentNavigationIndex_| to the |index| if it's in the entries bounds.
-- (void)goToEntryAtIndex:(NSInteger)index;
-
-// Removes the entry at |index| after discarding any noncomitted entries.
-// |index| must not be the index of the last committed entry, or a noncomitted
-// entry.
-- (void)removeEntryAtIndex:(NSInteger)index;
-
-// Returns an array containing all of the non-redirected CRWSessionEntry objects
-// whose index in |entries_| is less than |currentNavigationIndex_|.
-- (NSArray*)backwardEntries;
+- (void)goToItemAtIndex:(NSInteger)index;
-// Returns an array containing all of the non-redirected CRWSessionEntry objects
-// whose index in |entries_| is greater than |currentNavigationIndex_|.
-- (NSArray*)forwardEntries;
+// Removes the item at |index| after discarding any noncomitted entries.
+// |index| must not be the index of the last committed item, or a noncomitted
+// item.
+- (void)removeItemAtIndex:(NSInteger)index;
// Determines whether a navigation between |firstEntry| and |secondEntry| is a
// same-document navigation. Entries can be passed in any order.
-- (BOOL)isSameDocumentNavigationBetweenEntry:(CRWSessionEntry*)firstEntry
- andEntry:(CRWSessionEntry*)secondEntry;
+- (BOOL)isSameDocumentNavigationBetweenItem:(web::NavigationItem*)firstItem
+ andItem:(web::NavigationItem*)secondItem;
-// Find the most recent session entry that is not a redirect. Returns nil if
-// |entries_| is empty.
-- (CRWSessionEntry*)lastUserEntry;
-
-// Set |useDesktopUserAgentForNextPendingEntry_| to YES if there is no pending
+// Set |useDesktopUserAgentForNextPendingItem_| to YES if there is no pending
// entry, otherwise set |useDesktopUserAgent| in the pending entry.
-- (void)useDesktopUserAgentForNextPendingEntry;
+- (void)useDesktopUserAgentForNextPendingItem;
+
+// Returns the index of |item| in |items|.
+- (NSInteger)indexOfItem:(web::NavigationItem*)item;
@end
« 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