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 #include "ios/web/web_state/navigation_context_impl.h" | 5 #include "ios/web/web_state/navigation_context_impl.h" |
6 | 6 |
7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "net/http/http_response_headers.h" | 10 #include "net/http/http_response_headers.h" |
11 | 11 |
12 namespace web { | 12 namespace web { |
13 | 13 |
14 // static | 14 // static |
15 std::unique_ptr<NavigationContextImpl> | 15 std::unique_ptr<NavigationContextImpl> |
16 NavigationContextImpl::CreateNavigationContext(WebState* web_state, | 16 NavigationContextImpl::CreateNavigationContext(WebState* web_state, |
17 const GURL& url) { | 17 const GURL& url) { |
18 std::unique_ptr<NavigationContextImpl> result(new NavigationContextImpl( | 18 std::unique_ptr<NavigationContextImpl> result(new NavigationContextImpl( |
19 web_state, url, false /* is_same_document */, false /* is_error_page */, | 19 web_state, url, false /* is_same_document */, false /* is_error_page */, |
20 nullptr /* response_headers */)); | 20 nullptr /* response_headers */)); |
21 return result; | 21 return result; |
22 } | 22 } |
23 | 23 |
24 // static | |
25 std::unique_ptr<NavigationContextImpl> | |
26 NavigationContextImpl::CreateNavigationContext( | |
27 WebState* web_state, | |
28 const GURL& url, | |
29 const scoped_refptr<net::HttpResponseHeaders>& response_headers) { | |
30 std::unique_ptr<NavigationContextImpl> resut( | |
31 new NavigationContextImpl(web_state, url, false /* is_same_document */, | |
32 false /* is_error_page */, response_headers)); | |
33 return resut; | |
34 } | |
35 | |
36 // static | |
37 std::unique_ptr<NavigationContextImpl> | |
38 NavigationContextImpl::CreateSameDocumentNavigationContext(WebState* web_state, | |
39 const GURL& url) { | |
40 std::unique_ptr<NavigationContextImpl> result(new NavigationContextImpl( | |
41 web_state, url, true /* is_same_document */, false /* is_error_page */, | |
42 nullptr /* response_headers */)); | |
43 return result; | |
44 } | |
45 | |
46 // static | |
47 std::unique_ptr<NavigationContextImpl> | |
48 NavigationContextImpl::CreateErrorPageNavigationContext( | |
49 WebState* web_state, | |
50 const GURL& url, | |
51 const scoped_refptr<net::HttpResponseHeaders>& response_headers) { | |
52 std::unique_ptr<NavigationContextImpl> result( | |
53 new NavigationContextImpl(web_state, url, false /* is_same_document */, | |
54 true /* is_error_page */, response_headers)); | |
55 return result; | |
56 } | |
57 | |
58 #ifndef NDEBUG | 24 #ifndef NDEBUG |
59 NSString* NavigationContextImpl::GetDescription() const { | 25 NSString* NavigationContextImpl::GetDescription() const { |
60 return [NSString stringWithFormat:@"web::WebState: %ld, url: %s, " | 26 return [NSString stringWithFormat:@"web::WebState: %ld, url: %s, " |
61 "is_same_document: %@, is_error_page_: %@", | 27 "is_same_document: %@, is_error_page_: %@", |
62 reinterpret_cast<long>(web_state_), | 28 reinterpret_cast<long>(web_state_), |
63 url_.spec().c_str(), | 29 url_.spec().c_str(), |
64 is_same_document_ ? @"true" : @"false", | 30 is_same_document_ ? @"true" : @"false", |
65 is_error_page_ ? @"true" : @"false"]; | 31 is_error_page_ ? @"true" : @"false"]; |
66 } | 32 } |
67 #endif // NDEBUG | 33 #endif // NDEBUG |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 const scoped_refptr<net::HttpResponseHeaders>& response_headers) | 73 const scoped_refptr<net::HttpResponseHeaders>& response_headers) |
108 : web_state_(web_state), | 74 : web_state_(web_state), |
109 url_(url), | 75 url_(url), |
110 is_same_document_(is_same_document), | 76 is_same_document_(is_same_document), |
111 is_error_page_(is_error_page), | 77 is_error_page_(is_error_page), |
112 response_headers_(response_headers) {} | 78 response_headers_(response_headers) {} |
113 | 79 |
114 NavigationContextImpl::~NavigationContextImpl() = default; | 80 NavigationContextImpl::~NavigationContextImpl() = default; |
115 | 81 |
116 } // namespace web | 82 } // namespace web |
OLD | NEW |