| 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 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #import "ios/web/public/web_state/navigation_context.h" | 13 #import "ios/web/public/web_state/navigation_context.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace web { | 16 namespace web { |
| 17 | 17 |
| 18 // Tracks information related to a single navigation. | 18 // Tracks information related to a single navigation. |
| 19 class NavigationContextImpl : public NavigationContext { | 19 class NavigationContextImpl : public NavigationContext { |
| 20 public: | 20 public: |
| 21 // Creates navigation context for sucessful navigation to a different page. | 21 // Creates navigation context for sucessful navigation to a different page. |
| 22 // Response headers will ne null. | 22 // Response headers will ne null. |
| 23 static std::unique_ptr<NavigationContextImpl> CreateNavigationContext( | 23 static std::unique_ptr<NavigationContextImpl> CreateNavigationContext( |
| 24 WebState* web_state, | 24 WebState* web_state, |
| 25 const GURL& url); | 25 const GURL& url, |
| 26 ui::PageTransition page_transition); |
| 26 | 27 |
| 27 #ifndef NDEBUG | 28 #ifndef NDEBUG |
| 28 // Returns human readable description of this object. | 29 // Returns human readable description of this object. |
| 29 NSString* GetDescription() const; | 30 NSString* GetDescription() const; |
| 30 #endif // NDEBUG | 31 #endif // NDEBUG |
| 31 | 32 |
| 32 // NavigationContext overrides: | 33 // NavigationContext overrides: |
| 33 WebState* GetWebState() override; | 34 WebState* GetWebState() override; |
| 34 const GURL& GetUrl() const override; | 35 const GURL& GetUrl() const override; |
| 36 ui::PageTransition GetPageTransition() const override; |
| 35 bool IsSameDocument() const override; | 37 bool IsSameDocument() const override; |
| 36 NSError* GetError() const override; | 38 NSError* GetError() const override; |
| 37 net::HttpResponseHeaders* GetResponseHeaders() const override; | 39 net::HttpResponseHeaders* GetResponseHeaders() const override; |
| 38 ~NavigationContextImpl() override; | 40 ~NavigationContextImpl() override; |
| 39 | 41 |
| 40 // Setters for navigation context data members. | 42 // Setters for navigation context data members. |
| 41 void SetIsSameDocument(bool is_same_document); | 43 void SetIsSameDocument(bool is_same_document); |
| 42 void SetError(NSError* error); | 44 void SetError(NSError* error); |
| 43 void SetResponseHeaders( | 45 void SetResponseHeaders( |
| 44 const scoped_refptr<net::HttpResponseHeaders>& response_headers); | 46 const scoped_refptr<net::HttpResponseHeaders>& response_headers); |
| 45 | 47 |
| 46 // Optional unique id of the navigation item associated with this navigaiton. | 48 // Optional unique id of the navigation item associated with this navigaiton. |
| 47 int GetNavigationItemUniqueID() const; | 49 int GetNavigationItemUniqueID() const; |
| 48 void SetNavigationItemUniqueID(int unique_id); | 50 void SetNavigationItemUniqueID(int unique_id); |
| 49 | 51 |
| 50 private: | 52 private: |
| 51 NavigationContextImpl(WebState* web_state, const GURL& url); | 53 NavigationContextImpl(WebState* web_state, |
| 54 const GURL& url, |
| 55 ui::PageTransition page_transition); |
| 52 | 56 |
| 53 WebState* web_state_ = nullptr; | 57 WebState* web_state_ = nullptr; |
| 54 GURL url_; | 58 GURL url_; |
| 59 ui::PageTransition page_transition_; |
| 55 bool is_same_document_ = false; | 60 bool is_same_document_ = false; |
| 56 base::scoped_nsobject<NSError> error_; | 61 base::scoped_nsobject<NSError> error_; |
| 57 scoped_refptr<net::HttpResponseHeaders> response_headers_; | 62 scoped_refptr<net::HttpResponseHeaders> response_headers_; |
| 58 int navigation_item_unique_id_ = -1; | 63 int navigation_item_unique_id_ = -1; |
| 59 | 64 |
| 60 DISALLOW_COPY_AND_ASSIGN(NavigationContextImpl); | 65 DISALLOW_COPY_AND_ASSIGN(NavigationContextImpl); |
| 61 }; | 66 }; |
| 62 | 67 |
| 63 } // namespace web | 68 } // namespace web |
| 64 | 69 |
| 65 #endif // IOS_WEB_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ | 70 #endif // IOS_WEB_WEB_STATE_NAVIGATION_CONTEXT_IMPL_H_ |
| OLD | NEW |