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; |
| 17 class WebContents; |
14 | 18 |
15 // A NavigationHandle tracks information related to a single navigation. | 19 // A NavigationHandle tracks information related to a single navigation. |
16 class CONTENT_EXPORT NavigationHandle { | 20 class CONTENT_EXPORT NavigationHandle { |
17 public: | 21 public: |
18 virtual ~NavigationHandle() {} | 22 virtual ~NavigationHandle() {} |
19 | 23 |
| 24 // Parameters available at navigation start time ----------------------------- |
| 25 |
| 26 // These parameters are always available during the navigation. Note that |
| 27 // some may change during navigation (e.g. due to server redirects). |
| 28 |
20 // The URL the frame is navigating to. This may change during the navigation | 29 // The URL the frame is navigating to. This may change during the navigation |
21 // when encountering a server redirect. | 30 // when encountering a server redirect. |
22 virtual const GURL& GetURL() const = 0; | 31 virtual const GURL& GetURL() = 0; |
| 32 |
| 33 // Whether the navigation is taking place in the main frame or in a subframe. |
| 34 // This remains constant over the navigation lifetime. |
| 35 virtual bool IsInMainFrame() = 0; |
| 36 |
| 37 // The WebContents the navigation is taking place in. |
| 38 virtual WebContents* GetWebContents() = 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 no network request is made). |
| 44 // This corresponds to NavigationThrottle::WillSendRequest. They should not |
| 45 // be queried before that. |
| 46 |
| 47 // Whether the navigation is a POST or a GET. This may change during the |
| 48 // navigation when encountering a server redirect. |
| 49 virtual bool IsPost() = 0; |
| 50 |
| 51 // Returns a sanitized version of the referrer for this request. |
| 52 virtual const Referrer& GetReferrer() = 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() = 0; |
| 59 |
| 60 // Returns the page transition type. |
| 61 virtual ui::PageTransition GetPageTransition() = 0; |
| 62 |
| 63 // Whether the target URL cannot be handled by the browser's internal protocol |
| 64 // handlers. |
| 65 virtual bool IsExternalProtocol() = 0; |
| 66 |
| 67 // Navigation control flow -------------------------------------------------- |
23 | 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() = 0; |
27 | |
28 // Whether the navigation is taking place in the main frame or in a subframe. | |
29 virtual bool IsInMainFrame() const = 0; | |
30 | 72 |
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() = 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() = 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::CreateThrottlesForNavigation. This ensures proper |
| 85 // ordering 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 |