| 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 "ios/web/web_state/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 6 | 6 |
| 7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
| 8 | 8 |
| 9 #import <objc/runtime.h> | 9 #import <objc/runtime.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1333 // advance and use that instead. https://crbug.com/227769. | 1333 // advance and use that instead. https://crbug.com/227769. |
| 1334 return web::Referrer(GURL(base::SysNSStringToUTF8(referrerString)), | 1334 return web::Referrer(GURL(base::SysNSStringToUTF8(referrerString)), |
| 1335 web::ReferrerPolicyAlways); | 1335 web::ReferrerPolicyAlways); |
| 1336 } | 1336 } |
| 1337 | 1337 |
| 1338 - (void)pushStateWithPageURL:(const GURL&)pageURL | 1338 - (void)pushStateWithPageURL:(const GURL&)pageURL |
| 1339 stateObject:(NSString*)stateObject | 1339 stateObject:(NSString*)stateObject |
| 1340 transition:(ui::PageTransition)transition { | 1340 transition:(ui::PageTransition)transition { |
| 1341 std::unique_ptr<web::NavigationContextImpl> context = | 1341 std::unique_ptr<web::NavigationContextImpl> context = |
| 1342 web::NavigationContextImpl::CreateNavigationContext(_webStateImpl, | 1342 web::NavigationContextImpl::CreateNavigationContext(_webStateImpl, |
| 1343 pageURL); | 1343 pageURL, transition); |
| 1344 _webStateImpl->OnNavigationStarted(context.get()); | 1344 _webStateImpl->OnNavigationStarted(context.get()); |
| 1345 [[self sessionController] pushNewItemWithURL:pageURL | 1345 [[self sessionController] pushNewItemWithURL:pageURL |
| 1346 stateObject:stateObject | 1346 stateObject:stateObject |
| 1347 transition:transition]; | 1347 transition:transition]; |
| 1348 context->SetIsSameDocument(true); | 1348 context->SetIsSameDocument(true); |
| 1349 _webStateImpl->OnNavigationFinished(context.get()); | 1349 _webStateImpl->OnNavigationFinished(context.get()); |
| 1350 self.userInteractionRegistered = NO; | 1350 self.userInteractionRegistered = NO; |
| 1351 } | 1351 } |
| 1352 | 1352 |
| 1353 - (void)replaceStateWithPageURL:(const GURL&)pageURL | 1353 - (void)replaceStateWithPageURL:(const GURL&)pageURL |
| 1354 stateObject:(NSString*)stateObject { | 1354 stateObject:(NSString*)stateObject { |
| 1355 std::unique_ptr<web::NavigationContextImpl> context = | 1355 std::unique_ptr<web::NavigationContextImpl> context = |
| 1356 web::NavigationContextImpl::CreateNavigationContext(_webStateImpl, | 1356 web::NavigationContextImpl::CreateNavigationContext( |
| 1357 pageURL); | 1357 _webStateImpl, pageURL, |
| 1358 ui::PageTransition::PAGE_TRANSITION_CLIENT_REDIRECT); |
| 1358 _webStateImpl->OnNavigationStarted(context.get()); | 1359 _webStateImpl->OnNavigationStarted(context.get()); |
| 1359 [[self sessionController] updateCurrentItemWithURL:pageURL | 1360 [[self sessionController] updateCurrentItemWithURL:pageURL |
| 1360 stateObject:stateObject]; | 1361 stateObject:stateObject]; |
| 1361 context->SetIsSameDocument(true); | 1362 context->SetIsSameDocument(true); |
| 1362 _webStateImpl->OnNavigationFinished(context.get()); | 1363 _webStateImpl->OnNavigationFinished(context.get()); |
| 1363 } | 1364 } |
| 1364 | 1365 |
| 1365 - (void)setDocumentURL:(const GURL&)newURL { | 1366 - (void)setDocumentURL:(const GURL&)newURL { |
| 1366 if (newURL != _documentURL && newURL.is_valid()) { | 1367 if (newURL != _documentURL && newURL.is_valid()) { |
| 1367 _documentURL = newURL; | 1368 _documentURL = newURL; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1522 // Typically on PAGE_TRANSITION_CLIENT_REDIRECT. | 1523 // Typically on PAGE_TRANSITION_CLIENT_REDIRECT. |
| 1523 [[self sessionController] updatePendingItem:requestURL]; | 1524 [[self sessionController] updatePendingItem:requestURL]; |
| 1524 } else { | 1525 } else { |
| 1525 // A new session history entry needs to be created. | 1526 // A new session history entry needs to be created. |
| 1526 self.navigationManagerImpl->AddPendingItem( | 1527 self.navigationManagerImpl->AddPendingItem( |
| 1527 requestURL, referrer, transition, | 1528 requestURL, referrer, transition, |
| 1528 web::NavigationInitiationType::RENDERER_INITIATED, | 1529 web::NavigationInitiationType::RENDERER_INITIATED, |
| 1529 web::NavigationManager::UserAgentOverrideOption::INHERIT); | 1530 web::NavigationManager::UserAgentOverrideOption::INHERIT); |
| 1530 } | 1531 } |
| 1531 std::unique_ptr<web::NavigationContextImpl> context = | 1532 std::unique_ptr<web::NavigationContextImpl> context = |
| 1532 web::NavigationContextImpl::CreateNavigationContext(_webStateImpl, | 1533 web::NavigationContextImpl::CreateNavigationContext( |
| 1533 requestURL); | 1534 _webStateImpl, requestURL, transition); |
| 1534 | 1535 |
| 1535 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem(); | 1536 web::NavigationItem* item = self.navigationManagerImpl->GetPendingItem(); |
| 1536 // TODO(crbug.com/676129): AddPendingItem does not always create a pending | 1537 // TODO(crbug.com/676129): AddPendingItem does not always create a pending |
| 1537 // item. Remove this workaround once the bug is fixed. | 1538 // item. Remove this workaround once the bug is fixed. |
| 1538 if (!item) { | 1539 if (!item) { |
| 1539 item = self.navigationManagerImpl->GetLastCommittedItem(); | 1540 item = self.navigationManagerImpl->GetLastCommittedItem(); |
| 1540 } | 1541 } |
| 1541 context->SetNavigationItemUniqueID(item->GetUniqueID()); | 1542 context->SetNavigationItemUniqueID(item->GetUniqueID()); |
| 1542 _webStateImpl->SetIsLoading(true); | 1543 _webStateImpl->SetIsLoading(true); |
| 1543 _webStateImpl->OnNavigationStarted(context.get()); | 1544 _webStateImpl->OnNavigationStarted(context.get()); |
| (...skipping 2625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4169 // Web View should not be created for App Specific URLs. | 4170 // Web View should not be created for App Specific URLs. |
| 4170 if (!web::GetWebClient()->IsAppSpecificURL(URL)) { | 4171 if (!web::GetWebClient()->IsAppSpecificURL(URL)) { |
| 4171 [self ensureWebViewCreated]; | 4172 [self ensureWebViewCreated]; |
| 4172 DCHECK(_webView) << "_webView null while trying to load HTML"; | 4173 DCHECK(_webView) << "_webView null while trying to load HTML"; |
| 4173 } | 4174 } |
| 4174 WKNavigation* navigation = | 4175 WKNavigation* navigation = |
| 4175 [_webView loadHTMLString:HTML baseURL:net::NSURLWithGURL(URL)]; | 4176 [_webView loadHTMLString:HTML baseURL:net::NSURLWithGURL(URL)]; |
| 4176 [_navigationStates setState:web::WKNavigationState::REQUESTED | 4177 [_navigationStates setState:web::WKNavigationState::REQUESTED |
| 4177 forNavigation:navigation]; | 4178 forNavigation:navigation]; |
| 4178 std::unique_ptr<web::NavigationContextImpl> context; | 4179 std::unique_ptr<web::NavigationContextImpl> context; |
| 4180 const ui::PageTransition loadHTMLTransition = |
| 4181 ui::PageTransition::PAGE_TRANSITION_TYPED; |
| 4179 if (_webStateImpl->HasWebUI()) { | 4182 if (_webStateImpl->HasWebUI()) { |
| 4180 // WebUI uses |loadHTML:forURL:| to feed the content to web view. This | 4183 // WebUI uses |loadHTML:forURL:| to feed the content to web view. This |
| 4181 // should not be treated as a navigation, but WKNavigationDelegate callbacks | 4184 // should not be treated as a navigation, but WKNavigationDelegate callbacks |
| 4182 // still expect a valid context. | 4185 // still expect a valid context. |
| 4183 context = | 4186 context = web::NavigationContextImpl::CreateNavigationContext( |
| 4184 web::NavigationContextImpl::CreateNavigationContext(_webStateImpl, URL); | 4187 _webStateImpl, URL, loadHTMLTransition); |
| 4185 } else { | 4188 } else { |
| 4186 context = [self | 4189 context = [self registerLoadRequestForURL:URL |
| 4187 registerLoadRequestForURL:URL | 4190 referrer:web::Referrer() |
| 4188 referrer:web::Referrer() | 4191 transition:loadHTMLTransition]; |
| 4189 transition:ui::PageTransition::PAGE_TRANSITION_TYPED]; | |
| 4190 } | 4192 } |
| 4191 [_navigationStates setContext:std::move(context) forNavigation:navigation]; | 4193 [_navigationStates setContext:std::move(context) forNavigation:navigation]; |
| 4192 } | 4194 } |
| 4193 | 4195 |
| 4194 - (void)loadHTML:(NSString*)HTML forAppSpecificURL:(const GURL&)URL { | 4196 - (void)loadHTML:(NSString*)HTML forAppSpecificURL:(const GURL&)URL { |
| 4195 CHECK(web::GetWebClient()->IsAppSpecificURL(URL)); | 4197 CHECK(web::GetWebClient()->IsAppSpecificURL(URL)); |
| 4196 [self loadHTML:HTML forURL:URL]; | 4198 [self loadHTML:HTML forURL:URL]; |
| 4197 } | 4199 } |
| 4198 | 4200 |
| 4199 - (void)loadHTMLForCurrentURL:(NSString*)HTML { | 4201 - (void)loadHTMLForCurrentURL:(NSString*)HTML { |
| (...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5232 - (NSUInteger)observerCount { | 5234 - (NSUInteger)observerCount { |
| 5233 DCHECK_EQ(_observerBridges.size(), [_observers count]); | 5235 DCHECK_EQ(_observerBridges.size(), [_observers count]); |
| 5234 return [_observers count]; | 5236 return [_observers count]; |
| 5235 } | 5237 } |
| 5236 | 5238 |
| 5237 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { | 5239 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { |
| 5238 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; | 5240 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; |
| 5239 } | 5241 } |
| 5240 | 5242 |
| 5241 @end | 5243 @end |
| OLD | NEW |