Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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_NAVIGATION_MANAGER_IMPL_H_ | 5 #ifndef IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ |
| 6 #define IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ | 6 #define IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/mac/scoped_nsobject.h" | 11 #include "base/mac/scoped_nsobject.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "ios/web/public/navigation_manager.h" | 13 #include "ios/web/public/navigation_manager.h" |
| 14 #include "ui/base/page_transition_types.h" | 14 #include "ui/base/page_transition_types.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 @class CRWSessionController; | 17 @class CRWSessionController; |
| 18 @class CRWSessionEntry; | 18 @class CRWSessionEntry; |
| 19 | 19 |
| 20 namespace web { | 20 namespace web { |
| 21 class BrowserState; | 21 class BrowserState; |
| 22 class NavigationItem; | 22 class NavigationItem; |
| 23 struct Referrer; | 23 struct Referrer; |
| 24 class NavigationManagerDelegate; | 24 class NavigationManagerDelegate; |
| 25 class NavigationManagerFacadeDelegate; | 25 class NavigationManagerFacadeDelegate; |
| 26 class SerializedNavigationManagerBuilder; | |
| 26 | 27 |
| 27 // Implementation of NavigationManager. | 28 // Implementation of NavigationManager. |
| 28 // Generally mirrors upstream's NavigationController. | 29 // Generally mirrors upstream's NavigationController. |
| 29 class NavigationManagerImpl : public NavigationManager { | 30 class NavigationManagerImpl : public NavigationManager { |
| 30 public: | 31 public: |
| 31 NavigationManagerImpl(NavigationManagerDelegate* delegate, | 32 NavigationManagerImpl(); |
| 32 BrowserState* browser_state); | |
| 33 ~NavigationManagerImpl() override; | 33 ~NavigationManagerImpl() override; |
| 34 | 34 |
| 35 // Setters for NavigationManagerDelegate and BrowserState. | |
| 36 void SetDelegate(NavigationManagerDelegate* delegate); | |
| 37 void SetBrowserState(BrowserState* browser_state); | |
| 38 | |
| 35 // Sets the CRWSessionController that backs this object. | 39 // Sets the CRWSessionController that backs this object. |
| 36 // Keeps a strong reference to |session_controller|. | 40 // Keeps a strong reference to |session_controller|. |
| 37 // This method should only be called when deserializing |session_controller| | 41 // This method should only be called when deserializing |session_controller| |
| 38 // and joining it with its NavigationManager. Other cases should call | 42 // and joining it with its NavigationManager. Other cases should call |
| 39 // InitializeSession() or ReplaceSessionHistory(). | 43 // InitializeSession() or ReplaceSessionHistory(). |
| 40 // TODO(stuartmorgan): Also move deserialization of CRWSessionControllers | 44 // TODO(stuartmorgan): Also move deserialization of CRWSessionControllers |
| 41 // under the control of this class, and move the bulk of CRWSessionController | 45 // under the control of this class, and move the bulk of CRWSessionController |
| 42 // logic into it. | 46 // logic into it. |
| 43 void SetSessionController(CRWSessionController* session_controller); | 47 void SetSessionController(CRWSessionController* session_controller); |
| 44 | 48 |
| 45 // Initializes a new session history, supplying a unique |window_name| for the | 49 // 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. | 50 // 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. | 51 // |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 | 52 // |opener_index| is the navigation index of the opener, or -1 if there is |
| 49 // none. | 53 // none. |
| 50 void InitializeSession(NSString* window_name, | 54 void InitializeSession(NSString* window_name, |
| 51 NSString* opener_id, | 55 NSString* opener_id, |
| 52 BOOL opened_by_dom, | 56 BOOL opened_by_dom, |
| 53 int opener_navigation_index); | 57 int opener_navigation_index); |
| 54 | 58 |
| 55 // Replace the session history with a new one, where |items| is the | 59 // 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| | 60 // complete set of navigation items in the new history, and |current_index| |
| 57 // is the index of the currently active item. | 61 // is the index of the currently active item. |
| 58 void ReplaceSessionHistory(ScopedVector<NavigationItem> items, | 62 void ReplaceSessionHistory(ScopedVector<NavigationItem> items, |
| 59 int current_index); | 63 int current_index); |
| 60 | 64 |
| 65 // Returns a copy of the NavigationManager for use in serialization. Does not | |
|
Eugene But (OOO till 7-30)
2015/09/23 16:33:44
Deep copy or shallow copy?
kkhorimoto
2015/09/24 18:12:59
Deep. I've added a comment.
| |
| 66 // copy |delegate_| or |facade_delegate_|. | |
| 67 scoped_ptr<NavigationManagerImpl> CopyForSerialization() const; | |
| 68 | |
| 61 // Sets the delegate used to drive the navigation controller facade. | 69 // Sets the delegate used to drive the navigation controller facade. |
| 62 void SetFacadeDelegate(NavigationManagerFacadeDelegate* facade_delegate); | 70 void SetFacadeDelegate(NavigationManagerFacadeDelegate* facade_delegate); |
| 63 NavigationManagerFacadeDelegate* GetFacadeDelegate() const; | 71 NavigationManagerFacadeDelegate* GetFacadeDelegate() const; |
| 64 | 72 |
| 65 // Helper functions for communicating with the facade layer. | 73 // Helper functions for communicating with the facade layer. |
| 66 // TODO(stuartmorgan): Make these private once the logic triggering them moves | 74 // TODO(stuartmorgan): Make these private once the logic triggering them moves |
| 67 // into this layer. | 75 // into this layer. |
| 68 void OnNavigationItemChanged(); | 76 void OnNavigationItemChanged(); |
| 69 void OnNavigationItemCommitted(); | 77 void OnNavigationItemCommitted(); |
| 70 | 78 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 123 | 131 |
| 124 // Called to reset the transient url rewriter list. | 132 // Called to reset the transient url rewriter list. |
| 125 void RemoveTransientURLRewriters(); | 133 void RemoveTransientURLRewriters(); |
| 126 | 134 |
| 127 // Copy state from |navigation_manager|, including a copy of that object's | 135 // Copy state from |navigation_manager|, including a copy of that object's |
| 128 // CRWSessionController. | 136 // CRWSessionController. |
| 129 // TODO(marq): This doesn't deep-copy the SessionEntries in the | 137 // TODO(marq): This doesn't deep-copy the SessionEntries in the |
| 130 // CRWSessionController. | 138 // CRWSessionController. |
| 131 void CopyState(NavigationManagerImpl* navigation_manager); | 139 void CopyState(NavigationManagerImpl* navigation_manager); |
| 132 private: | 140 private: |
| 141 friend SerializedNavigationManagerBuilder; | |
| 142 | |
| 133 // The primary delegate for this manager. | 143 // The primary delegate for this manager. |
| 134 NavigationManagerDelegate* delegate_; | 144 NavigationManagerDelegate* delegate_; |
| 135 | 145 |
| 136 // The BrowserState that is associated with this instance. | 146 // The BrowserState that is associated with this instance. |
| 137 BrowserState* browser_state_; | 147 BrowserState* browser_state_; |
| 138 | 148 |
| 139 // CRWSessionController that backs this instance. | 149 // CRWSessionController that backs this instance. |
| 140 // TODO(stuartmorgan): Fold CRWSessionController into this class. | 150 // TODO(stuartmorgan): Fold CRWSessionController into this class. |
| 141 base::scoped_nsobject<CRWSessionController> session_controller_; | 151 base::scoped_nsobject<CRWSessionController> session_controller_; |
| 142 | 152 |
| 143 // Weak pointer to the facade delegate. | 153 // Weak pointer to the facade delegate. |
| 144 NavigationManagerFacadeDelegate* facade_delegate_; | 154 NavigationManagerFacadeDelegate* facade_delegate_; |
| 145 | 155 |
| 146 // List of transient url rewriters added by |AddTransientURLRewriter()|. | 156 // List of transient url rewriters added by |AddTransientURLRewriter()|. |
| 147 scoped_ptr<std::vector<BrowserURLRewriter::URLRewriter>> | 157 scoped_ptr<std::vector<BrowserURLRewriter::URLRewriter>> |
| 148 transient_url_rewriters_; | 158 transient_url_rewriters_; |
| 149 | 159 |
| 150 DISALLOW_COPY_AND_ASSIGN(NavigationManagerImpl); | 160 DISALLOW_COPY_AND_ASSIGN(NavigationManagerImpl); |
| 151 }; | 161 }; |
| 152 | 162 |
| 153 } // namespace web | 163 } // namespace web |
| 154 | 164 |
| 155 #endif // IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ | 165 #endif // IOS_WEB_NAVIGATION_NAVIGATION_MANAGER_IMPL_H_ |
| OLD | NEW |