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

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

Issue 2698773002: [iOS] Refactoring web CRWSessionController user agent code. (Closed)
Patch Set: Fix unit tests and rebase 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 // The initiation type of this pending navigation. Resets to user-initiated
99 // after commit.
100 void SetNavigationInitiationType(
101 web::NavigationInitiationType navigation_initiation_type);
102 web::NavigationInitiationType NavigationInitiationType() const;
103
97 // Whether or not to bypass showing the repost form confirmation when loading 104 // Whether or not to bypass showing the repost form confirmation when loading
98 // a POST request. Set to YES for browser-generated POST requests. 105 // a POST request. Set to YES for browser-generated POST requests.
99 void SetShouldSkipRepostFormConfirmation(bool skip); 106 void SetShouldSkipRepostFormConfirmation(bool skip);
100 bool ShouldSkipRepostFormConfirmation() const; 107 bool ShouldSkipRepostFormConfirmation() const;
101 108
102 // Data submitted with a POST request, persisted for resubmits. 109 // Data submitted with a POST request, persisted for resubmits.
103 void SetPostData(NSData* post_data); 110 void SetPostData(NSData* post_data);
104 NSData* GetPostData() const; 111 NSData* GetPostData() const;
105 112
106 // Removes the header for |key| from |http_request_headers_|. 113 // Removes the header for |key| from |http_request_headers_|.
107 void RemoveHttpRequestHeaderForKey(NSString* key); 114 void RemoveHttpRequestHeaderForKey(NSString* key);
108 115
109 // Removes all http headers from |http_request_headers_|. 116 // Removes all http headers from |http_request_headers_|.
110 void ResetHttpRequestHeaders(); 117 void ResetHttpRequestHeaders();
111 118
112 // Once a navigation item is committed, we should no longer track 119 // Once a navigation item is committed, we should no longer track
113 // non-persisted state, as documented on the members below. 120 // non-persisted state, as documented on the members below.
114 void ResetForCommit(); 121 void ResetForCommit();
115 122
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: 123 private:
124 // The NavigationManItemStorageBuilder functions require access to 124 // The NavigationManItemStorageBuilder functions require access to
125 // private variables of NavigationItemImpl. 125 // private variables of NavigationItemImpl.
126 friend NavigationItemStorageBuilder; 126 friend NavigationItemStorageBuilder;
127 127
128 int unique_id_; 128 int unique_id_;
129 GURL original_request_url_; 129 GURL original_request_url_;
130 GURL url_; 130 GURL url_;
131 Referrer referrer_; 131 Referrer referrer_;
132 GURL virtual_url_; 132 GURL virtual_url_;
133 base::string16 title_; 133 base::string16 title_;
134 PageDisplayState page_display_state_; 134 PageDisplayState page_display_state_;
135 ui::PageTransition transition_type_; 135 ui::PageTransition transition_type_;
136 FaviconStatus favicon_; 136 FaviconStatus favicon_;
137 SSLStatus ssl_; 137 SSLStatus ssl_;
138 base::Time timestamp_; 138 base::Time timestamp_;
139 bool is_overriding_user_agent_; 139 bool is_overriding_user_agent_;
140 base::scoped_nsobject<NSMutableDictionary> http_request_headers_; 140 base::scoped_nsobject<NSMutableDictionary> http_request_headers_;
141 141
142 base::scoped_nsobject<NSString> serialized_state_object_; 142 base::scoped_nsobject<NSString> serialized_state_object_;
143 bool is_created_from_push_state_; 143 bool is_created_from_push_state_;
144 bool has_state_been_replaced_; 144 bool has_state_been_replaced_;
145 bool is_created_from_hash_change_; 145 bool is_created_from_hash_change_;
146 bool should_skip_repost_form_confirmation_; 146 bool should_skip_repost_form_confirmation_;
147 base::scoped_nsobject<NSData> post_data_; 147 base::scoped_nsobject<NSData> post_data_;
148 148
149 // Whether the item, while loading, was created for a renderer-initiated 149 // The navigation initiation type of the item. This decides whether the URL
150 // navigation. This dictates whether the URL should be displayed before the 150 // should be displayed before the navigation commits. It is cleared in
151 // navigation commits. It is cleared in |ResetForCommit| and not persisted. 151 // |ResetForCommit| and not persisted.
152 bool is_renderer_initiated_; 152 web::NavigationInitiationType navigation_initiation_type_;
153 153
154 // Whether the navigation contains unsafe resources. 154 // Whether the navigation contains unsafe resources.
155 bool is_unsafe_; 155 bool is_unsafe_;
156 156
157 // This is a cached version of the result of GetTitleForDisplay. When the URL, 157 // 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. 158 // virtual URL, or title is set, this should be cleared to force a refresh.
159 mutable base::string16 cached_display_title_; 159 mutable base::string16 cached_display_title_;
160 160
161 // Weak pointer to the facade delegate. 161 // Weak pointer to the facade delegate.
162 std::unique_ptr<NavigationItemFacadeDelegate> facade_delegate_; 162 std::unique_ptr<NavigationItemFacadeDelegate> facade_delegate_;
163 163
164 // Copy and assignment is explicitly allowed for this class. 164 // Copy and assignment is explicitly allowed for this class.
165 }; 165 };
166 166
167 } // namespace web 167 } // namespace web
168 168
169 #endif // IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ 169 #endif // IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_
OLDNEW
« no previous file with comments | « ios/web/navigation/crw_session_controller_unittest.mm ('k') | ios/web/navigation/navigation_item_impl.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698