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; | |
nasko
2015/08/31 23:25:15
Is there any reason to return non-validated URL?
clamy
2015/09/03 15:30:52
I think some observers/throttles may be interested
nasko
2015/09/04 23:36:49
If we need to keep this, I'd flip it around such t
| |
35 | |
36 // Whether the navigation is taking place in the main frame or in a subframe. | |
37 // This reamins constant over the navigation. | |
nasko
2015/08/31 23:25:15
nit: navigation lifetime.
Avi (use Gerrit)
2015/09/01 16:38:47
typo: remains
clamy
2015/09/03 15:30:52
Done.
| |
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 a network request is | |
Avi (use Gerrit)
2015/09/01 16:38:47
"when the network request"
clamy
2015/09/03 15:30:52
Done.
| |
43 // made for the navigation (or commit time if not network request is made). | |
Avi (use Gerrit)
2015/09/01 16:38:47
"or at commit time if no network request is made"
clamy
2015/09/03 15:30:52
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 | |
nasko
2015/08/31 23:25:15
nit: s/post/POST/
clamy
2015/09/03 15:30:52
Done.
| |
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& GetSanitizedReferrer() const = 0; | |
nasko
2015/08/31 23:25:15
Since there is no other referrer that we are retur
clamy
2015/09/03 15:30:52
Done.
| |
53 | |
54 // Whether the navigation was initiated by a user gesture. Note that this | |
55 // will return false for browser-initiated navigations. | |
56 virtual bool HasUserGesture() const = 0; | |
nasko
2015/08/31 23:25:15
Usually, browser initiated navigations are in resp
clamy
2015/09/03 15:30:52
It's possible to do that for PlzNavigate, but diff
| |
57 | |
58 // Returns the page transition type. | |
59 virtual ui::PageTransition GetPageTransition() const = 0; | |
60 | |
61 // Whether the target URL cannot be handled by Chrome's internal protocol | |
nasko
2015/08/31 23:25:15
nit: s/Chrome/the browser/. Chrome is a branded ve
clamy
2015/09/03 15:30:52
Done.
| |
62 // handlers. | |
63 virtual bool IsExternalProtocol() const = 0; | |
64 | |
65 // Navigation control flow -------------------------------------------------- | |
66 | |
24 // The net error code if an error happened prior to commit. Otherwise it will | 67 // The net error code if an error happened prior to commit. Otherwise it will |
25 // be net::OK. | 68 // be net::OK. |
26 virtual net::Error GetNetErrorCode() const = 0; | 69 virtual net::Error GetNetErrorCode() const = 0; |
27 | 70 |
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. | 71 // Whether the navigation has successfully committed a document. |
32 virtual bool HasCommittedDocument() const = 0; | 72 virtual bool HasCommittedDocument() const = 0; |
33 | 73 |
34 // Whether an error page has committed for the navigation. | 74 // Whether an error page has committed for the navigation. |
35 virtual bool HasCommittedErrorPage() const = 0; | 75 virtual bool HasCommittedErrorPage() const = 0; |
76 | |
77 // Registers a NavigationThrottle for this navigation. The throttle can | |
78 // modify the request, pause the request or cancel the request. This will | |
79 // take ownership of the NavigationThrottle. | |
80 virtual void RegisterThrottle( | |
81 scoped_ptr<NavigationThrottle> navigation_throttle) = 0; | |
davidben
2015/09/01 21:55:18
I wonder if this would be better done as the Resou
clamy
2015/09/03 15:30:52
Well the goal was to have that happen in just one
| |
36 }; | 82 }; |
37 | 83 |
38 } // namespace content | 84 } // namespace content |
39 | 85 |
40 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ | 86 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ |
OLD | NEW |