| 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 static std::unique_ptr<NavigationContext> CreateNavigationContext( | 21 static std::unique_ptr<NavigationContextImpl> CreateNavigationContext( |
| 22 WebState* web_state, | 22 WebState* web_state, |
| 23 const GURL& url, | 23 const GURL& url, |
| 24 const scoped_refptr<net::HttpResponseHeaders>& response_headers); | 24 const scoped_refptr<net::HttpResponseHeaders>& response_headers); |
| 25 | 25 |
| 26 // Creates navigation context for sucessful same page navigation. | 26 // Creates navigation context for sucessful same page navigation. |
| 27 static std::unique_ptr<NavigationContext> CreateSameDocumentNavigationContext( | 27 static std::unique_ptr<NavigationContextImpl> |
| 28 WebState* web_state, | 28 CreateSameDocumentNavigationContext(WebState* web_state, const GURL& url); |
| 29 const GURL& url); | |
| 30 | 29 |
| 31 // Creates navigation context for the error page navigation. | 30 // Creates navigation context for the error page navigation. |
| 32 static std::unique_ptr<NavigationContext> CreateErrorPageNavigationContext( | 31 static std::unique_ptr<NavigationContextImpl> |
| 32 CreateErrorPageNavigationContext( |
| 33 WebState* web_state, | 33 WebState* web_state, |
| 34 const GURL& url, | 34 const GURL& url, |
| 35 const scoped_refptr<net::HttpResponseHeaders>& response_headers); | 35 const scoped_refptr<net::HttpResponseHeaders>& response_headers); |
| 36 | 36 |
| 37 #ifndef NDEBUG |
| 38 // Returns human readable description of this object. |
| 39 NSString* GetDescription() const; |
| 40 #endif // NDEBUG |
| 41 |
| 37 // NavigationContext overrides: | 42 // NavigationContext overrides: |
| 38 WebState* GetWebState() override; | 43 WebState* GetWebState() override; |
| 39 const GURL& GetUrl() const override; | 44 const GURL& GetUrl() const override; |
| 40 bool IsSameDocument() const override; | 45 bool IsSameDocument() const override; |
| 41 bool IsErrorPage() const override; | 46 bool IsErrorPage() const override; |
| 42 net::HttpResponseHeaders* GetResponseHeaders() const override; | 47 net::HttpResponseHeaders* GetResponseHeaders() const override; |
| 48 ~NavigationContextImpl() override; |
| 43 | 49 |
| 44 private: | 50 private: |
| 45 NavigationContextImpl( | 51 NavigationContextImpl( |
| 46 WebState* web_state, | 52 WebState* web_state, |
| 47 const GURL& url, | 53 const GURL& url, |
| 48 bool is_same_page, | 54 bool is_same_page, |
| 49 bool is_error_page, | 55 bool is_error_page, |
| 50 const scoped_refptr<net::HttpResponseHeaders>& response_headers); | 56 const scoped_refptr<net::HttpResponseHeaders>& response_headers); |
| 51 ~NavigationContextImpl() override; | |
| 52 | 57 |
| 53 WebState* web_state_ = nullptr; | 58 WebState* web_state_ = nullptr; |
| 54 GURL url_; | 59 GURL url_; |
| 55 bool is_same_document_ = false; | 60 bool is_same_document_ = false; |
| 56 bool is_error_page_ = false; | 61 bool is_error_page_ = false; |
| 57 scoped_refptr<net::HttpResponseHeaders> response_headers_; | 62 scoped_refptr<net::HttpResponseHeaders> response_headers_; |
| 58 | 63 |
| 59 DISALLOW_COPY_AND_ASSIGN(NavigationContextImpl); | 64 DISALLOW_COPY_AND_ASSIGN(NavigationContextImpl); |
| 60 }; | 65 }; |
| 61 | 66 |
| 62 } // namespace web | 67 } // namespace web |
| 63 | 68 |
| 64 #endif // IOS_WEB_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ | 69 #endif // IOS_WEB_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ |
| OLD | NEW |