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

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

Issue 1028603004: Upstream ios/web/navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ios-testing
Patch Set: Rebase and resync Created 5 years, 9 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
(Empty)
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.
4
5 #ifndef IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_
6 #define IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_
7
8 #include <vector>
9
10 #include "base/basictypes.h"
11 #include "base/mac/scoped_nsobject.h"
12 #include "base/memory/scoped_vector.h"
13 #include "ios/web/public/navigation_manager.h"
14 #include "ui/base/page_transition_types.h"
15 #include "url/gurl.h"
16
17 @class CRWSessionController;
18 @class CRWSessionEntry;
19
20 namespace web {
21 class BrowserState;
22 class NavigationItem;
23 struct Referrer;
24 class NavigationManagerDelegate;
25 class NavigationManagerFacadeDelegate;
26
27 // Implementation of NavigationManager.
28 // Generally mirrors upstream's NavigationController.
29 class NavigationManagerImpl : public web::NavigationManager {
30 public:
31 NavigationManagerImpl(NavigationManagerDelegate* delegate,
32 BrowserState* browser_state);
33 ~NavigationManagerImpl() override;
34
35 // Sets the CRWSessionController that backs this object.
36 // Keeps a strong reference to |session_controller|.
37 // This method should only be called when deserializing |session_controller|
38 // and joining it with its NavigationManager. Other cases should call
39 // InitializeSession() or ReplaceSessionHistory().
40 // TODO(stuartmorgan): Also move deserialization of CRWSessionControllers
41 // under the control of this class, and move the bulk of CRWSessionController
42 // logic into it.
43 void SetSessionController(CRWSessionController* session_controller);
44
45 // Initializes a new session history, supplying a unique |window_name| for the
46 // window (or nil). |opener_id| is the id of opener, or nil if there is none.
47 // |opened_by_dom| is YES if the page was opened by DOM.
48 // |opener_index| is the navigation index of the opener, or -1 if there is
49 // none.
50 void InitializeSession(NSString* window_name,
51 NSString* opener_id,
52 BOOL opened_by_dom,
53 int opener_navigation_index);
54
55 // Replace the session history with a new one, where |items| is the
56 // complete set of navigation items in the new history, and |current_index|
57 // is the index of the currently active item.
58 void ReplaceSessionHistory(ScopedVector<web::NavigationItem> items,
59 int current_index);
60
61 // Sets the delegate used to drive the navigation controller facade.
62 void SetFacadeDelegate(NavigationManagerFacadeDelegate* facade_delegate);
63 NavigationManagerFacadeDelegate* GetFacadeDelegate() const;
64
65 // Helper functions for communicating with the facade layer.
66 // TODO(stuartmorgan): Make these private once the logic triggering them moves
67 // into this layer.
68 void OnNavigationItemChanged();
69 void OnNavigationItemCommitted();
70
71 // Returns the pending entry corresponding to the navigation that is
72 // currently in progress, or nullptr if there is none.
73 NavigationItem* GetPendingItem() const;
74
75 // Returns the transient item if any. This is an item which is removed and
76 // discarded if any navigation occurs. Note that the returned item is owned
77 // by the navigation manager and may be deleted at any time.
78 NavigationItem* GetTransientItem() const;
79
80 // Returns the last committed NavigationItem, which may be NULL if there
81 // are no committed entries.
82 NavigationItem* GetLastCommittedItem() const;
83
84 // Returns the committed NavigationItem at |index|.
85 NavigationItem* GetItemAtIndex(size_t index) const;
86
87 // Temporary accessors and content/ class pass-throughs.
88 // TODO(stuartmorgan): Re-evaluate this list once the refactorings have
89 // settled down.
90 CRWSessionController* GetSessionController();
91 int GetCurrentEntryIndex() const;
92 int GetLastCommittedEntryIndex() const;
93 int GetEntryCount() const;
94 bool RemoveEntryAtIndex(int index);
95 void DiscardNonCommittedEntries();
96 int GetPendingEntryIndex() const;
97 void LoadURL(const GURL& url,
98 const web::Referrer& referrer,
99 ui::PageTransition type);
100 bool CanGoBack() const;
101 bool CanGoForward() const;
102 void GoBack();
103 void GoForward();
104
105 // Convenience accessors to get the underlying NavigationItems from the
106 // SessionEntries returned from |session_controller_|'s -lastUserEntry and
107 // -previousEntry methods.
108 // TODO(marq):Evaluate the long-term utility of these methods.
109 NavigationItem* GetLastUserItem() const;
110 NavigationItem* GetPreviousItem() const;
111
112 // Temporary method. Returns a vector of NavigationItems corresponding to
113 // the SessionEntries of the uderlying CRWSessionController.
114 // TOOD(marq): Remove this method and unfork its caller,
115 // TabRestoreServiceHelper::PopulateTab
116 std::vector<NavigationItem*> GetItems();
117
118 // NavigationManager:
119 BrowserState* GetBrowserState() const override;
120 WebState* GetWebState() const override;
121 web::NavigationItem* GetVisibleItem() const override;
122
123 // Copy state from |navigation_manager|, including a copy of that object's
124 // CRWSessionController.
125 // TODO(marq): This doesn't deep-copy the SessionEntries in the
126 // CRWSessionController.
127 void CopyState(NavigationManagerImpl* navigation_manager);
128 private:
129 // The primary delegate for this manager.
130 NavigationManagerDelegate* delegate_;
131
132 // The BrowserState that is associated with this instance.
133 BrowserState* browser_state_;
134
135 // CRWSessionController that backs this instance.
136 // TODO(stuartmorgan): Fold CRWSessionController into this class.
137 base::scoped_nsobject<CRWSessionController> session_controller_;
138
139 // Weak pointer to the facade delegate.
140 NavigationManagerFacadeDelegate* facade_delegate_;
141
142 DISALLOW_COPY_AND_ASSIGN(NavigationManagerImpl);
143 };
144
145 } // namespace web
146
147 #endif // IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_
OLDNEW
« no previous file with comments | « ios/web/navigation/navigation_manager_facade_delegate.h ('k') | ios/web/navigation/navigation_manager_impl.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698