OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ |
| 6 #define IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 #include <vector> |
| 10 |
| 11 #include "ui/base/page_transition_types.h" |
| 12 #include "url/gurl.h" |
| 13 |
| 14 @class CRWSessionEntry; |
| 15 @class CRWSessionCertificatePolicyManager; |
| 16 @class XCallbackParameters; |
| 17 |
| 18 namespace web { |
| 19 class NavigationManagerImpl; |
| 20 struct Referrer; |
| 21 struct SSLStatus; |
| 22 } |
| 23 |
| 24 // A CRWSessionController is similar to a NavigationController object in desktop |
| 25 // Chrome. It maintains information needed to save/restore a tab with its |
| 26 // complete session history. There is one of these for each tab. |
| 27 // TODO(stuartmorgan): Move under NavigationManager, and consider merging into |
| 28 // NavigationManager. |
| 29 @interface CRWSessionController : NSObject<NSCoding, NSCopying> |
| 30 |
| 31 @property(nonatomic, readonly, retain) NSString* tabId; |
| 32 @property(nonatomic, readonly, assign) NSInteger currentNavigationIndex; |
| 33 @property(nonatomic, readonly, assign) NSInteger previousNavigationIndex; |
| 34 @property(nonatomic, readonly, retain) NSArray* entries; |
| 35 @property(nonatomic, copy) NSString* windowName; |
| 36 // Indicates whether the page was opened by DOM (e.g. with |window.open| |
| 37 // JavaScript call or by clicking a link with |_blank| target). |
| 38 @property(nonatomic, readonly, getter=isOpenedByDOM) BOOL openedByDOM; |
| 39 @property(nonatomic, readonly, retain) |
| 40 CRWSessionCertificatePolicyManager* sessionCertificatePolicyManager; |
| 41 // Returns the current entry in the session list, or the pending entry if there |
| 42 // is a navigation in progress. |
| 43 @property(nonatomic, readonly) CRWSessionEntry* currentEntry; |
| 44 // Returns the entry that should be displayed to users (e.g., in the omnibox). |
| 45 @property(nonatomic, readonly) CRWSessionEntry* visibleEntry; |
| 46 // Returns the pending entry, if any. |
| 47 @property(nonatomic, readonly) CRWSessionEntry* pendingEntry; |
| 48 // Returns the transient entry, if any. |
| 49 @property(nonatomic, readonly) CRWSessionEntry* transientEntry; |
| 50 // Returns the last committed entry. |
| 51 @property(nonatomic, readonly) CRWSessionEntry* lastCommittedEntry; |
| 52 // Returns the previous entry in the session list, or nil if there isn't any. |
| 53 @property(nonatomic, readonly) CRWSessionEntry* previousEntry; |
| 54 @property(nonatomic, assign) NSTimeInterval lastVisitedTimestamp; |
| 55 @property(nonatomic, readonly, copy) NSString* openerId; |
| 56 @property(nonatomic, readonly, assign) NSInteger openerNavigationIndex; |
| 57 @property(nonatomic, retain) XCallbackParameters* xCallbackParameters; |
| 58 |
| 59 // CRWSessionController doesn't have public constructors. New |
| 60 // CRWSessionControllers are created by deserialization, or via a |
| 61 // NavigationManager. |
| 62 |
| 63 // Sets the corresponding NavigationManager. |
| 64 - (void)setNavigationManager:(web::NavigationManagerImpl*)navigationManager; |
| 65 |
| 66 // Add a new entry with the given url, referrer, and navigation type, making it |
| 67 // the current entry. If |url| is the same as the current entry's url, this |
| 68 // does nothing. |referrer| may be nil if there isn't one. The entry starts |
| 69 // out as pending, and will be lost unless |-commitPendingEntry| is called. |
| 70 - (void)addPendingEntry:(const GURL&)url |
| 71 referrer:(const web::Referrer&)referrer |
| 72 transition:(ui::PageTransition)type |
| 73 rendererInitiated:(BOOL)rendererInitiated; |
| 74 |
| 75 // Updates the URL of the yet to be committed pending entry. Useful for page |
| 76 // redirects. Does nothing if there is no pending entry. |
| 77 - (void)updatePendingEntry:(const GURL&)url; |
| 78 |
| 79 // Commits the current pending entry. No changes are made to the entry during |
| 80 // this process, it is just moved from pending to committed. |
| 81 // TODO(pinkerton): Desktop Chrome broadcasts a notification here, should we? |
| 82 - (void)commitPendingEntry; |
| 83 |
| 84 // Adds a transient entry with the given information. A transient entry will be |
| 85 // discarded on any navigation. |
| 86 // TODO(stuartmorgan): Make this work more like upstream, where the entry can |
| 87 // be made from outside and then handed in, instead of having to pass a bunch |
| 88 // of construction params here. |
| 89 - (void)addTransientEntry:(const GURL&)url |
| 90 title:(const base::string16&)title |
| 91 sslStatus:(const web::SSLStatus*)status; |
| 92 |
| 93 // Creates a new CRWSessionEntry with the given URL and state object. A state |
| 94 // object is a serialized generic JavaScript object that contains details of the |
| 95 // UI's state for a given CRWSessionEntry/URL. The current entry's URL is the |
| 96 // new entry's referrer. |
| 97 - (void)pushNewEntryWithURL:(const GURL&)url stateObject:(NSString*)stateObject; |
| 98 // Updates the URL and state object for the current entry. |
| 99 - (void)updateCurrentEntryWithURL:(const GURL&)url |
| 100 stateObject:(NSString*)stateObject; |
| 101 |
| 102 - (void)discardNonCommittedEntries; |
| 103 |
| 104 // Returns YES if there is a pending entry. |
| 105 - (BOOL)hasPendingEntry; |
| 106 |
| 107 // Copies history state from the given CRWSessionController and adds it to this |
| 108 // controller. If |replaceState|, replaces the state of this controller with |
| 109 // the state of |otherSession|, instead of appending. |
| 110 - (void)copyStateFromAndPrune:(CRWSessionController*)otherSession |
| 111 replaceState:(BOOL)replaceState; |
| 112 |
| 113 // Returns YES if there are entries to go back or forward to, given the |
| 114 // current entry. |
| 115 - (BOOL)canGoBack; |
| 116 - (BOOL)canGoForward; |
| 117 // Adjusts the current entry to reflect the navigation in the corresponding |
| 118 // direction in history. |
| 119 - (void)goBack; |
| 120 - (void)goForward; |
| 121 // Calls goBack or goForward the appropriate number of times to adjust |
| 122 // currentNavigationIndex_ by delta. |
| 123 - (void)goDelta:(int)delta; |
| 124 // Sets |currentNavigationIndex_| to the index of |entry| if |entries_| contains |
| 125 // |entry|. |
| 126 - (void)goToEntry:(CRWSessionEntry*)entry; |
| 127 |
| 128 // Removes the entry at |index| after discarding any noncomitted entries. |
| 129 // |index| must not be the index of the last committed entry, or a noncomitted |
| 130 // entry. |
| 131 - (void)removeEntryAtIndex:(NSInteger)index; |
| 132 |
| 133 // Returns an array containing all of the non-redirected CRWSessionEntry objects |
| 134 // whose index in |entries_| is less than |currentNavigationIndex_|. |
| 135 - (NSArray*)backwardEntries; |
| 136 |
| 137 // Returns an array containing all of the non-redirected CRWSessionEntry objects |
| 138 // whose index in |entries_| is greater than |currentNavigationIndex_|. |
| 139 - (NSArray*)forwardEntries; |
| 140 |
| 141 // Returns the URLs in the entries that are redirected to the current entry. |
| 142 - (std::vector<GURL>)currentRedirectedUrls; |
| 143 |
| 144 // Determines if navigation between the two given entries is a push state |
| 145 // navigation. Entries can be passed in in any order. |
| 146 - (BOOL)isPushStateNavigationBetweenEntry:(CRWSessionEntry*)firstEntry |
| 147 andEntry:(CRWSessionEntry*)secondEntry; |
| 148 |
| 149 // Find the most recent session entry that is not a redirect. Returns nil if |
| 150 // |entries_| is empty. |
| 151 - (CRWSessionEntry*)lastUserEntry; |
| 152 |
| 153 // Set |useDesktopUserAgentForNextPendingEntry_| to YES if there is no pending |
| 154 // entry, otherwise set |useDesktopUserAgent| in the pending entry. |
| 155 - (void)useDesktopUserAgentForNextPendingEntry; |
| 156 |
| 157 @end |
| 158 |
| 159 #endif // IOS_WEB_NAVIGATION_CRW_SESSION_CONTROLLER_H_ |
OLD | NEW |