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_PUBLIC_NAVIGATION_MANAGER_H_ | 5 #ifndef IOS_WEB_PUBLIC_NAVIGATION_MANAGER_H_ |
| 6 #define IOS_WEB_PUBLIC_NAVIGATION_MANAGER_H_ | 6 #define IOS_WEB_PUBLIC_NAVIGATION_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 class NavigationItem; | 23 class NavigationItem; |
| 24 class WebState; | 24 class WebState; |
| 25 | 25 |
| 26 // A NavigationManager maintains the back-forward list for a WebState and | 26 // A NavigationManager maintains the back-forward list for a WebState and |
| 27 // manages all navigation within that list. | 27 // manages all navigation within that list. |
| 28 // | 28 // |
| 29 // Each NavigationManager belongs to one WebState; each WebState has | 29 // Each NavigationManager belongs to one WebState; each WebState has |
| 30 // exactly one NavigationManager. | 30 // exactly one NavigationManager. |
| 31 class NavigationManager { | 31 class NavigationManager { |
| 32 public: | 32 public: |
| 33 // User agent override option used in LoadURLParams. | |
| 34 enum class UserAgentOverrideOption : short { | |
| 35 // Inherit the user agent type from the last committed non-app specific item | |
|
Eugene But (OOO till 7-30)
2017/03/30 19:21:24
What if there are no committed items?
liaoyuke
2017/03/30 19:56:25
Done.
| |
| 36 // in the NavigationManager. | |
| 37 INHERIT = 0, | |
| 38 | |
| 39 // Use the mobile user agent. | |
| 40 MOBILE, | |
| 41 | |
| 42 // Use the desktop user agent. | |
| 43 DESKTOP | |
|
Eugene But (OOO till 7-30)
2017/03/30 19:21:24
Optional nit: it's a good practice to have comma a
liaoyuke
2017/03/30 19:56:25
Done.
| |
| 44 }; | |
| 45 | |
| 33 // Parameters for URL loading. Most parameters are optional, and can be left | 46 // Parameters for URL loading. Most parameters are optional, and can be left |
| 34 // at the default values set by the constructor. | 47 // at the default values set by the constructor. |
| 35 struct WebLoadParams { | 48 struct WebLoadParams { |
| 36 public: | 49 public: |
| 37 // The URL to load. Must be set. | 50 // The URL to load. Must be set. |
| 38 GURL url; | 51 GURL url; |
| 39 | 52 |
| 40 // The referrer for the load. May be empty. | 53 // The referrer for the load. May be empty. |
| 41 Referrer referrer; | 54 Referrer referrer; |
| 42 | 55 |
| 43 // The transition type for the load. Defaults to PAGE_TRANSITION_LINK. | 56 // The transition type for the load. Defaults to PAGE_TRANSITION_LINK. |
| 44 ui::PageTransition transition_type; | 57 ui::PageTransition transition_type; |
| 45 | 58 |
| 59 // The user agent override option for the load. Defualts to INHERIT. | |
| 60 UserAgentOverrideOption user_agent_override_option; | |
| 61 | |
| 46 // True for renderer-initiated navigations. This is | 62 // True for renderer-initiated navigations. This is |
| 47 // important for tracking whether to display pending URLs. | 63 // important for tracking whether to display pending URLs. |
| 48 bool is_renderer_initiated; | 64 bool is_renderer_initiated; |
| 49 | 65 |
| 50 // Any extra HTTP headers to add to the load. | 66 // Any extra HTTP headers to add to the load. |
| 51 base::scoped_nsobject<NSDictionary> extra_headers; | 67 base::scoped_nsobject<NSDictionary> extra_headers; |
| 52 | 68 |
| 53 // Any post data to send with the load. When setting this, you should | 69 // Any post data to send with the load. When setting this, you should |
| 54 // generally set a Content-Type header as well. | 70 // generally set a Content-Type header as well. |
| 55 base::scoped_nsobject<NSData> post_data; | 71 base::scoped_nsobject<NSData> post_data; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 // This ignores any pending or transient entries in |source|. This will be a | 188 // This ignores any pending or transient entries in |source|. This will be a |
| 173 // no-op if called while CanPruneAllButLastCommittedItem() is false. | 189 // no-op if called while CanPruneAllButLastCommittedItem() is false. |
| 174 virtual void CopyStateFromAndPrune(const NavigationManager* source) = 0; | 190 virtual void CopyStateFromAndPrune(const NavigationManager* source) = 0; |
| 175 | 191 |
| 176 // Whether the NavigationManager can prune all but the last committed item. | 192 // Whether the NavigationManager can prune all but the last committed item. |
| 177 // This is true when all the following conditions are met: | 193 // This is true when all the following conditions are met: |
| 178 // - There is a last committed NavigationItem. | 194 // - There is a last committed NavigationItem. |
| 179 // - There is no pending history navigation. | 195 // - There is no pending history navigation. |
| 180 // - There is no transient NavigationItem. | 196 // - There is no transient NavigationItem. |
| 181 virtual bool CanPruneAllButLastCommittedItem() const = 0; | 197 virtual bool CanPruneAllButLastCommittedItem() const = 0; |
| 182 | |
| 183 // Forces the pending item to be loaded using desktop user agent. Note that | |
| 184 // the pending item may or may not already exist. | |
| 185 // TODO(crbug.com/692303): Remove this when overriding the user agent doesn't | |
| 186 // create a new NavigationItem. | |
| 187 virtual void OverrideDesktopUserAgentForNextPendingItem() = 0; | |
| 188 }; | 198 }; |
| 189 | 199 |
| 190 } // namespace web | 200 } // namespace web |
| 191 | 201 |
| 192 #endif // IOS_WEB_PUBLIC_NAVIGATION_MANAGER_H_ | 202 #endif // IOS_WEB_PUBLIC_NAVIGATION_MANAGER_H_ |
| OLD | NEW |