Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: content/public/browser/navigation_handle.h

Issue 1269813002: Add a NavigationThrottle to the public content/ interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@navigation-api
Patch Set: Addressed comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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() const = 0;
Charlie Reis 2015/09/11 00:06:49 From http://www.chromium.org/developers/content-mo
clamy 2015/09/16 01:03:22 Done.
23 32
33 // A sanitized version of the URL the frame is navigating to. It may change
34 // during the navigation when encountering a server redirect.
35 virtual const GURL& GetValidatedURL() const = 0;
Charlie Reis 2015/09/11 00:06:48 It's not initially clear to me what this refers to
clamy 2015/09/11 13:30:44 When transitioning the InterceptNavigationResource
nasko 2015/09/14 22:00:04 I am all for only having one accessor, as I've sta
Charlie Reis 2015/09/16 00:09:24 Yes, let's try to have only GetURL which returns a
clamy 2015/09/16 01:03:22 Done.
36
37 // Whether the navigation is taking place in the main frame or in a subframe.
38 // This remains constant over the navigation lifetime.
39 virtual bool IsInMainFrame() const = 0;
40
41 // The WebContents the navigation is taking place in.
42 virtual WebContents* GetWebContents() const = 0;
43
44 // Parameters available at network request start time ------------------------
45
46 // The following parameters are only available when the network request is
47 // made for the navigation (or at commit time if no network request is made).
48 // This corresponds to NavigationThrottle::WillSendRequest. They should not
49 // be queried before that.
50
51 // Whether the navigation is a POST or not. This may change during the
52 // navigation when encountering a server redirect.
53 virtual bool IsPost() const = 0;
54
55 // Returns a sanitized version of the referrer for this request.
56 virtual const Referrer& GetReferrer() const = 0;
57
58 // Whether the navigation was initiated by a user gesture. Note that this
59 // will return false for browser-initiated navigations.
60 // TODO(clamy): when PlzNavigate launches, this should return true for
61 // browser-initiated navigations.
62 virtual bool HasUserGesture() const = 0;
Charlie Reis 2015/09/11 00:06:49 I'm not sure why many of these are inaccessible un
clamy 2015/09/11 13:30:44 It's for supporting the current architecture witho
63
64 // Returns the page transition type.
65 virtual ui::PageTransition GetPageTransition() const = 0;
66
67 // Whether the target URL cannot be handled by the browser's internal protocol
68 // handlers.
69 virtual bool IsExternalProtocol() const = 0;
70
71 // Navigation control flow --------------------------------------------------
72
24 // The net error code if an error happened prior to commit. Otherwise it will 73 // The net error code if an error happened prior to commit. Otherwise it will
25 // be net::OK. 74 // be net::OK.
26 virtual net::Error GetNetErrorCode() const = 0; 75 virtual net::Error GetNetErrorCode() const = 0;
27 76
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. 77 // Whether the navigation has successfully committed a document.
32 virtual bool HasCommittedDocument() const = 0; 78 virtual bool HasCommittedDocument() const = 0;
33 79
34 // Whether an error page has committed for the navigation. 80 // Whether an error page has committed for the navigation.
35 virtual bool HasCommittedErrorPage() const = 0; 81 virtual bool HasCommittedErrorPage() const = 0;
82
83 // Registers a NavigationThrottle for tests. The throttle can
84 // modify the request, pause the request or cancel the request. This will
85 // take ownership of the NavigationThrottle.
86 // Note: in non-test cases, NavigationThrottles should not be added directly
87 // but returned by the implementation of
88 // ContentBrowserClient::AddNavigationThrottles. This ensures proper ordering
Charlie Reis 2015/09/11 00:06:48 Stale name?
clamy 2015/09/16 01:03:22 Done.
89 // of the throttles.
90 virtual void RegisterThrottleForTesting(
Charlie Reis 2015/09/11 00:06:48 Everything so far has been an accessor with no sta
clamy 2015/09/16 01:03:22 Well I did group it with the last 3 accessors in a
91 scoped_ptr<NavigationThrottle> navigation_throttle) = 0;
36 }; 92 };
37 93
38 } // namespace content 94 } // namespace content
39 95
40 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_ 96 #endif // CONTENT_PUBLIC_BROWSER_NAVIGATION_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698