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

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

Issue 2705293014: Created web::UserAgentType. (Closed)
Patch Set: Eugene's comments Created 3 years, 9 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 #import "ios/web/navigation/navigation_manager_impl.h"
15 #import "ios/web/public/web_client.h"
15 #include "ui/base/page_transition_types.h" 16 #include "ui/base/page_transition_types.h"
16 #include "ui/gfx/text_elider.h" 17 #include "ui/gfx/text_elider.h"
17 18
18 #if !defined(__has_feature) || !__has_feature(objc_arc) 19 #if !defined(__has_feature) || !__has_feature(objc_arc)
19 #error "This file requires ARC support." 20 #error "This file requires ARC support."
20 #endif 21 #endif
21 22
22 namespace { 23 namespace {
23 24
24 // Returns a new unique ID for use in NavigationItem during construction. The 25 // Returns a new unique ID for use in NavigationItem during construction. The
25 // returned ID is guaranteed to be nonzero (which is the "no ID" indicator). 26 // returned ID is guaranteed to be nonzero (which is the "no ID" indicator).
26 static int GetUniqueIDInConstructor() { 27 static int GetUniqueIDInConstructor() {
27 static int unique_id_counter = 0; 28 static int unique_id_counter = 0;
28 return ++unique_id_counter; 29 return ++unique_id_counter;
29 } 30 }
30 31
31 } // namespace 32 } // namespace
32 33
33 namespace web { 34 namespace web {
34 35
35 // static 36 // static
36 std::unique_ptr<NavigationItem> NavigationItem::Create() { 37 std::unique_ptr<NavigationItem> NavigationItem::Create() {
37 return std::unique_ptr<NavigationItem>(new NavigationItemImpl()); 38 return std::unique_ptr<NavigationItem>(new NavigationItemImpl());
38 } 39 }
39 40
40 NavigationItemImpl::NavigationItemImpl() 41 NavigationItemImpl::NavigationItemImpl()
41 : unique_id_(GetUniqueIDInConstructor()), 42 : unique_id_(GetUniqueIDInConstructor()),
42 transition_type_(ui::PAGE_TRANSITION_LINK), 43 transition_type_(ui::PAGE_TRANSITION_LINK),
43 is_overriding_user_agent_(false), 44 user_agent_type_(UserAgentType::MOBILE),
44 is_created_from_push_state_(false), 45 is_created_from_push_state_(false),
45 has_state_been_replaced_(false), 46 has_state_been_replaced_(false),
46 is_created_from_hash_change_(false), 47 is_created_from_hash_change_(false),
47 should_skip_repost_form_confirmation_(false), 48 should_skip_repost_form_confirmation_(false),
48 navigation_initiation_type_(web::NavigationInitiationType::NONE), 49 navigation_initiation_type_(web::NavigationInitiationType::NONE),
49 is_unsafe_(false), 50 is_unsafe_(false),
50 facade_delegate_(nullptr) {} 51 facade_delegate_(nullptr) {}
51 52
52 NavigationItemImpl::~NavigationItemImpl() { 53 NavigationItemImpl::~NavigationItemImpl() {
53 } 54 }
54 55
55 NavigationItemImpl::NavigationItemImpl(const NavigationItemImpl& item) 56 NavigationItemImpl::NavigationItemImpl(const NavigationItemImpl& item)
56 : unique_id_(item.unique_id_), 57 : unique_id_(item.unique_id_),
57 original_request_url_(item.original_request_url_), 58 original_request_url_(item.original_request_url_),
58 url_(item.url_), 59 url_(item.url_),
59 referrer_(item.referrer_), 60 referrer_(item.referrer_),
60 virtual_url_(item.virtual_url_), 61 virtual_url_(item.virtual_url_),
61 title_(item.title_), 62 title_(item.title_),
62 page_display_state_(item.page_display_state_), 63 page_display_state_(item.page_display_state_),
63 transition_type_(item.transition_type_), 64 transition_type_(item.transition_type_),
64 favicon_(item.favicon_), 65 favicon_(item.favicon_),
65 ssl_(item.ssl_), 66 ssl_(item.ssl_),
66 timestamp_(item.timestamp_), 67 timestamp_(item.timestamp_),
67 is_overriding_user_agent_(item.is_overriding_user_agent_), 68 user_agent_type_(item.user_agent_type_),
68 http_request_headers_([item.http_request_headers_ copy]), 69 http_request_headers_([item.http_request_headers_ copy]),
69 serialized_state_object_([item.serialized_state_object_ copy]), 70 serialized_state_object_([item.serialized_state_object_ copy]),
70 is_created_from_push_state_(item.is_created_from_push_state_), 71 is_created_from_push_state_(item.is_created_from_push_state_),
71 has_state_been_replaced_(item.has_state_been_replaced_), 72 has_state_been_replaced_(item.has_state_been_replaced_),
72 is_created_from_hash_change_(item.is_created_from_hash_change_), 73 is_created_from_hash_change_(item.is_created_from_hash_change_),
73 should_skip_repost_form_confirmation_( 74 should_skip_repost_form_confirmation_(
74 item.should_skip_repost_form_confirmation_), 75 item.should_skip_repost_form_confirmation_),
75 post_data_([item.post_data_ copy]), 76 post_data_([item.post_data_ copy]),
76 navigation_initiation_type_(item.navigation_initiation_type_), 77 navigation_initiation_type_(item.navigation_initiation_type_),
77 is_unsafe_(item.is_unsafe_), 78 is_unsafe_(item.is_unsafe_),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 } 200 }
200 201
201 void NavigationItemImpl::SetTimestamp(base::Time timestamp) { 202 void NavigationItemImpl::SetTimestamp(base::Time timestamp) {
202 timestamp_ = timestamp; 203 timestamp_ = timestamp;
203 } 204 }
204 205
205 base::Time NavigationItemImpl::GetTimestamp() const { 206 base::Time NavigationItemImpl::GetTimestamp() const {
206 return timestamp_; 207 return timestamp_;
207 } 208 }
208 209
209 void NavigationItemImpl::SetIsOverridingUserAgent( 210 void NavigationItemImpl::SetUserAgentType(UserAgentType type) {
210 bool is_overriding_user_agent) { 211 user_agent_type_ = type;
211 is_overriding_user_agent_ = is_overriding_user_agent; 212 url_ = original_request_url_;
Eugene But (OOO till 7-30) 2017/02/27 23:55:18 Why? The old code and NavigationEntryImpl is not d
liaoyuke 2017/03/01 01:33:56 Actually, now I think this is bad. We may justify
kkhorimoto 2017/03/01 18:29:25 I've reverted this change, instead only setting |u
213 virtual_url_ = GURL();
214 DCHECK_EQ(GetWebClient()->IsAppSpecificURL(GetVirtualURL()),
215 user_agent_type_ == UserAgentType::NONE);
212 } 216 }
213 217
214 bool NavigationItemImpl::IsOverridingUserAgent() const { 218 UserAgentType NavigationItemImpl::GetUserAgentType() const {
215 return is_overriding_user_agent_; 219 return user_agent_type_;
216 } 220 }
217 221
218 bool NavigationItemImpl::HasPostData() const { 222 bool NavigationItemImpl::HasPostData() const {
219 return post_data_.get() != nil; 223 return post_data_.get() != nil;
220 } 224 }
221 225
222 NSDictionary* NavigationItemImpl::GetHttpRequestHeaders() const { 226 NSDictionary* NavigationItemImpl::GetHttpRequestHeaders() const {
223 return [http_request_headers_ copy]; 227 return [http_request_headers_ copy];
224 } 228 }
225 229
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 http_request_headers_.reset(); 308 http_request_headers_.reset();
305 } 309 }
306 310
307 void NavigationItemImpl::ResetForCommit() { 311 void NavigationItemImpl::ResetForCommit() {
308 // Navigation initiation type is only valid for pending navigations, thus 312 // Navigation initiation type is only valid for pending navigations, thus
309 // always reset to NONE after the item is committed. 313 // always reset to NONE after the item is committed.
310 SetNavigationInitiationType(web::NavigationInitiationType::NONE); 314 SetNavigationInitiationType(web::NavigationInitiationType::NONE);
311 } 315 }
312 316
313 } // namespace web 317 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698