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