Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 6 #define CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
| 7 | 7 |
| 8 #include "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
| 9 #include "content/public/common/referrer.h" | |
| 9 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| 11 #include "ui/base/page_transition_types.h" | |
| 10 | 12 |
| 11 class GURL; | 13 class GURL; |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 16 class NavigationThrottle; | |
| 14 | 17 |
| 15 // A NavigationHandle tracks information related to a single navigation. | 18 // A NavigationHandle tracks information related to a single navigation. |
| 16 class CONTENT_EXPORT NavigationHandle { | 19 class CONTENT_EXPORT NavigationHandle { |
| 17 public: | 20 public: |
| 18 virtual ~NavigationHandle() {} | 21 virtual ~NavigationHandle() {} |
| 19 | 22 |
| 23 // Parameters available at navigation start time ----------------------------- | |
| 24 | |
| 25 // These parameters are always available during the navigation. Note that | |
| 26 // some may change during navigation (e.g. due to server redirects). | |
| 27 | |
| 20 // The URL the frame is navigating to. This may change during the navigation | 28 // The URL the frame is navigating to. This may change during the navigation |
| 21 // when encountering a server redirect. | 29 // when encountering a server redirect. |
| 22 virtual const GURL& GetURL() const = 0; | 30 virtual const GURL& GetURL() const = 0; |
| 23 | 31 |
| 32 // A sanitized version of the URL the frame is navigating to. It may change | |
| 33 // during the navigation when encountering a server redirect. | |
| 34 virtual const GURL& GetValidatedURL() const = 0; | |
| 35 | |
| 36 // Whether the navigation is taking place in the main frame or in a subframe. | |
| 37 // This remains constant over the navigation lifetime. | |
| 38 virtual bool IsInMainFrame() const = 0; | |
| 39 | |
| 40 // Parameters available at network request start time ------------------------ | |
| 41 | |
| 42 // The following parameters are only available when the network request is | |
| 43 // made for the navigation (or at commit time if not network request is made). | |
|
nasko
2015/09/04 00:01:53
nit: "no network request"
clamy
2015/09/08 16:27:19
Done.
| |
| 44 // This corresponds to NavigationThrottle::WillSendRequest. They should not | |
| 45 // be queried before that. | |
| 46 | |
| 47 // Whether the navigation is a POST or not. This may change during the | |
| 48 // navigation when encountering a server redirect. | |
| 49 virtual bool IsPost() const = 0; | |
| 50 | |
| 51 // Returns a sanitized version of the referrer for this request. | |
| 52 virtual const Referrer& GetReferrer() const = 0; | |
| 53 | |
| 54 // Whether the navigation was initiated by a user gesture. Note that this | |
| 55 // will return false for browser-initiated navigations. | |
| 56 // TODO(clamy): when PlzNavigate launches, this should return true for | |
| 57 // browser-initiated navigations. | |
| 58 virtual bool HasUserGesture() const = 0; | |
| 59 | |
| 60 // Returns the page transition type. | |
| 61 virtual ui::PageTransition GetPageTransition() const = 0; | |
| 62 | |
| 63 // Whether the target URL cannot be handled by the browser's internal protocol | |
| 64 // handlers. | |
| 65 virtual bool IsExternalProtocol() const = 0; | |
| 66 | |
| 67 // Navigation control flow -------------------------------------------------- | |
| 68 | |
| 24 // The net error code if an error happened prior to commit. Otherwise it will | 69 // The net error code if an error happened prior to commit. Otherwise it will |
| 25 // be net::OK. | 70 // be net::OK. |
| 26 virtual net::Error GetNetErrorCode() const = 0; | 71 virtual net::Error GetNetErrorCode() const = 0; |
| 27 | 72 |
| 28 // Whether the navigation is taking place in the main frame or in a subframe. | |
| 29 virtual bool IsInMainFrame() const = 0; | |
| 30 | |
| 31 // Whether the navigation has successfully committed a document. | 73 // Whether the navigation has successfully committed a document. |
| 32 virtual bool HasCommittedDocument() const = 0; | 74 virtual bool HasCommittedDocument() const = 0; |
| 33 | 75 |
| 34 // Whether an error page has committed for the navigation. | 76 // Whether an error page has committed for the navigation. |
| 35 virtual bool HasCommittedErrorPage() const = 0; | 77 virtual bool HasCommittedErrorPage() const = 0; |
| 78 | |
| 79 // Registers a NavigationThrottle for tests. The throttle can | |
| 80 // modify the request, pause the request or cancel the request. This will | |
| 81 // take ownership of the NavigationThrottle. | |
| 82 // Note: in non-test cases, NavigationThrottles should not be added directly | |
| 83 // but returned by the implementation of | |
| 84 // ContentBrowserClient::AddNavigationThrottles. This ensures proper ordering | |
| 85 // of the throttles. | |
| 86 virtual void RegisterThrottleForTesting( | |
| 87 scoped_ptr<NavigationThrottle> navigation_throttle) = 0; | |
| 36 }; | 88 }; |
| 37 | 89 |
| 38 } // namespace content | 90 } // namespace content |
| 39 | 91 |
| 40 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 92 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
| OLD | NEW |