OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/navigation/navigation_item_impl.h" | 5 #include "ios/web/navigation/navigation_item_impl.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/base/net_util.h" | 9 #include "net/base/net_util.h" |
10 #include "ui/base/page_transition_types.h" | 10 #include "ui/base/page_transition_types.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 // static | 26 // static |
27 scoped_ptr<NavigationItem> NavigationItem::Create() { | 27 scoped_ptr<NavigationItem> NavigationItem::Create() { |
28 return scoped_ptr<NavigationItem>(new NavigationItemImpl()); | 28 return scoped_ptr<NavigationItem>(new NavigationItemImpl()); |
29 } | 29 } |
30 | 30 |
31 NavigationItemImpl::NavigationItemImpl() | 31 NavigationItemImpl::NavigationItemImpl() |
32 : unique_id_(GetUniqueIDInConstructor()), | 32 : unique_id_(GetUniqueIDInConstructor()), |
33 page_id_(-1), | 33 page_id_(-1), |
34 transition_type_(ui::PAGE_TRANSITION_LINK), | 34 transition_type_(ui::PAGE_TRANSITION_LINK), |
| 35 is_overriding_user_agent_(false), |
| 36 is_created_from_push_state_(false), |
| 37 should_skip_resubmit_data_confirmation_(false), |
35 is_renderer_initiated_(false), | 38 is_renderer_initiated_(false), |
36 is_unsafe_(false), | 39 is_unsafe_(false), |
37 facade_delegate_(nullptr) { | 40 facade_delegate_(nullptr) { |
38 } | 41 } |
39 | 42 |
40 NavigationItemImpl::~NavigationItemImpl() { | 43 NavigationItemImpl::~NavigationItemImpl() { |
41 } | 44 } |
42 | 45 |
43 NavigationItemImpl::NavigationItemImpl(const NavigationItemImpl& item) | 46 NavigationItemImpl::NavigationItemImpl(const NavigationItemImpl& item) |
44 : unique_id_(item.unique_id_), | 47 : unique_id_(item.unique_id_), |
45 url_(item.url_), | 48 url_(item.url_), |
46 referrer_(item.referrer_), | 49 referrer_(item.referrer_), |
47 virtual_url_(item.virtual_url_), | 50 virtual_url_(item.virtual_url_), |
48 title_(item.title_), | 51 title_(item.title_), |
49 page_id_(item.page_id_), | 52 page_id_(item.page_id_), |
50 page_scroll_state_(item.page_scroll_state_), | 53 page_scroll_state_(item.page_scroll_state_), |
51 transition_type_(item.transition_type_), | 54 transition_type_(item.transition_type_), |
52 favicon_(item.favicon_), | 55 favicon_(item.favicon_), |
53 ssl_(item.ssl_), | 56 ssl_(item.ssl_), |
54 timestamp_(item.timestamp_), | 57 timestamp_(item.timestamp_), |
| 58 is_overriding_user_agent_(item.is_overriding_user_agent_), |
| 59 http_request_headers_([item.http_request_headers_ copy]), |
| 60 serialized_state_object_([item.serialized_state_object_ copy]), |
| 61 is_created_from_push_state_(item.is_created_from_push_state_), |
| 62 should_skip_resubmit_data_confirmation_( |
| 63 item.should_skip_resubmit_data_confirmation_), |
| 64 post_data_([item.post_data_ copy]), |
55 is_renderer_initiated_(item.is_renderer_initiated_), | 65 is_renderer_initiated_(item.is_renderer_initiated_), |
56 is_unsafe_(item.is_unsafe_), | 66 is_unsafe_(item.is_unsafe_), |
57 cached_display_title_(item.cached_display_title_), | 67 cached_display_title_(item.cached_display_title_), |
58 facade_delegate_(nullptr) { | 68 facade_delegate_(nullptr) { |
59 } | 69 } |
60 | 70 |
61 void NavigationItemImpl::SetFacadeDelegate( | 71 void NavigationItemImpl::SetFacadeDelegate( |
62 scoped_ptr<NavigationItemFacadeDelegate> facade_delegate) { | 72 scoped_ptr<NavigationItemFacadeDelegate> facade_delegate) { |
63 facade_delegate_ = facade_delegate.Pass(); | 73 facade_delegate_ = facade_delegate.Pass(); |
64 } | 74 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 } | 190 } |
181 | 191 |
182 void NavigationItemImpl::SetTimestamp(base::Time timestamp) { | 192 void NavigationItemImpl::SetTimestamp(base::Time timestamp) { |
183 timestamp_ = timestamp; | 193 timestamp_ = timestamp; |
184 } | 194 } |
185 | 195 |
186 base::Time NavigationItemImpl::GetTimestamp() const { | 196 base::Time NavigationItemImpl::GetTimestamp() const { |
187 return timestamp_; | 197 return timestamp_; |
188 } | 198 } |
189 | 199 |
190 void NavigationItemImpl::ResetForCommit() { | |
191 // Any state that only matters when a navigation item is pending should be | |
192 // cleared here. | |
193 set_is_renderer_initiated(false); | |
194 } | |
195 | |
196 void NavigationItemImpl::SetUnsafe(bool is_unsafe) { | 200 void NavigationItemImpl::SetUnsafe(bool is_unsafe) { |
197 is_unsafe_ = is_unsafe; | 201 is_unsafe_ = is_unsafe; |
198 } | 202 } |
199 | 203 |
200 bool NavigationItemImpl::IsUnsafe() const { | 204 bool NavigationItemImpl::IsUnsafe() const { |
201 return is_unsafe_; | 205 return is_unsafe_; |
202 } | 206 } |
203 | 207 |
| 208 void NavigationItemImpl::SetIsOverridingUserAgent( |
| 209 bool is_overriding_user_agent) { |
| 210 is_overriding_user_agent_ = is_overriding_user_agent; |
| 211 } |
| 212 |
| 213 bool NavigationItemImpl::IsOverridingUserAgent() const { |
| 214 return is_overriding_user_agent_; |
| 215 } |
| 216 |
| 217 bool NavigationItemImpl::HasPostData() const { |
| 218 return post_data_.get() != nil; |
| 219 } |
| 220 |
| 221 NSDictionary* NavigationItemImpl::GetHttpRequestHeaders() const { |
| 222 return [[http_request_headers_ copy] autorelease]; |
| 223 } |
| 224 |
| 225 void NavigationItemImpl::AddHttpRequestHeaders( |
| 226 NSDictionary* additional_headers) { |
| 227 if (!additional_headers) |
| 228 return; |
| 229 |
| 230 if (http_request_headers_) |
| 231 [http_request_headers_ addEntriesFromDictionary:additional_headers]; |
| 232 else |
| 233 http_request_headers_.reset([additional_headers mutableCopy]); |
| 234 } |
| 235 |
| 236 void NavigationItemImpl::SetSerializedStateObject( |
| 237 NSString* serialized_state_object) { |
| 238 serialized_state_object_.reset([serialized_state_object retain]); |
| 239 } |
| 240 |
| 241 NSString* NavigationItemImpl::GetSerializedStateObject() const { |
| 242 return serialized_state_object_.get(); |
| 243 } |
| 244 |
| 245 void NavigationItemImpl::SetIsCreatedFromPushState(bool push_state) { |
| 246 is_created_from_push_state_ = push_state; |
| 247 } |
| 248 |
| 249 bool NavigationItemImpl::IsCreatedFromPushState() const { |
| 250 return is_created_from_push_state_; |
| 251 } |
| 252 |
| 253 void NavigationItemImpl::SetShouldSkipResubmitDataConfirmation(bool skip) { |
| 254 should_skip_resubmit_data_confirmation_ = skip; |
| 255 } |
| 256 |
| 257 bool NavigationItemImpl::ShouldSkipResubmitDataConfirmation() const { |
| 258 return should_skip_resubmit_data_confirmation_; |
| 259 } |
| 260 |
| 261 void NavigationItemImpl::SetPostData(NSData* post_data) { |
| 262 post_data_.reset([post_data retain]); |
| 263 } |
| 264 |
| 265 NSData* NavigationItemImpl::GetPostData() const { |
| 266 return post_data_.get(); |
| 267 } |
| 268 |
| 269 void NavigationItemImpl::RemoveHttpRequestHeaderForKey(NSString* key) { |
| 270 DCHECK(key); |
| 271 [http_request_headers_ removeObjectForKey:key]; |
| 272 if (![http_request_headers_ count]) |
| 273 http_request_headers_.reset(); |
| 274 } |
| 275 |
| 276 void NavigationItemImpl::ResetHttpRequestHeaders() { |
| 277 http_request_headers_.reset(); |
| 278 } |
| 279 |
| 280 void NavigationItemImpl::ResetForCommit() { |
| 281 // Any state that only matters when a navigation item is pending should be |
| 282 // cleared here. |
| 283 set_is_renderer_initiated(false); |
| 284 } |
| 285 |
204 } // namespace web | 286 } // namespace web |
OLD | NEW |