| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_WEB_STATE_NAVIGATION_CONTEXT_H_ | 5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_NAVIGATION_CONTEXT_H_ |
| 6 #define IOS_WEB_PUBLIC_WEB_STATE_NAVIGATION_CONTEXT_H_ | 6 #define IOS_WEB_PUBLIC_WEB_STATE_NAVIGATION_CONTEXT_H_ |
| 7 | 7 |
| 8 #include "ui/base/page_transition_types.h" |
| 9 |
| 8 class GURL; | 10 class GURL; |
| 9 | 11 |
| 10 namespace net { | 12 namespace net { |
| 11 class HttpResponseHeaders; | 13 class HttpResponseHeaders; |
| 12 } | 14 } |
| 13 | 15 |
| 14 namespace web { | 16 namespace web { |
| 15 | 17 |
| 16 class WebState; | 18 class WebState; |
| 17 | 19 |
| 18 // Tracks information related to a single navigation. A NavigationContext is | 20 // Tracks information related to a single navigation. A NavigationContext is |
| 19 // provided to WebStateObserver methods to allow observers to track specific | 21 // provided to WebStateObserver methods to allow observers to track specific |
| 20 // navigations and their details. Observers should clear any references to a | 22 // navigations and their details. Observers should clear any references to a |
| 21 // NavigationContext at the time of WebStateObserver::DidFinishNavigation, just | 23 // NavigationContext at the time of WebStateObserver::DidFinishNavigation, just |
| 22 // before the handle is destroyed. | 24 // before the handle is destroyed. |
| 23 class NavigationContext { | 25 class NavigationContext { |
| 24 public: | 26 public: |
| 25 // The WebState the navigation is taking place in. | 27 // The WebState the navigation is taking place in. |
| 26 virtual WebState* GetWebState() = 0; | 28 virtual WebState* GetWebState() = 0; |
| 27 | 29 |
| 28 // The URL the WebState is navigating to. | 30 // The URL the WebState is navigating to. |
| 29 virtual const GURL& GetUrl() const = 0; | 31 virtual const GURL& GetUrl() const = 0; |
| 30 | 32 |
| 33 // Returns the page transition type for this navigation. |
| 34 virtual ui::PageTransition GetPageTransition() const = 0; |
| 35 |
| 31 // Whether the navigation happened within the same document. Examples of same | 36 // Whether the navigation happened within the same document. Examples of same |
| 32 // document navigations are: | 37 // document navigations are: |
| 33 // * reference fragment navigations | 38 // * reference fragment navigations |
| 34 // * pushState/replaceState | 39 // * pushState/replaceState |
| 35 // * same document history navigation | 40 // * same document history navigation |
| 36 virtual bool IsSameDocument() const = 0; | 41 virtual bool IsSameDocument() const = 0; |
| 37 | 42 |
| 38 // Whether the navigation resulted in an error page. | 43 // Whether the navigation resulted in an error page. |
| 39 virtual bool IsErrorPage() const = 0; | 44 virtual bool IsErrorPage() const = 0; |
| 40 | 45 |
| 41 // Returns the response headers for the request, or null if there aren't any | 46 // Returns the response headers for the request, or null if there aren't any |
| 42 // response headers or they have not been received yet. The response headers | 47 // response headers or they have not been received yet. The response headers |
| 43 // returned should not be modified, as modifications will not be reflected. | 48 // returned should not be modified, as modifications will not be reflected. |
| 44 virtual net::HttpResponseHeaders* GetResponseHeaders() const = 0; | 49 virtual net::HttpResponseHeaders* GetResponseHeaders() const = 0; |
| 45 | 50 |
| 46 virtual ~NavigationContext() {} | 51 virtual ~NavigationContext() {} |
| 47 }; | 52 }; |
| 48 | 53 |
| 49 } // namespace web | 54 } // namespace web |
| 50 | 55 |
| 51 #endif // IOS_WEB_PUBLIC_WEB_STATE_NAVIGATION_CONTEXT_H_ | 56 #endif // IOS_WEB_PUBLIC_WEB_STATE_NAVIGATION_CONTEXT_H_ |
| OLD | NEW |