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_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ | 5 #ifndef IOS_WEB_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ |
6 #define IOS_WEB_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ | 6 #define IOS_WEB_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "ios/web/public/web_state/navigation_context.h" | 12 #include "ios/web/public/web_state/navigation_context.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace web { | 15 namespace web { |
16 | 16 |
17 // Tracks information related to a single navigation. | 17 // Tracks information related to a single navigation. |
18 class NavigationContextImpl : public NavigationContext { | 18 class NavigationContextImpl : public NavigationContext { |
19 public: | 19 public: |
20 // Creates navigation context for sucessful navigation to a different page. | 20 // Creates navigation context for sucessful navigation to a different page. |
21 // Response headers will ne null. | 21 // Response headers will ne null. |
22 static std::unique_ptr<NavigationContextImpl> CreateNavigationContext( | 22 static std::unique_ptr<NavigationContextImpl> CreateNavigationContext( |
23 WebState* web_state, | 23 WebState* web_state, |
24 const GURL& url); | 24 const GURL& url); |
25 | 25 |
26 // Creates navigation context for sucessful navigation to a different page. | |
27 static std::unique_ptr<NavigationContextImpl> CreateNavigationContext( | |
28 WebState* web_state, | |
29 const GURL& url, | |
30 const scoped_refptr<net::HttpResponseHeaders>& response_headers); | |
31 | |
32 // Creates navigation context for sucessful same page navigation. | |
33 static std::unique_ptr<NavigationContextImpl> | |
34 CreateSameDocumentNavigationContext(WebState* web_state, const GURL& url); | |
35 | |
36 // Creates navigation context for the error page navigation. | |
37 static std::unique_ptr<NavigationContextImpl> | |
38 CreateErrorPageNavigationContext( | |
39 WebState* web_state, | |
40 const GURL& url, | |
41 const scoped_refptr<net::HttpResponseHeaders>& response_headers); | |
42 | |
43 #ifndef NDEBUG | 26 #ifndef NDEBUG |
44 // Returns human readable description of this object. | 27 // Returns human readable description of this object. |
45 NSString* GetDescription() const; | 28 NSString* GetDescription() const; |
46 #endif // NDEBUG | 29 #endif // NDEBUG |
47 | 30 |
48 // NavigationContext overrides: | 31 // NavigationContext overrides: |
49 WebState* GetWebState() override; | 32 WebState* GetWebState() override; |
50 const GURL& GetUrl() const override; | 33 const GURL& GetUrl() const override; |
51 bool IsSameDocument() const override; | 34 bool IsSameDocument() const override; |
52 bool IsErrorPage() const override; | 35 bool IsErrorPage() const override; |
(...skipping 19 matching lines...) Expand all Loading... |
72 bool is_same_document_ = false; | 55 bool is_same_document_ = false; |
73 bool is_error_page_ = false; | 56 bool is_error_page_ = false; |
74 scoped_refptr<net::HttpResponseHeaders> response_headers_; | 57 scoped_refptr<net::HttpResponseHeaders> response_headers_; |
75 | 58 |
76 DISALLOW_COPY_AND_ASSIGN(NavigationContextImpl); | 59 DISALLOW_COPY_AND_ASSIGN(NavigationContextImpl); |
77 }; | 60 }; |
78 | 61 |
79 } // namespace web | 62 } // namespace web |
80 | 63 |
81 #endif // IOS_WEB_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ | 64 #endif // IOS_WEB_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ |
OLD | NEW |