Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: ios/web/navigation/navigation_item_impl.mm

Issue 2698773002: [iOS] Refactoring web CRWSessionController user agent code. (Closed)
Patch Set: Update NavigationItemImpl to use NavigationInitiationType Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #import "ios/web/navigation/navigation_item_impl.h" 5 #import "ios/web/navigation/navigation_item_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "components/url_formatter/url_formatter.h" 13 #include "components/url_formatter/url_formatter.h"
14 #import "ios/web/navigation/navigation_manager_impl.h"
14 #include "ui/base/page_transition_types.h" 15 #include "ui/base/page_transition_types.h"
15 #include "ui/gfx/text_elider.h" 16 #include "ui/gfx/text_elider.h"
16 17
17 #if !defined(__has_feature) || !__has_feature(objc_arc) 18 #if !defined(__has_feature) || !__has_feature(objc_arc)
18 #error "This file requires ARC support." 19 #error "This file requires ARC support."
19 #endif 20 #endif
20 21
21 namespace { 22 namespace {
22 23
23 // Returns a new unique ID for use in NavigationItem during construction. The 24 // Returns a new unique ID for use in NavigationItem during construction. The
(...skipping 13 matching lines...) Expand all
37 } 38 }
38 39
39 NavigationItemImpl::NavigationItemImpl() 40 NavigationItemImpl::NavigationItemImpl()
40 : unique_id_(GetUniqueIDInConstructor()), 41 : unique_id_(GetUniqueIDInConstructor()),
41 transition_type_(ui::PAGE_TRANSITION_LINK), 42 transition_type_(ui::PAGE_TRANSITION_LINK),
42 is_overriding_user_agent_(false), 43 is_overriding_user_agent_(false),
43 is_created_from_push_state_(false), 44 is_created_from_push_state_(false),
44 has_state_been_replaced_(false), 45 has_state_been_replaced_(false),
45 is_created_from_hash_change_(false), 46 is_created_from_hash_change_(false),
46 should_skip_repost_form_confirmation_(false), 47 should_skip_repost_form_confirmation_(false),
47 is_renderer_initiated_(false), 48 navigation_initiation_type_(
49 web::NavigationInitiationType::USER_INITIATED),
kkhorimoto 2017/02/17 20:51:35 This should be initialized to RENDERER_INITIATED f
liaoyuke 2017/02/17 22:15:40 Per offline discussion, will do this in a separate
48 is_unsafe_(false), 50 is_unsafe_(false),
49 facade_delegate_(nullptr) {} 51 facade_delegate_(nullptr) {}
50 52
51 NavigationItemImpl::~NavigationItemImpl() { 53 NavigationItemImpl::~NavigationItemImpl() {
52 } 54 }
53 55
54 NavigationItemImpl::NavigationItemImpl(const NavigationItemImpl& item) 56 NavigationItemImpl::NavigationItemImpl(const NavigationItemImpl& item)
55 : unique_id_(item.unique_id_), 57 : unique_id_(item.unique_id_),
56 original_request_url_(item.original_request_url_), 58 original_request_url_(item.original_request_url_),
57 url_(item.url_), 59 url_(item.url_),
58 referrer_(item.referrer_), 60 referrer_(item.referrer_),
59 virtual_url_(item.virtual_url_), 61 virtual_url_(item.virtual_url_),
60 title_(item.title_), 62 title_(item.title_),
61 page_display_state_(item.page_display_state_), 63 page_display_state_(item.page_display_state_),
62 transition_type_(item.transition_type_), 64 transition_type_(item.transition_type_),
63 favicon_(item.favicon_), 65 favicon_(item.favicon_),
64 ssl_(item.ssl_), 66 ssl_(item.ssl_),
65 timestamp_(item.timestamp_), 67 timestamp_(item.timestamp_),
66 is_overriding_user_agent_(item.is_overriding_user_agent_), 68 is_overriding_user_agent_(item.is_overriding_user_agent_),
67 http_request_headers_([item.http_request_headers_ copy]), 69 http_request_headers_([item.http_request_headers_ copy]),
68 serialized_state_object_([item.serialized_state_object_ copy]), 70 serialized_state_object_([item.serialized_state_object_ copy]),
69 is_created_from_push_state_(item.is_created_from_push_state_), 71 is_created_from_push_state_(item.is_created_from_push_state_),
70 has_state_been_replaced_(item.has_state_been_replaced_), 72 has_state_been_replaced_(item.has_state_been_replaced_),
71 is_created_from_hash_change_(item.is_created_from_hash_change_), 73 is_created_from_hash_change_(item.is_created_from_hash_change_),
72 should_skip_repost_form_confirmation_( 74 should_skip_repost_form_confirmation_(
73 item.should_skip_repost_form_confirmation_), 75 item.should_skip_repost_form_confirmation_),
74 post_data_([item.post_data_ copy]), 76 post_data_([item.post_data_ copy]),
75 is_renderer_initiated_(item.is_renderer_initiated_), 77 navigation_initiation_type_(item.navigation_initiation_type_),
76 is_unsafe_(item.is_unsafe_), 78 is_unsafe_(item.is_unsafe_),
77 cached_display_title_(item.cached_display_title_), 79 cached_display_title_(item.cached_display_title_),
78 facade_delegate_(nullptr) {} 80 facade_delegate_(nullptr) {}
79 81
80 void NavigationItemImpl::SetFacadeDelegate( 82 void NavigationItemImpl::SetFacadeDelegate(
81 std::unique_ptr<NavigationItemFacadeDelegate> facade_delegate) { 83 std::unique_ptr<NavigationItemFacadeDelegate> facade_delegate) {
82 facade_delegate_ = std::move(facade_delegate); 84 facade_delegate_ = std::move(facade_delegate);
83 } 85 }
84 86
85 NavigationItemFacadeDelegate* NavigationItemImpl::GetFacadeDelegate() const { 87 NavigationItemFacadeDelegate* NavigationItemImpl::GetFacadeDelegate() const {
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 } 245 }
244 246
245 void NavigationItemImpl::SetIsCreatedFromPushState(bool push_state) { 247 void NavigationItemImpl::SetIsCreatedFromPushState(bool push_state) {
246 is_created_from_push_state_ = push_state; 248 is_created_from_push_state_ = push_state;
247 } 249 }
248 250
249 bool NavigationItemImpl::IsCreatedFromPushState() const { 251 bool NavigationItemImpl::IsCreatedFromPushState() const {
250 return is_created_from_push_state_; 252 return is_created_from_push_state_;
251 } 253 }
252 254
255 void NavigationItemImpl::SetIsRendererInitiated(bool is_renderer_initiated) {
256 navigation_initiation_type_ =
257 is_renderer_initiated ? web::NavigationInitiationType::RENDERER_INITIATED
258 : web::NavigationInitiationType::USER_INITIATED;
259 }
260
261 bool NavigationItemImpl::IsRendererInitiated() const {
262 return navigation_initiation_type_ ==
263 web::NavigationInitiationType::RENDERER_INITIATED;
264 }
265
253 void NavigationItemImpl::SetHasStateBeenReplaced(bool replace_state) { 266 void NavigationItemImpl::SetHasStateBeenReplaced(bool replace_state) {
254 has_state_been_replaced_ = replace_state; 267 has_state_been_replaced_ = replace_state;
255 } 268 }
256 269
257 bool NavigationItemImpl::HasStateBeenReplaced() const { 270 bool NavigationItemImpl::HasStateBeenReplaced() const {
258 return has_state_been_replaced_; 271 return has_state_been_replaced_;
259 } 272 }
260 273
261 void NavigationItemImpl::SetIsCreatedFromHashChange(bool hash_change) { 274 void NavigationItemImpl::SetIsCreatedFromHashChange(bool hash_change) {
262 is_created_from_hash_change_ = hash_change; 275 is_created_from_hash_change_ = hash_change;
(...skipping 26 matching lines...) Expand all
289 http_request_headers_.reset(); 302 http_request_headers_.reset();
290 } 303 }
291 304
292 void NavigationItemImpl::ResetHttpRequestHeaders() { 305 void NavigationItemImpl::ResetHttpRequestHeaders() {
293 http_request_headers_.reset(); 306 http_request_headers_.reset();
294 } 307 }
295 308
296 void NavigationItemImpl::ResetForCommit() { 309 void NavigationItemImpl::ResetForCommit() {
297 // Any state that only matters when a navigation item is pending should be 310 // Any state that only matters when a navigation item is pending should be
298 // cleared here. 311 // cleared here.
299 set_is_renderer_initiated(false); 312 SetIsRendererInitiated(false);
300 } 313 }
301 314
302 } // namespace web 315 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698