| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 <UIKit/UIKit.h> | 5 #import <UIKit/UIKit.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 void TearDown() override { | 225 void TearDown() override { |
| 226 // Ensure that the Tab is destroyed before the autorelease pool is cleared. | 226 // Ensure that the Tab is destroyed before the autorelease pool is cleared. |
| 227 web_state_impl_.reset(); | 227 web_state_impl_.reset(); |
| 228 BlockCleanupTest::TearDown(); | 228 BlockCleanupTest::TearDown(); |
| 229 } | 229 } |
| 230 | 230 |
| 231 void BrowseTo(const GURL& userUrl, const GURL& redirectUrl, NSString* title) { | 231 void BrowseTo(const GURL& userUrl, const GURL& redirectUrl, NSString* title) { |
| 232 DCHECK_EQ(tab_.get().webState, web_state_impl_.get()); | 232 DCHECK_EQ(tab_.get().webState, web_state_impl_.get()); |
| 233 | 233 |
| 234 [tab_ webWillAddPendingURL:userUrl transition:ui::PAGE_TRANSITION_TYPED]; | 234 [tab_ webWillAddPendingURL:userUrl transition:ui::PAGE_TRANSITION_TYPED]; |
| 235 web_state_impl_->OnProvisionalNavigationStarted(userUrl); | 235 std::unique_ptr<web::NavigationContext> context1 = |
| 236 web::NavigationContextImpl::CreateNavigationContext( |
| 237 web_state_impl_.get(), userUrl); |
| 238 web_state_impl_->OnNavigationStarted(context1.get()); |
| 236 [tab_ webWillAddPendingURL:redirectUrl | 239 [tab_ webWillAddPendingURL:redirectUrl |
| 237 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT]; | 240 transition:ui::PAGE_TRANSITION_CLIENT_REDIRECT]; |
| 238 | 241 |
| 239 web::Referrer empty_referrer; | 242 web::Referrer empty_referrer; |
| 240 [tab_ navigationManagerImpl]->AddPendingItem( | 243 [tab_ navigationManagerImpl]->AddPendingItem( |
| 241 redirectUrl, empty_referrer, ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 244 redirectUrl, empty_referrer, ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
| 242 web::NavigationInitiationType::RENDERER_INITIATED, | 245 web::NavigationInitiationType::RENDERER_INITIATED, |
| 243 web::NavigationManager::UserAgentOverrideOption::INHERIT); | 246 web::NavigationManager::UserAgentOverrideOption::INHERIT); |
| 244 | 247 |
| 245 web_state_impl_->OnProvisionalNavigationStarted(redirectUrl); | 248 std::unique_ptr<web::NavigationContext> context2 = |
| 249 web::NavigationContextImpl::CreateNavigationContext( |
| 250 web_state_impl_.get(), redirectUrl); |
| 251 web_state_impl_->OnNavigationStarted(context2.get()); |
| 246 [[tab_ navigationManagerImpl]->GetSessionController() commitPendingItem]; | 252 [[tab_ navigationManagerImpl]->GetSessionController() commitPendingItem]; |
| 247 web_state_impl_->UpdateHttpResponseHeaders(redirectUrl); | 253 web_state_impl_->UpdateHttpResponseHeaders(redirectUrl); |
| 248 std::unique_ptr<web::NavigationContext> context = | 254 web_state_impl_->OnNavigationFinished(context2.get()); |
| 249 web::NavigationContextImpl::CreateNavigationContext( | |
| 250 web_state_impl_.get(), redirectUrl); | |
| 251 web_state_impl_->OnNavigationFinished(context.get()); | |
| 252 | 255 |
| 253 base::string16 new_title = base::SysNSStringToUTF16(title); | 256 base::string16 new_title = base::SysNSStringToUTF16(title); |
| 254 [tab_ navigationManager]->GetLastCommittedItem()->SetTitle(new_title); | 257 [tab_ navigationManager]->GetLastCommittedItem()->SetTitle(new_title); |
| 255 | 258 |
| 256 web_state_impl_->OnTitleChanged(); | 259 web_state_impl_->OnTitleChanged(); |
| 257 [[[(id)mock_web_controller_ expect] | 260 [[[(id)mock_web_controller_ expect] |
| 258 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase]; | 261 andReturnValue:OCMOCK_VALUE(kPageLoaded)] loadPhase]; |
| 259 web_state_impl_->OnPageLoaded(redirectUrl, true); | 262 web_state_impl_->OnPageLoaded(redirectUrl, true); |
| 260 } | 263 } |
| 261 | 264 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 [[FakeNativeAppMetadata alloc] init]); | 593 [[FakeNativeAppMetadata alloc] init]); |
| 591 | 594 |
| 592 // Turn auto open on. | 595 // Turn auto open on. |
| 593 [metadata setShouldAutoOpenLinks:YES]; | 596 [metadata setShouldAutoOpenLinks:YES]; |
| 594 int expectedCallCount = 2; | 597 int expectedCallCount = 2; |
| 595 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); | 598 TestOpenNativeAppURL(testURL, NO, expectedCallCount, NO); |
| 596 EXPECT_FALSE([metadata shouldAutoOpenLinks]); | 599 EXPECT_FALSE([metadata shouldAutoOpenLinks]); |
| 597 } | 600 } |
| 598 | 601 |
| 599 } // namespace | 602 } // namespace |
| OLD | NEW |