| 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 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 493 |
| 494 @synthesize browserState = browserState_; | 494 @synthesize browserState = browserState_; |
| 495 @synthesize useGreyImageCache = useGreyImageCache_; | 495 @synthesize useGreyImageCache = useGreyImageCache_; |
| 496 @synthesize isPrerenderTab = isPrerenderTab_; | 496 @synthesize isPrerenderTab = isPrerenderTab_; |
| 497 @synthesize isLinkLoadingPrerenderTab = isLinkLoadingPrerenderTab_; | 497 @synthesize isLinkLoadingPrerenderTab = isLinkLoadingPrerenderTab_; |
| 498 @synthesize isVoiceSearchResultsTab = isVoiceSearchResultsTab_; | 498 @synthesize isVoiceSearchResultsTab = isVoiceSearchResultsTab_; |
| 499 @synthesize delegate = delegate_; | 499 @synthesize delegate = delegate_; |
| 500 @synthesize tabSnapshottingDelegate = tabSnapshottingDelegate_; | 500 @synthesize tabSnapshottingDelegate = tabSnapshottingDelegate_; |
| 501 @synthesize tabHeadersDelegate = tabHeadersDelegate_; | 501 @synthesize tabHeadersDelegate = tabHeadersDelegate_; |
| 502 | 502 |
| 503 - (instancetype)initWithWindowName:(NSString*)windowName | 503 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState |
| 504 opener:(Tab*)opener | 504 opener:(Tab*)opener |
| 505 openedByDOM:(BOOL)openedByDOM | 505 openedByDOM:(BOOL)openedByDOM |
| 506 model:(TabModel*)parentModel | 506 model:(TabModel*)parentModel { |
| 507 browserState:(ios::ChromeBrowserState*)browserState { | |
| 508 std::unique_ptr<web::WebStateImpl> webState( | 507 std::unique_ptr<web::WebStateImpl> webState( |
| 509 new web::WebStateImpl(browserState)); | 508 new web::WebStateImpl(browserState)); |
| 510 webState->GetNavigationManagerImpl().InitializeSession(windowName, | 509 webState->GetNavigationManagerImpl().InitializeSession(openedByDOM); |
| 511 openedByDOM); | |
| 512 if ([opener navigationManager]) { | 510 if ([opener navigationManager]) { |
| 513 web::SerializableUserDataManager* userDataManager = | 511 web::SerializableUserDataManager* userDataManager = |
| 514 web::SerializableUserDataManager::FromWebState(webState.get()); | 512 web::SerializableUserDataManager::FromWebState(webState.get()); |
| 515 userDataManager->AddSerializableData(opener.tabId, kOpenerIDKey); | 513 userDataManager->AddSerializableData(opener.tabId, kOpenerIDKey); |
| 516 userDataManager->AddSerializableData( | 514 userDataManager->AddSerializableData( |
| 517 @([opener navigationManager]->GetLastCommittedItemIndex()), | 515 @([opener navigationManager]->GetLastCommittedItemIndex()), |
| 518 kOpenerNavigationIndexKey); | 516 kOpenerNavigationIndexKey); |
| 519 } | 517 } |
| 520 | 518 |
| 521 return [self initWithWebState:std::move(webState) model:parentModel]; | 519 return [self initWithWebState:std::move(webState) model:parentModel]; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 } | 678 } |
| 681 | 679 |
| 682 + (Tab*)newPreloadingTabWithBrowserState:(ios::ChromeBrowserState*)browserState | 680 + (Tab*)newPreloadingTabWithBrowserState:(ios::ChromeBrowserState*)browserState |
| 683 url:(const GURL&)URL | 681 url:(const GURL&)URL |
| 684 referrer:(const web::Referrer&)referrer | 682 referrer:(const web::Referrer&)referrer |
| 685 transition:(ui::PageTransition)transition | 683 transition:(ui::PageTransition)transition |
| 686 provider:(id<CRWNativeContentProvider>)provider | 684 provider:(id<CRWNativeContentProvider>)provider |
| 687 opener:(Tab*)opener | 685 opener:(Tab*)opener |
| 688 desktopUserAgent:(BOOL)desktopUserAgent | 686 desktopUserAgent:(BOOL)desktopUserAgent |
| 689 configuration:(void (^)(Tab*))configuration { | 687 configuration:(void (^)(Tab*))configuration { |
| 690 Tab* tab = [[[Tab alloc] initWithWindowName:nil | 688 Tab* tab = [[[Tab alloc] initWithBrowserState:browserState |
| 691 opener:opener | 689 opener:opener |
| 692 openedByDOM:NO | 690 openedByDOM:NO |
| 693 model:nil | 691 model:nil] autorelease]; |
| 694 browserState:browserState] autorelease]; | |
| 695 if (desktopUserAgent) | 692 if (desktopUserAgent) |
| 696 [tab enableDesktopUserAgent]; | 693 [tab enableDesktopUserAgent]; |
| 697 [[tab webController] setNativeProvider:provider]; | 694 [[tab webController] setNativeProvider:provider]; |
| 698 [[tab webController] setWebUsageEnabled:YES]; | 695 [[tab webController] setWebUsageEnabled:YES]; |
| 699 | 696 |
| 700 if (configuration) | 697 if (configuration) |
| 701 configuration(tab); | 698 configuration(tab); |
| 702 | 699 |
| 703 web::NavigationManager::WebLoadParams params(URL); | 700 web::NavigationManager::WebLoadParams params(URL); |
| 704 params.transition_type = transition; | 701 params.transition_type = transition; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 return pageTitle.empty() ? nil : base::SysUTF16ToNSString(pageTitle); | 783 return pageTitle.empty() ? nil : base::SysUTF16ToNSString(pageTitle); |
| 787 } | 784 } |
| 788 | 785 |
| 789 - (NSString*)urlDisplayString { | 786 - (NSString*)urlDisplayString { |
| 790 base::string16 urlText = url_formatter::FormatUrl( | 787 base::string16 urlText = url_formatter::FormatUrl( |
| 791 self.url, url_formatter::kFormatUrlOmitNothing, net::UnescapeRule::SPACES, | 788 self.url, url_formatter::kFormatUrlOmitNothing, net::UnescapeRule::SPACES, |
| 792 nullptr, nullptr, nullptr); | 789 nullptr, nullptr, nullptr); |
| 793 return base::SysUTF16ToNSString(urlText); | 790 return base::SysUTF16ToNSString(urlText); |
| 794 } | 791 } |
| 795 | 792 |
| 796 - (NSString*)windowName { | |
| 797 DCHECK([self navigationManager]); | |
| 798 return [self navigationManager]->GetSessionController().windowName; | |
| 799 } | |
| 800 | |
| 801 - (NSString*)tabId { | 793 - (NSString*)tabId { |
| 802 DCHECK(self.webState); | 794 DCHECK(self.webState); |
| 803 web::SerializableUserDataManager* userDataManager = | 795 web::SerializableUserDataManager* userDataManager = |
| 804 web::SerializableUserDataManager::FromWebState(self.webState); | 796 web::SerializableUserDataManager::FromWebState(self.webState); |
| 805 id<NSCoding> tabID = userDataManager->GetValueForSerializationKey(kTabIDKey); | 797 id<NSCoding> tabID = userDataManager->GetValueForSerializationKey(kTabIDKey); |
| 806 if (!tabID) { | 798 if (!tabID) { |
| 807 tabID = [[NSUUID UUID] UUIDString]; | 799 tabID = [[NSUUID UUID] UUIDString]; |
| 808 userDataManager->AddSerializableData(tabID, kTabIDKey); | 800 userDataManager->AddSerializableData(tabID, kTabIDKey); |
| 809 } | 801 } |
| 810 return base::mac::ObjCCastStrict<NSString>(tabID); | 802 return base::mac::ObjCCastStrict<NSString>(tabID); |
| (...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2172 // user chooses to go to incognito, the mobile U-turn page is no longer | 2164 // user chooses to go to incognito, the mobile U-turn page is no longer |
| 2173 // neeeded. The current solution is to go back in history. This has the | 2165 // neeeded. The current solution is to go back in history. This has the |
| 2174 // advantage of keeping the current browsing session and give a good user | 2166 // advantage of keeping the current browsing session and give a good user |
| 2175 // experience when the user comes back from incognito. | 2167 // experience when the user comes back from incognito. |
| 2176 [self goBack]; | 2168 [self goBack]; |
| 2177 | 2169 |
| 2178 if (url.is_valid()) { | 2170 if (url.is_valid()) { |
| 2179 base::scoped_nsobject<OpenUrlCommand> command([[OpenUrlCommand alloc] | 2171 base::scoped_nsobject<OpenUrlCommand> command([[OpenUrlCommand alloc] |
| 2180 initWithURL:url | 2172 initWithURL:url |
| 2181 referrer:web::Referrer() // Strip referrer when switching modes. | 2173 referrer:web::Referrer() // Strip referrer when switching modes. |
| 2182 windowName:nil | |
| 2183 inIncognito:YES | 2174 inIncognito:YES |
| 2184 inBackground:NO | 2175 inBackground:NO |
| 2185 appendTo:kLastTab]); | 2176 appendTo:kLastTab]); |
| 2186 [self.view chromeExecuteCommand:command]; | 2177 [self.view chromeExecuteCommand:command]; |
| 2187 } else { | 2178 } else { |
| 2188 base::scoped_nsobject<GenericChromeCommand> chromeCommand( | 2179 base::scoped_nsobject<GenericChromeCommand> chromeCommand( |
| 2189 [[GenericChromeCommand alloc] initWithTag:IDC_NEW_INCOGNITO_TAB]); | 2180 [[GenericChromeCommand alloc] initWithTag:IDC_NEW_INCOGNITO_TAB]); |
| 2190 [self.view chromeExecuteCommand:chromeCommand]; | 2181 [self.view chromeExecuteCommand:chromeCommand]; |
| 2191 } | 2182 } |
| 2192 } | 2183 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2241 | 2232 |
| 2242 - (TabModel*)parentTabModel { | 2233 - (TabModel*)parentTabModel { |
| 2243 return parentTabModel_; | 2234 return parentTabModel_; |
| 2244 } | 2235 } |
| 2245 | 2236 |
| 2246 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2237 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
| 2247 return inputAccessoryViewController_.get(); | 2238 return inputAccessoryViewController_.get(); |
| 2248 } | 2239 } |
| 2249 | 2240 |
| 2250 @end | 2241 @end |
| OLD | NEW |