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/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 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1562 _loadPhase = web::LOAD_REQUESTED; | 1562 _loadPhase = web::LOAD_REQUESTED; |
| 1563 _lastRegisteredRequestURL = requestURL; | 1563 _lastRegisteredRequestURL = requestURL; |
| 1564 | 1564 |
| 1565 if (!(transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK)) { | 1565 if (!(transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK)) { |
| 1566 // Record state of outgoing page. | 1566 // Record state of outgoing page. |
| 1567 [self recordStateInHistory]; | 1567 [self recordStateInHistory]; |
| 1568 } | 1568 } |
| 1569 | 1569 |
| 1570 [_delegate webWillAddPendingURL:requestURL transition:transition]; | 1570 [_delegate webWillAddPendingURL:requestURL transition:transition]; |
| 1571 // Add or update pending url. | 1571 // Add or update pending url. |
| 1572 if (_webStateImpl->GetNavigationManagerImpl().GetPendingItem()) { | 1572 if (_webStateImpl->GetNavigationManagerImpl().GetPendingItem()) { |
|
Eugene But (OOO till 7-30)
2017/02/16 02:20:48
nit: Do you want to create a local variable for Na
liaoyuke
2017/02/16 22:04:29
Acknowledged.
| |
| 1573 // Update the existing pending entry. | 1573 // Update the existing pending entry. |
| 1574 // Typically on PAGE_TRANSITION_CLIENT_REDIRECT. | 1574 // Typically on PAGE_TRANSITION_CLIENT_REDIRECT. |
| 1575 [[self sessionController] updatePendingItem:requestURL]; | 1575 [[self sessionController] updatePendingItem:requestURL]; |
| 1576 } else { | 1576 } else { |
| 1577 // A new session history entry needs to be created. | 1577 // A new session history entry needs to be created. |
| 1578 [[self sessionController] addPendingItem:requestURL | 1578 _webStateImpl->GetNavigationManagerImpl().AddRendererInitiatedPendingItem( |
| 1579 referrer:referrer | 1579 requestURL, referrer, transition); |
| 1580 transition:transition | |
| 1581 rendererInitiated:YES]; | |
| 1582 } | 1580 } |
| 1583 _webStateImpl->SetIsLoading(true); | 1581 _webStateImpl->SetIsLoading(true); |
| 1584 _webStateImpl->OnProvisionalNavigationStarted(requestURL); | 1582 _webStateImpl->OnProvisionalNavigationStarted(requestURL); |
| 1585 } | 1583 } |
| 1586 | 1584 |
| 1587 - (void)updateHTML5HistoryState { | 1585 - (void)updateHTML5HistoryState { |
| 1588 web::NavigationItemImpl* currentItem = | 1586 web::NavigationItemImpl* currentItem = |
| 1589 static_cast<web::NavigationItemImpl*>([self currentNavItem]); | 1587 static_cast<web::NavigationItemImpl*>([self currentNavItem]); |
| 1590 if (!currentItem) | 1588 if (!currentItem) |
| 1591 return; | 1589 return; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1905 } else { | 1903 } else { |
| 1906 // Clear transient view before making any changes to history and navigation | 1904 // Clear transient view before making any changes to history and navigation |
| 1907 // manager. TODO(stuartmorgan): Drive Transient Item clearing from | 1905 // manager. TODO(stuartmorgan): Drive Transient Item clearing from |
| 1908 // navigation system, rather than from WebController. | 1906 // navigation system, rather than from WebController. |
| 1909 [self clearTransientContentView]; | 1907 [self clearTransientContentView]; |
| 1910 | 1908 |
| 1911 // TODO(stuartmorgan): Why doesn't recordStateInHistory get called for | 1909 // TODO(stuartmorgan): Why doesn't recordStateInHistory get called for |
| 1912 // forward/back transitions? | 1910 // forward/back transitions? |
| 1913 [self recordStateInHistory]; | 1911 [self recordStateInHistory]; |
| 1914 | 1912 |
| 1915 CRWSessionController* history = | |
| 1916 _webStateImpl->GetNavigationManagerImpl().GetSessionController(); | |
| 1917 if (!self.currentSessionEntry) | 1913 if (!self.currentSessionEntry) |
| 1918 initialNavigation = YES; | 1914 initialNavigation = YES; |
| 1919 [history addPendingItem:navUrl | 1915 |
| 1920 referrer:params.referrer | 1916 if (params.is_renderer_initiated) { |
| 1921 transition:transition | 1917 _webStateImpl->GetNavigationManagerImpl().AddRendererInitiatedPendingItem( |
|
Eugene But (OOO till 7-30)
2017/02/16 02:20:48
Having 2 APIs for adding pendingItem looks error p
liaoyuke
2017/02/16 22:04:29
I like this idea, but I changed the class name to
Eugene But (OOO till 7-30)
2017/02/17 00:00:23
How about NavigationInitiationType ?
Eugene But (OOO till 7-30)
2017/02/17 01:21:11
Please address this comment.
liaoyuke
2017/02/17 01:58:45
Agreed, NavigationInitiationType is more informati
| |
| 1922 rendererInitiated:params.is_renderer_initiated]; | 1918 navUrl, params.referrer, transition); |
| 1919 } else { | |
| 1920 _webStateImpl->GetNavigationManagerImpl().AddUserInitiatedPendingItem( | |
| 1921 navUrl, params.referrer, transition); | |
| 1922 } | |
| 1923 | |
| 1923 web::NavigationItemImpl* addedItem = | 1924 web::NavigationItemImpl* addedItem = |
| 1924 [self currentSessionEntry].navigationItemImpl; | 1925 [self currentSessionEntry].navigationItemImpl; |
| 1925 DCHECK(addedItem); | 1926 DCHECK(addedItem); |
| 1926 if (params.extra_headers) | 1927 if (params.extra_headers) |
| 1927 addedItem->AddHttpRequestHeaders(params.extra_headers); | 1928 addedItem->AddHttpRequestHeaders(params.extra_headers); |
| 1928 if (params.post_data) { | 1929 if (params.post_data) { |
| 1929 DCHECK([addedItem->GetHttpRequestHeaders() objectForKey:@"Content-Type"]) | 1930 DCHECK([addedItem->GetHttpRequestHeaders() objectForKey:@"Content-Type"]) |
| 1930 << "Post data should have an associated content type"; | 1931 << "Post data should have an associated content type"; |
| 1931 addedItem->SetPostData(params.post_data); | 1932 addedItem->SetPostData(params.post_data); |
| 1932 addedItem->SetShouldSkipRepostFormConfirmation(true); | 1933 addedItem->SetShouldSkipRepostFormConfirmation(true); |
| (...skipping 3382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5315 - (void)simulateLoadRequestWithURL:(const GURL&)URL { | 5316 - (void)simulateLoadRequestWithURL:(const GURL&)URL { |
| 5316 _lastRegisteredRequestURL = URL; | 5317 _lastRegisteredRequestURL = URL; |
| 5317 _loadPhase = web::LOAD_REQUESTED; | 5318 _loadPhase = web::LOAD_REQUESTED; |
| 5318 } | 5319 } |
| 5319 | 5320 |
| 5320 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { | 5321 - (NSString*)refererFromNavigationAction:(WKNavigationAction*)action { |
| 5321 return [action.request valueForHTTPHeaderField:@"Referer"]; | 5322 return [action.request valueForHTTPHeaderField:@"Referer"]; |
| 5322 } | 5323 } |
| 5323 | 5324 |
| 5324 @end | 5325 @end |
| OLD | NEW |