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

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

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 #ifndef IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ 5 #ifndef IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_
6 #define IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ 6 #define IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_
7 7
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #import "base/mac/scoped_nsobject.h" 12 #import "base/mac/scoped_nsobject.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "ios/web/navigation/navigation_item_facade_delegate.h" 14 #include "ios/web/navigation/navigation_item_facade_delegate.h"
15 #include "ios/web/public/favicon_status.h" 15 #include "ios/web/public/favicon_status.h"
16 #import "ios/web/public/navigation_item.h" 16 #import "ios/web/public/navigation_item.h"
17 #include "ios/web/public/referrer.h" 17 #include "ios/web/public/referrer.h"
18 #include "ios/web/public/ssl_status.h" 18 #include "ios/web/public/ssl_status.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 namespace web { 21 namespace web {
22 22
23 class NavigationItemFacadeDelegate; 23 class NavigationItemFacadeDelegate;
24 class NavigationItemStorageBuilder; 24 class NavigationItemStorageBuilder;
25 enum class NavigationInitiationType;
25 26
26 // Implementation of NavigationItem. 27 // Implementation of NavigationItem.
27 class NavigationItemImpl : public web::NavigationItem { 28 class NavigationItemImpl : public web::NavigationItem {
28 public: 29 public:
29 // Creates a default NavigationItemImpl. 30 // Creates a default NavigationItemImpl.
30 NavigationItemImpl(); 31 NavigationItemImpl();
31 ~NavigationItemImpl() override; 32 ~NavigationItemImpl() override;
32 33
33 // Since NavigationItemImpls own their facade delegates, there is no implicit 34 // Since NavigationItemImpls own their facade delegates, there is no implicit
34 // copy constructor (scoped_ptrs can't be copied), so one is defined here. 35 // copy constructor (scoped_ptrs can't be copied), so one is defined here.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // TODO(crbug.com/659816): This state is only tracked because of flaky early 88 // TODO(crbug.com/659816): This state is only tracked because of flaky early
88 // page script injection. Once the root cause of this flake is found, this 89 // page script injection. Once the root cause of this flake is found, this
89 // can be removed. 90 // can be removed.
90 void SetHasStateBeenReplaced(bool replace_state); 91 void SetHasStateBeenReplaced(bool replace_state);
91 bool HasStateBeenReplaced() const; 92 bool HasStateBeenReplaced() const;
92 93
93 // Whether this navigation is the result of a hash change. 94 // Whether this navigation is the result of a hash change.
94 void SetIsCreatedFromHashChange(bool hash_change); 95 void SetIsCreatedFromHashChange(bool hash_change);
95 bool IsCreatedFromHashChange() const; 96 bool IsCreatedFromHashChange() const;
96 97
98 // Whether this (pending) navigation is renderer-initiated. Resets to false
99 // after commit.
100 void SetIsRendererInitiated(bool is_renderer_initiated);
kkhorimoto 2017/02/17 20:51:35 Instead of passing a bool here, let's just have a
liaoyuke 2017/02/17 22:15:40 Done.
101 bool IsRendererInitiated() const;
102
97 // Whether or not to bypass showing the repost form confirmation when loading 103 // Whether or not to bypass showing the repost form confirmation when loading
98 // a POST request. Set to YES for browser-generated POST requests. 104 // a POST request. Set to YES for browser-generated POST requests.
99 void SetShouldSkipRepostFormConfirmation(bool skip); 105 void SetShouldSkipRepostFormConfirmation(bool skip);
100 bool ShouldSkipRepostFormConfirmation() const; 106 bool ShouldSkipRepostFormConfirmation() const;
101 107
102 // Data submitted with a POST request, persisted for resubmits. 108 // Data submitted with a POST request, persisted for resubmits.
103 void SetPostData(NSData* post_data); 109 void SetPostData(NSData* post_data);
104 NSData* GetPostData() const; 110 NSData* GetPostData() const;
105 111
106 // Removes the header for |key| from |http_request_headers_|. 112 // Removes the header for |key| from |http_request_headers_|.
107 void RemoveHttpRequestHeaderForKey(NSString* key); 113 void RemoveHttpRequestHeaderForKey(NSString* key);
108 114
109 // Removes all http headers from |http_request_headers_|. 115 // Removes all http headers from |http_request_headers_|.
110 void ResetHttpRequestHeaders(); 116 void ResetHttpRequestHeaders();
111 117
112 // Once a navigation item is committed, we should no longer track 118 // Once a navigation item is committed, we should no longer track
113 // non-persisted state, as documented on the members below. 119 // non-persisted state, as documented on the members below.
114 void ResetForCommit(); 120 void ResetForCommit();
115 121
116 // Whether this (pending) navigation is renderer-initiated. Resets to false
117 // for all types of navigations after commit.
118 void set_is_renderer_initiated(bool is_renderer_initiated) {
119 is_renderer_initiated_ = is_renderer_initiated;
120 }
121 bool is_renderer_initiated() const { return is_renderer_initiated_; }
122
123 private: 122 private:
124 // The NavigationManItemStorageBuilder functions require access to 123 // The NavigationManItemStorageBuilder functions require access to
125 // private variables of NavigationItemImpl. 124 // private variables of NavigationItemImpl.
126 friend NavigationItemStorageBuilder; 125 friend NavigationItemStorageBuilder;
127 126
128 int unique_id_; 127 int unique_id_;
129 GURL original_request_url_; 128 GURL original_request_url_;
130 GURL url_; 129 GURL url_;
131 Referrer referrer_; 130 Referrer referrer_;
132 GURL virtual_url_; 131 GURL virtual_url_;
133 base::string16 title_; 132 base::string16 title_;
134 PageDisplayState page_display_state_; 133 PageDisplayState page_display_state_;
135 ui::PageTransition transition_type_; 134 ui::PageTransition transition_type_;
136 FaviconStatus favicon_; 135 FaviconStatus favicon_;
137 SSLStatus ssl_; 136 SSLStatus ssl_;
138 base::Time timestamp_; 137 base::Time timestamp_;
139 bool is_overriding_user_agent_; 138 bool is_overriding_user_agent_;
140 base::scoped_nsobject<NSMutableDictionary> http_request_headers_; 139 base::scoped_nsobject<NSMutableDictionary> http_request_headers_;
141 140
142 base::scoped_nsobject<NSString> serialized_state_object_; 141 base::scoped_nsobject<NSString> serialized_state_object_;
143 bool is_created_from_push_state_; 142 bool is_created_from_push_state_;
144 bool has_state_been_replaced_; 143 bool has_state_been_replaced_;
145 bool is_created_from_hash_change_; 144 bool is_created_from_hash_change_;
146 bool should_skip_repost_form_confirmation_; 145 bool should_skip_repost_form_confirmation_;
147 base::scoped_nsobject<NSData> post_data_; 146 base::scoped_nsobject<NSData> post_data_;
148 147
149 // Whether the item, while loading, was created for a renderer-initiated 148 // The navigation initiation type of the item. This decides whether the URL
150 // navigation. This dictates whether the URL should be displayed before the 149 // should be displayed before the navigation commits. It is cleared in
151 // navigation commits. It is cleared in |ResetForCommit| and not persisted. 150 // |ResetForCommit| and not persisted.
152 bool is_renderer_initiated_; 151 web::NavigationInitiationType navigation_initiation_type_;
153 152
154 // Whether the navigation contains unsafe resources. 153 // Whether the navigation contains unsafe resources.
155 bool is_unsafe_; 154 bool is_unsafe_;
156 155
157 // This is a cached version of the result of GetTitleForDisplay. When the URL, 156 // This is a cached version of the result of GetTitleForDisplay. When the URL,
158 // virtual URL, or title is set, this should be cleared to force a refresh. 157 // virtual URL, or title is set, this should be cleared to force a refresh.
159 mutable base::string16 cached_display_title_; 158 mutable base::string16 cached_display_title_;
160 159
161 // Weak pointer to the facade delegate. 160 // Weak pointer to the facade delegate.
162 std::unique_ptr<NavigationItemFacadeDelegate> facade_delegate_; 161 std::unique_ptr<NavigationItemFacadeDelegate> facade_delegate_;
163 162
164 // Copy and assignment is explicitly allowed for this class. 163 // Copy and assignment is explicitly allowed for this class.
165 }; 164 };
166 165
167 } // namespace web 166 } // namespace web
168 167
169 #endif // IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ 168 #endif // IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698