| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/web/public/test/fakes/crw_test_web_state_observer.h" |
| 6 |
| 7 #include "base/memory/ptr_util.h" |
| 8 |
| 9 namespace web { |
| 10 TestFormActivityInfo::TestFormActivityInfo() {} |
| 11 TestFormActivityInfo::~TestFormActivityInfo() = default; |
| 12 TestUpdateFaviconUrlCandidatesInfo::TestUpdateFaviconUrlCandidatesInfo() {} |
| 13 TestUpdateFaviconUrlCandidatesInfo::~TestUpdateFaviconUrlCandidatesInfo() = |
| 14 default; |
| 15 } |
| 16 |
| 17 @implementation CRWTestWebStateObserver { |
| 18 // Arguments passed to |webState:didStartProvisionalNavigationForURL:|. |
| 19 std::unique_ptr<web::TestStartProvisionalNavigationInfo> |
| 20 _startProvisionalNavigationInfo; |
| 21 // Arguments passed to |webState:didCommitNavigationWithDetails:|. |
| 22 std::unique_ptr<web::TestCommitNavigationInfo> _commitNavigationInfo; |
| 23 // Arguments passed to |webState:didLoadPageWithSuccess:|. |
| 24 std::unique_ptr<web::TestLoadPageInfo> _loadPageInfo; |
| 25 // Arguments passed to |webStateDidDismissInterstitial:|. |
| 26 std::unique_ptr<web::TestDismissInterstitialInfo> _dismissInterstitialInfo; |
| 27 // Arguments passed to |webStateDidChangeURLHash:|. |
| 28 std::unique_ptr<web::TestChangeUrlHashInfo> _changeUrlHashInfo; |
| 29 // Arguments passed to |webStateDidChangeHistoryState:|. |
| 30 std::unique_ptr<web::TestChangeHistoryStateInfo> _changeHistoryStateInfo; |
| 31 // Arguments passed to |webState:didChangeLoadingProgress:|. |
| 32 std::unique_ptr<web::TestChangeLoadingProgressInfo> |
| 33 _changeLoadingProgressInfo; |
| 34 // Arguments passed to |
| 35 // |webState:didSubmitDocumentWithFormNamed:userInitiated:|. |
| 36 std::unique_ptr<web::TestSubmitDocumentInfo> _submitDocumentInfo; |
| 37 // Arguments passed to |
| 38 // |webState:didRegisterFormActivityWithFormNamed:fieldName:type:value:|. |
| 39 std::unique_ptr<web::TestFormActivityInfo> _formActivityInfo; |
| 40 // Arguments passed to |webState:didUpdateFaviconURLCandidates|. |
| 41 std::unique_ptr<web::TestUpdateFaviconUrlCandidatesInfo> |
| 42 _updateFaviconUrlCandidatesInfo; |
| 43 // Arguments passed to |webState:renderProcessGoneForWebState:|. |
| 44 std::unique_ptr<web::TestRenderProcessGoneInfo> _renderProcessGoneInfo; |
| 45 // Arguments passed to |webStateDestroyed:|. |
| 46 std::unique_ptr<web::TestWebStateDestroyedInfo> _webStateDestroyedInfo; |
| 47 // Arguments passed to |webStateDidStopLoading:|. |
| 48 std::unique_ptr<web::TestStopLoadingInfo> _stopLoadingInfo; |
| 49 // Arguments passed to |webStateDidStartLoading:|. |
| 50 std::unique_ptr<web::TestStartLoadingInfo> _startLoadingInfo; |
| 51 } |
| 52 |
| 53 - (web::TestStartProvisionalNavigationInfo*)startProvisionalNavigationInfo { |
| 54 return _startProvisionalNavigationInfo.get(); |
| 55 } |
| 56 |
| 57 - (web::TestCommitNavigationInfo*)commitNavigationInfo { |
| 58 return _commitNavigationInfo.get(); |
| 59 } |
| 60 |
| 61 - (web::TestLoadPageInfo*)loadPageInfo { |
| 62 return _loadPageInfo.get(); |
| 63 } |
| 64 |
| 65 - (web::TestDismissInterstitialInfo*)dismissInterstitialInfo { |
| 66 return _dismissInterstitialInfo.get(); |
| 67 } |
| 68 |
| 69 - (web::TestChangeUrlHashInfo*)changeUrlHashInfo { |
| 70 return _changeUrlHashInfo.get(); |
| 71 } |
| 72 |
| 73 - (web::TestChangeHistoryStateInfo*)changeHistoryStateInfo { |
| 74 return _changeHistoryStateInfo.get(); |
| 75 } |
| 76 |
| 77 - (web::TestChangeLoadingProgressInfo*)changeLoadingProgressInfo { |
| 78 return _changeLoadingProgressInfo.get(); |
| 79 } |
| 80 |
| 81 - (web::TestSubmitDocumentInfo*)submitDocumentInfo { |
| 82 return _submitDocumentInfo.get(); |
| 83 } |
| 84 |
| 85 - (web::TestFormActivityInfo*)formActivityInfo { |
| 86 return _formActivityInfo.get(); |
| 87 } |
| 88 |
| 89 - (web::TestUpdateFaviconUrlCandidatesInfo*)updateFaviconUrlCandidatesInfo { |
| 90 return _updateFaviconUrlCandidatesInfo.get(); |
| 91 } |
| 92 |
| 93 - (web::TestRenderProcessGoneInfo*)renderProcessGoneInfo { |
| 94 return _renderProcessGoneInfo.get(); |
| 95 } |
| 96 |
| 97 - (web::TestWebStateDestroyedInfo*)webStateDestroyedInfo { |
| 98 return _webStateDestroyedInfo.get(); |
| 99 } |
| 100 |
| 101 - (web::TestStopLoadingInfo*)stopLoadingInfo { |
| 102 return _stopLoadingInfo.get(); |
| 103 } |
| 104 |
| 105 - (web::TestStartLoadingInfo*)startLoadingInfo { |
| 106 return _startLoadingInfo.get(); |
| 107 } |
| 108 |
| 109 #pragma mark CRWWebStateObserver methods - |
| 110 |
| 111 - (void)webState:(web::WebState*)webState |
| 112 didStartProvisionalNavigationForURL:(const GURL&)URL { |
| 113 _startProvisionalNavigationInfo = |
| 114 base::MakeUnique<web::TestStartProvisionalNavigationInfo>(); |
| 115 _startProvisionalNavigationInfo->web_state = webState; |
| 116 _startProvisionalNavigationInfo->url = URL; |
| 117 } |
| 118 |
| 119 - (void)webState:(web::WebState*)webState |
| 120 didCommitNavigationWithDetails: |
| 121 (const web::LoadCommittedDetails&)load_details { |
| 122 _commitNavigationInfo = base::MakeUnique<web::TestCommitNavigationInfo>(); |
| 123 _commitNavigationInfo->web_state = webState; |
| 124 _commitNavigationInfo->load_details = load_details; |
| 125 } |
| 126 |
| 127 - (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success { |
| 128 _loadPageInfo = base::MakeUnique<web::TestLoadPageInfo>(); |
| 129 _loadPageInfo->web_state = webState; |
| 130 _loadPageInfo->success = success; |
| 131 } |
| 132 |
| 133 - (void)webStateDidDismissInterstitial:(web::WebState*)webState { |
| 134 _dismissInterstitialInfo = |
| 135 base::MakeUnique<web::TestDismissInterstitialInfo>(); |
| 136 _dismissInterstitialInfo->web_state = webState; |
| 137 } |
| 138 |
| 139 - (void)webStateDidChangeURLHash:(web::WebState*)webState { |
| 140 _changeUrlHashInfo = base::MakeUnique<web::TestChangeUrlHashInfo>(); |
| 141 _changeUrlHashInfo->web_state = webState; |
| 142 } |
| 143 |
| 144 - (void)webStateDidChangeHistoryState:(web::WebState*)webState { |
| 145 _changeHistoryStateInfo = base::MakeUnique<web::TestChangeHistoryStateInfo>(); |
| 146 _changeHistoryStateInfo->web_state = webState; |
| 147 } |
| 148 |
| 149 - (void)webState:(web::WebState*)webState |
| 150 didChangeLoadingProgress:(double)progress { |
| 151 _changeLoadingProgressInfo = |
| 152 base::MakeUnique<web::TestChangeLoadingProgressInfo>(); |
| 153 _changeLoadingProgressInfo->web_state = webState; |
| 154 _changeLoadingProgressInfo->progress = progress; |
| 155 } |
| 156 |
| 157 - (void)webState:(web::WebState*)webState |
| 158 didSubmitDocumentWithFormNamed:(const std::string&)formName |
| 159 userInitiated:(BOOL)userInitiated { |
| 160 _submitDocumentInfo = base::MakeUnique<web::TestSubmitDocumentInfo>(); |
| 161 _submitDocumentInfo->web_state = webState; |
| 162 _submitDocumentInfo->form_name = formName; |
| 163 _submitDocumentInfo->user_initiated = userInitiated; |
| 164 } |
| 165 |
| 166 - (void)webState:(web::WebState*)webState |
| 167 didRegisterFormActivityWithFormNamed:(const std::string&)formName |
| 168 fieldName:(const std::string&)fieldName |
| 169 type:(const std::string&)type |
| 170 value:(const std::string&)value |
| 171 inputMissing:(BOOL)inputMissing { |
| 172 _formActivityInfo = base::MakeUnique<web::TestFormActivityInfo>(); |
| 173 _formActivityInfo->web_state = webState; |
| 174 _formActivityInfo->form_name = formName; |
| 175 _formActivityInfo->field_name = fieldName; |
| 176 _formActivityInfo->type = type; |
| 177 _formActivityInfo->value = value; |
| 178 _formActivityInfo->input_missing = inputMissing; |
| 179 } |
| 180 |
| 181 - (void)webState:(web::WebState*)webState |
| 182 didUpdateFaviconURLCandidates: |
| 183 (const std::vector<web::FaviconURL>&)candidates { |
| 184 _updateFaviconUrlCandidatesInfo = |
| 185 base::MakeUnique<web::TestUpdateFaviconUrlCandidatesInfo>(); |
| 186 _updateFaviconUrlCandidatesInfo->web_state = webState; |
| 187 _updateFaviconUrlCandidatesInfo->candidates = candidates; |
| 188 } |
| 189 |
| 190 - (void)renderProcessGoneForWebState:(web::WebState*)webState { |
| 191 _renderProcessGoneInfo = base::MakeUnique<web::TestRenderProcessGoneInfo>(); |
| 192 _renderProcessGoneInfo->web_state = webState; |
| 193 } |
| 194 |
| 195 - (void)webStateDestroyed:(web::WebState*)webState { |
| 196 _webStateDestroyedInfo = base::MakeUnique<web::TestWebStateDestroyedInfo>(); |
| 197 _webStateDestroyedInfo->web_state = webState; |
| 198 } |
| 199 |
| 200 - (void)webStateDidStopLoading:(web::WebState*)webState { |
| 201 _stopLoadingInfo = base::MakeUnique<web::TestStopLoadingInfo>(); |
| 202 _stopLoadingInfo->web_state = webState; |
| 203 } |
| 204 |
| 205 - (void)webStateDidStartLoading:(web::WebState*)webState { |
| 206 _startLoadingInfo = base::MakeUnique<web::TestStartLoadingInfo>(); |
| 207 _startLoadingInfo->web_state = webState; |
| 208 } |
| 209 |
| 210 @end |
| OLD | NEW |