1 // Copyright 2013 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.
5 #ifndef IOS_WEB_PUBLIC_NAVIGATION_MANAGER_H_
6 #define IOS_WEB_PUBLIC_NAVIGATION_MANAGER_H_
8 #include "ios/web/public/browser_url_rewriter.h"
16 // A NavigationManager maintains the back-forward list for a WebState and
17 // manages all navigation within that list.
19 // Each NavigationManager belongs to one WebState; each WebState has
20 // exactly one NavigationManager.
21 class NavigationManager
{
23 virtual ~NavigationManager() {}
25 // Gets the BrowserState associated with this NavigationManager. Can never
27 virtual BrowserState
* GetBrowserState() const = 0;
29 // Gets the WebState associated with this NavigationManager.
30 virtual WebState
* GetWebState() const = 0;
32 // Returns the NavigationItem that should be used when displaying info about
33 // the current entry to the user. It ignores certain pending entries, to
34 // prevent spoofing attacks using slow-loading navigations.
35 virtual NavigationItem
* GetVisibleItem() const = 0;
37 // Returns the last committed NavigationItem, which may be null if there
38 // are no committed entries.
39 virtual NavigationItem
* GetLastCommittedItem() const = 0;
41 // Returns the pending entry corresponding to the navigation that is
42 // currently in progress, or null if there is none.
43 virtual NavigationItem
* GetPendingItem() const = 0;
45 // Removes the transient and pending NavigationItems.
46 virtual void DiscardNonCommittedItems() = 0;
48 // Currently a no-op, but present to be called in contexts where
49 // NavigationController::LoadIfNecessary() is called in the analogous
50 // //content-based context. In particular, likely will become more than
51 // a no-op if NavigationManager::SetNeedsReload() becomes necessary to
52 // match NavigationController::SetNeedsReload().
53 virtual void LoadIfNecessary() = 0;
55 // Adds |rewriter| to a transient list of URL rewriters. Transient URL
56 // rewriters will be executed before the rewriters already added to the
57 // BrowserURLRewriter singleton, and the list will be cleared after the next
58 // attempted page load. |rewriter| must not be null.
59 virtual void AddTransientURLRewriter(
60 BrowserURLRewriter::URLRewriter rewriter
) = 0;
62 // Returns the number of items in the NavigationManager, excluding
63 // pending and transient entries.
64 virtual int GetEntryCount() const = 0;
66 // Returns the committed NavigationItem at |index|.
67 virtual NavigationItem
* GetItemAtIndex(size_t index
) const = 0;
69 // Returns the index from which web would go back/forward or reload.
70 virtual int GetCurrentEntryIndex() const = 0;
72 // Returns the index of the pending item or -1 if the pending item
73 // corresponds to a new navigation.
74 virtual int GetPendingItemIndex() const = 0;
79 #endif // IOS_WEB_PUBLIC_NAVIGATION_MANAGER_H_