| 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/chrome/browser/tabs/tab.h" | 5 #import "ios/chrome/browser/tabs/tab.h" |
| 6 | 6 |
| 7 #import <CoreLocation/CoreLocation.h> | 7 #import <CoreLocation/CoreLocation.h> |
| 8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 DCHECK(historyService); | 1035 DCHECK(historyService); |
| 1036 historyService->SetPageTitle(self.url, base::SysNSStringToUTF16(title)); | 1036 historyService->SetPageTitle(self.url, base::SysNSStringToUTF16(title)); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 - (void)addCurrentEntryToHistoryDB { | 1039 - (void)addCurrentEntryToHistoryDB { |
| 1040 DCHECK(self.currentSessionEntry); | 1040 DCHECK(self.currentSessionEntry); |
| 1041 // If incognito, don't update history. | 1041 // If incognito, don't update history. |
| 1042 if (browserState_->IsOffTheRecord()) | 1042 if (browserState_->IsOffTheRecord()) |
| 1043 return; | 1043 return; |
| 1044 | 1044 |
| 1045 CRWSessionEntry* sessionEntry = self.currentSessionEntry; | |
| 1046 web::NavigationItem* item = [self navigationManager]->GetVisibleItem(); | 1045 web::NavigationItem* item = [self navigationManager]->GetVisibleItem(); |
| 1047 | 1046 |
| 1048 // Do not update the history db for back/forward navigations. | 1047 // Do not update the history db for back/forward navigations. |
| 1049 // TODO(crbug.com/661667): We do not currently tag the entry with a | 1048 // TODO(crbug.com/661667): We do not currently tag the entry with a |
| 1050 // FORWARD_BACK transition. Fix. | 1049 // FORWARD_BACK transition. Fix. |
| 1051 if (item->GetTransitionType() & ui::PAGE_TRANSITION_FORWARD_BACK) | 1050 if (item->GetTransitionType() & ui::PAGE_TRANSITION_FORWARD_BACK) |
| 1052 return; | 1051 return; |
| 1053 | 1052 |
| 1054 history::HistoryService* historyService = | 1053 history::HistoryService* historyService = |
| 1055 ios::HistoryServiceFactory::GetForBrowserState( | 1054 ios::HistoryServiceFactory::GetForBrowserState( |
| 1056 browserState_, ServiceAccessType::IMPLICIT_ACCESS); | 1055 browserState_, ServiceAccessType::IMPLICIT_ACCESS); |
| 1057 DCHECK(historyService); | 1056 DCHECK(historyService); |
| 1058 | 1057 |
| 1059 const GURL url(item->GetURL()); | 1058 const GURL url(item->GetURL()); |
| 1060 const web::Referrer& referrer = item->GetReferrer(); | 1059 const web::Referrer& referrer = item->GetReferrer(); |
| 1061 | 1060 |
| 1062 // Do not update the history db for data: urls. This diverges from upstream, | 1061 // Do not update the history db for data: urls. This diverges from upstream, |
| 1063 // but prevents us from dumping huge view-source urls into the history | 1062 // but prevents us from dumping huge view-source urls into the history |
| 1064 // database. Since view-source is only activated in Debug builds, this check | 1063 // database. Since view-source is only activated in Debug builds, this check |
| 1065 // can be Debug-only as well. | 1064 // can be Debug-only as well. |
| 1066 #ifndef NDEBUG | 1065 #ifndef NDEBUG |
| 1067 if (url.scheme() == url::kDataScheme) | 1066 if (url.scheme() == url::kDataScheme) |
| 1068 return; | 1067 return; |
| 1069 #endif | 1068 #endif |
| 1070 | 1069 |
| 1071 history::RedirectList redirects; | 1070 history::RedirectList redirects; |
| 1072 if (item->GetURL() != sessionEntry.originalUrl) { | 1071 GURL originalURL = item->GetOriginalRequestURL(); |
| 1072 if (item->GetURL() != originalURL) { |
| 1073 // Simulate a valid redirect chain in case of URL that have been modified | 1073 // Simulate a valid redirect chain in case of URL that have been modified |
| 1074 // in |CRWWebController finishHistoryNavigationFromEntry:|. | 1074 // in |CRWWebController finishHistoryNavigationFromEntry:|. |
| 1075 const std::string& urlSpec = item->GetURL().spec(); | 1075 const std::string& urlSpec = item->GetURL().spec(); |
| 1076 size_t urlSpecLength = urlSpec.size(); | 1076 size_t urlSpecLength = urlSpec.size(); |
| 1077 if (item->GetTransitionType() & ui::PAGE_TRANSITION_CLIENT_REDIRECT || | 1077 if (item->GetTransitionType() & ui::PAGE_TRANSITION_CLIENT_REDIRECT || |
| 1078 (urlSpecLength && (urlSpec.at(urlSpecLength - 1) == '#') && | 1078 (urlSpecLength && (urlSpec.at(urlSpecLength - 1) == '#') && |
| 1079 !urlSpec.compare(0, urlSpecLength - 1, | 1079 !urlSpec.compare(0, urlSpecLength - 1, originalURL.spec()))) { |
| 1080 sessionEntry.originalUrl.spec()))) { | |
| 1081 redirects.push_back(referrer.url); | 1080 redirects.push_back(referrer.url); |
| 1082 } | 1081 } |
| 1083 // TODO(crbug.com/661670): the redirect chain is not constructed the same | 1082 // TODO(crbug.com/661670): the redirect chain is not constructed the same |
| 1084 // way as upstream so this part needs to be revised. | 1083 // way as upstream so this part needs to be revised. |
| 1085 redirects.push_back(sessionEntry.originalUrl); | 1084 redirects.push_back(originalURL); |
| 1086 redirects.push_back(url); | 1085 redirects.push_back(url); |
| 1087 } | 1086 } |
| 1088 | 1087 |
| 1089 DCHECK(item->GetTimestamp().ToInternalValue() > 0); | 1088 DCHECK(item->GetTimestamp().ToInternalValue() > 0); |
| 1090 if ([self isPrerenderTab]) { | 1089 if ([self isPrerenderTab]) { |
| 1091 // Clicks on content suggestions on the NTP should not contribute to the | 1090 // Clicks on content suggestions on the NTP should not contribute to the |
| 1092 // Most Visited tiles in the NTP. | 1091 // Most Visited tiles in the NTP. |
| 1093 const bool consider_for_ntp_most_visited = | 1092 const bool consider_for_ntp_most_visited = |
| 1094 referrer.url != GURL(kChromeContentSuggestionsReferrer); | 1093 referrer.url != GURL(kChromeContentSuggestionsReferrer); |
| 1095 | 1094 |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 ui::PageTransition transition = | 1598 ui::PageTransition transition = |
| 1600 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT); | 1599 ui::PageTransitionFromInt(ui::PAGE_TRANSITION_FORM_SUBMIT); |
| 1601 DCHECK([self navigationManager]); | 1600 DCHECK([self navigationManager]); |
| 1602 CRWSessionController* sessionController = | 1601 CRWSessionController* sessionController = |
| 1603 [self navigationManager]->GetSessionController(); | 1602 [self navigationManager]->GetSessionController(); |
| 1604 CRWSessionEntry* lastUserEntry = [sessionController lastUserEntry]; | 1603 CRWSessionEntry* lastUserEntry = [sessionController lastUserEntry]; |
| 1605 if (!lastUserEntry) | 1604 if (!lastUserEntry) |
| 1606 return; | 1605 return; |
| 1607 | 1606 |
| 1608 // |originalUrl| will be empty if a page was open by DOM. | 1607 // |originalUrl| will be empty if a page was open by DOM. |
| 1609 GURL reloadURL(lastUserEntry.originalUrl); | 1608 GURL reloadURL(lastUserEntry.navigationItem->GetOriginalRequestURL()); |
| 1610 if (reloadURL.is_empty()) { | 1609 if (reloadURL.is_empty()) { |
| 1611 DCHECK(sessionController.openedByDOM); | 1610 DCHECK(sessionController.openedByDOM); |
| 1612 reloadURL = [lastUserEntry navigationItem]->GetVirtualURL(); | 1611 reloadURL = [lastUserEntry navigationItem]->GetVirtualURL(); |
| 1613 } | 1612 } |
| 1614 | 1613 |
| 1615 web::NavigationManager::WebLoadParams params(reloadURL); | 1614 web::NavigationManager::WebLoadParams params(reloadURL); |
| 1616 params.referrer = lastUserEntry.navigationItem->GetReferrer(); | 1615 params.referrer = lastUserEntry.navigationItem->GetReferrer(); |
| 1617 params.transition_type = transition; | 1616 params.transition_type = transition; |
| 1618 if (self.navigationManager) | 1617 if (self.navigationManager) |
| 1619 self.navigationManager->LoadURLWithParams(params); | 1618 self.navigationManager->LoadURLWithParams(params); |
| (...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 | 2333 |
| 2335 - (TabModel*)parentTabModel { | 2334 - (TabModel*)parentTabModel { |
| 2336 return parentTabModel_; | 2335 return parentTabModel_; |
| 2337 } | 2336 } |
| 2338 | 2337 |
| 2339 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2338 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2340 return inputAccessoryViewController_.get(); | 2339 return inputAccessoryViewController_.get(); |
| 2341 } | 2340 } |
| 2342 | 2341 |
| 2343 @end | 2342 @end |
| OLD | NEW |