Chromium Code Reviews| 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/navigation/crw_session_controller.h" | 5 #import "ios/web/navigation/crw_session_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 | 277 |
| 278 - (void)setBrowserState:(web::BrowserState*)browserState { | 278 - (void)setBrowserState:(web::BrowserState*)browserState { |
| 279 _browserState = browserState; | 279 _browserState = browserState; |
| 280 DCHECK(!_navigationManager || | 280 DCHECK(!_navigationManager || |
| 281 _navigationManager->GetBrowserState() == _browserState); | 281 _navigationManager->GetBrowserState() == _browserState); |
| 282 } | 282 } |
| 283 | 283 |
| 284 - (void)addPendingItem:(const GURL&)url | 284 - (void)addPendingItem:(const GURL&)url |
| 285 referrer:(const web::Referrer&)ref | 285 referrer:(const web::Referrer&)ref |
| 286 transition:(ui::PageTransition)trans | 286 transition:(ui::PageTransition)trans |
| 287 initiationType:(web::NavigationInitiationType)initiationType { | 287 initiationType:(web::NavigationInitiationType)initiationType |
| 288 userAgentOverrideOption:(web::NavigationManager::UserAgentOverrideOption) | |
| 289 userAgentOverrideOption { | |
| 288 // Server side redirects are handled by updating existing pending item instead | 290 // Server side redirects are handled by updating existing pending item instead |
| 289 // of adding a new item. | 291 // of adding a new item. |
| 290 DCHECK((trans & ui::PAGE_TRANSITION_SERVER_REDIRECT) == 0); | 292 DCHECK((trans & ui::PAGE_TRANSITION_SERVER_REDIRECT) == 0); |
| 291 | 293 |
| 292 [self discardTransientItem]; | 294 [self discardTransientItem]; |
| 293 self.pendingItemIndex = -1; | 295 self.pendingItemIndex = -1; |
| 294 | 296 |
| 295 // Don't create a new item if it's already the same as the current item, | 297 // Don't create a new item if it's already the same as the current item, |
| 296 // allowing this routine to be called multiple times in a row without issue. | 298 // allowing this routine to be called multiple times in a row without issue. |
| 297 // Note: CRWSessionController currently has the responsibility to distinguish | 299 // Note: CRWSessionController currently has the responsibility to distinguish |
| 298 // between new navigations and history stack navigation, hence the inclusion | 300 // between new navigations and history stack navigation, hence the inclusion |
| 299 // of specific transiton type logic here, in order to make it reliable with | 301 // of specific transiton type logic here, in order to make it reliable with |
| 300 // real-world observed behavior. | 302 // real-world observed behavior. |
| 301 // TODO(crbug.com/676129): Fix the way changes are detected/reported elsewhere | 303 // TODO(crbug.com/676129): Fix the way changes are detected/reported elsewhere |
| 302 // in the web layer so that this hack can be removed. | 304 // in the web layer so that this hack can be removed. |
| 303 // Remove the workaround code from -presentSafeBrowsingWarningForResource:. | 305 // Remove the workaround code from -presentSafeBrowsingWarningForResource:. |
| 304 web::NavigationItemImpl* currentItem = self.currentItem; | 306 web::NavigationItemImpl* currentItem = self.currentItem; |
| 305 if (currentItem) { | 307 if (currentItem) { |
| 306 BOOL hasSameURL = currentItem->GetURL() == url; | 308 BOOL hasSameURL = currentItem->GetURL() == url; |
| 307 BOOL isPendingTransitionFormSubmit = | 309 BOOL isPendingTransitionFormSubmit = |
| 308 PageTransitionCoreTypeIs(trans, ui::PAGE_TRANSITION_FORM_SUBMIT); | 310 PageTransitionCoreTypeIs(trans, ui::PAGE_TRANSITION_FORM_SUBMIT); |
| 309 BOOL isCurrentTransitionFormSubmit = PageTransitionCoreTypeIs( | 311 BOOL isCurrentTransitionFormSubmit = PageTransitionCoreTypeIs( |
| 310 currentItem->GetTransitionType(), ui::PAGE_TRANSITION_FORM_SUBMIT); | 312 currentItem->GetTransitionType(), ui::PAGE_TRANSITION_FORM_SUBMIT); |
| 311 BOOL shouldCreatePendingItem = | 313 BOOL shouldCreatePendingItem = |
| 312 !hasSameURL || | 314 !hasSameURL || |
| 313 (isPendingTransitionFormSubmit && !isCurrentTransitionFormSubmit); | 315 (isPendingTransitionFormSubmit && !isCurrentTransitionFormSubmit); |
| 314 | 316 |
| 317 if (userAgentOverrideOption != | |
| 318 web::NavigationManager::UserAgentOverrideOption::INHERIT) | |
|
kkhorimoto
2017/04/05 23:01:44
I think we should also check whether the override
liaoyuke
2017/04/06 22:24:55
Theoretically, override option should always be di
| |
| 319 shouldCreatePendingItem = YES; | |
| 320 | |
| 315 if (!shouldCreatePendingItem) { | 321 if (!shouldCreatePendingItem) { |
| 316 // Send the notification anyway, to preserve old behavior. It's unknown | 322 // Send the notification anyway, to preserve old behavior. It's unknown |
| 317 // whether anything currently relies on this, but since both this whole | 323 // whether anything currently relies on this, but since both this whole |
| 318 // hack and the content facade will both be going away, it's not worth | 324 // hack and the content facade will both be going away, it's not worth |
| 319 // trying to unwind. | 325 // trying to unwind. |
| 320 if (_navigationManager && _navigationManager->GetFacadeDelegate()) | 326 if (_navigationManager && _navigationManager->GetFacadeDelegate()) |
| 321 _navigationManager->GetFacadeDelegate()->OnNavigationItemPending(); | 327 _navigationManager->GetFacadeDelegate()->OnNavigationItemPending(); |
| 322 return; | 328 return; |
| 323 } | 329 } |
| 324 } | 330 } |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 629 return item; | 635 return item; |
| 630 } | 636 } |
| 631 | 637 |
| 632 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index { | 638 - (BOOL)isRedirectTransitionForItemAtIndex:(size_t)index { |
| 633 DCHECK_LT(index, self.items.size()); | 639 DCHECK_LT(index, self.items.size()); |
| 634 ui::PageTransition transition = self.items[index]->GetTransitionType(); | 640 ui::PageTransition transition = self.items[index]->GetTransitionType(); |
| 635 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; | 641 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; |
| 636 } | 642 } |
| 637 | 643 |
| 638 @end | 644 @end |
| OLD | NEW |