OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #include "ios/web/public/test/fakes/test_web_state_observer.h" | 5 #include "ios/web/public/test/fakes/test_web_state_observer.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "ios/web/public/web_state/navigation_context.h" | 8 #include "ios/web/public/web_state/navigation_context.h" |
9 #include "ios/web/public/web_state/web_state.h" | 9 #include "ios/web/public/web_state/web_state.h" |
10 #include "ios/web/web_state/navigation_context_impl.h" | 10 #include "ios/web/web_state/navigation_context_impl.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 navigation_items_pruned_info_->web_state = web_state(); | 58 navigation_items_pruned_info_->web_state = web_state(); |
59 navigation_items_pruned_info_->count = pruned_item_count; | 59 navigation_items_pruned_info_->count = pruned_item_count; |
60 } | 60 } |
61 | 61 |
62 void TestWebStateObserver::NavigationItemChanged() { | 62 void TestWebStateObserver::NavigationItemChanged() { |
63 navigation_item_changed_info_ = | 63 navigation_item_changed_info_ = |
64 base::MakeUnique<web::TestNavigationItemChangedInfo>(); | 64 base::MakeUnique<web::TestNavigationItemChangedInfo>(); |
65 navigation_item_changed_info_->web_state = web_state(); | 65 navigation_item_changed_info_->web_state = web_state(); |
66 } | 66 } |
67 | 67 |
68 void TestWebStateObserver::DidFinishNavigation(NavigationContext* context) { | 68 void TestWebStateObserver::DidFinishNavigation(NavigationContext* navigation) { |
| 69 ASSERT_TRUE(!navigation->IsErrorPage() || !navigation->IsSameDocument()); |
69 did_finish_navigation_info_ = | 70 did_finish_navigation_info_ = |
70 base::MakeUnique<web::TestDidFinishNavigationInfo>(); | 71 base::MakeUnique<web::TestDidFinishNavigationInfo>(); |
71 did_finish_navigation_info_->web_state = web_state(); | 72 did_finish_navigation_info_->web_state = web_state(); |
72 if (context->IsSameDocument()) { | 73 std::unique_ptr<web::NavigationContextImpl> context = |
73 ASSERT_FALSE(context->IsErrorPage()); | 74 web::NavigationContextImpl::CreateNavigationContext( |
74 did_finish_navigation_info_->context = | 75 navigation->GetWebState(), navigation->GetUrl()); |
75 NavigationContextImpl::CreateSameDocumentNavigationContext( | 76 context->SetIsSameDocument(navigation->IsSameDocument()); |
76 context->GetWebState(), context->GetUrl()); | 77 context->SetIsErrorPage(navigation->IsErrorPage()); |
77 } else if (context->IsErrorPage()) { | 78 did_finish_navigation_info_->context = std::move(context); |
78 ASSERT_FALSE(context->IsSameDocument()); | |
79 did_finish_navigation_info_->context = | |
80 NavigationContextImpl::CreateErrorPageNavigationContext( | |
81 context->GetWebState(), context->GetUrl(), | |
82 context->GetResponseHeaders()); | |
83 } else { | |
84 did_finish_navigation_info_->context = | |
85 NavigationContextImpl::CreateNavigationContext( | |
86 context->GetWebState(), context->GetUrl(), | |
87 context->GetResponseHeaders()); | |
88 } | |
89 } | 79 } |
90 | 80 |
91 void TestWebStateObserver::TitleWasSet() { | 81 void TestWebStateObserver::TitleWasSet() { |
92 title_was_set_info_ = base::MakeUnique<web::TestTitleWasSetInfo>(); | 82 title_was_set_info_ = base::MakeUnique<web::TestTitleWasSetInfo>(); |
93 title_was_set_info_->web_state = web_state(); | 83 title_was_set_info_->web_state = web_state(); |
94 } | 84 } |
95 | 85 |
96 void TestWebStateObserver::DidChangeVisibleSecurityState() { | 86 void TestWebStateObserver::DidChangeVisibleSecurityState() { |
97 did_change_visible_security_state_info_ = | 87 did_change_visible_security_state_info_ = |
98 base::MakeUnique<web::TestDidChangeVisibleSecurityStateInfo>(); | 88 base::MakeUnique<web::TestDidChangeVisibleSecurityStateInfo>(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 start_loading_info_ = base::MakeUnique<web::TestStartLoadingInfo>(); | 143 start_loading_info_ = base::MakeUnique<web::TestStartLoadingInfo>(); |
154 start_loading_info_->web_state = web_state(); | 144 start_loading_info_->web_state = web_state(); |
155 } | 145 } |
156 | 146 |
157 void TestWebStateObserver::DidStopLoading() { | 147 void TestWebStateObserver::DidStopLoading() { |
158 stop_loading_info_ = base::MakeUnique<web::TestStopLoadingInfo>(); | 148 stop_loading_info_ = base::MakeUnique<web::TestStopLoadingInfo>(); |
159 stop_loading_info_->web_state = web_state(); | 149 stop_loading_info_->web_state = web_state(); |
160 } | 150 } |
161 | 151 |
162 } // namespace web | 152 } // namespace web |
OLD | NEW |