| 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/ui/browser_view_controller.h" | 5 #import "ios/chrome/browser/ui/browser_view_controller.h" |
| 6 | 6 |
| 7 #import <AssetsLibrary/AssetsLibrary.h> | 7 #import <AssetsLibrary/AssetsLibrary.h> |
| 8 #import <MobileCoreServices/MobileCoreServices.h> | 8 #import <MobileCoreServices/MobileCoreServices.h> |
| 9 #import <PassKit/PassKit.h> | 9 #import <PassKit/PassKit.h> |
| 10 #import <Photos/Photos.h> | 10 #import <Photos/Photos.h> |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 #include "ios/chrome/grit/ios_strings.h" | 164 #include "ios/chrome/grit/ios_strings.h" |
| 165 #import "ios/net/request_tracker.h" | 165 #import "ios/net/request_tracker.h" |
| 166 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" | 166 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" |
| 167 #include "ios/public/provider/chrome/browser/ui/app_rating_prompt.h" | 167 #include "ios/public/provider/chrome/browser/ui/app_rating_prompt.h" |
| 168 #include "ios/public/provider/chrome/browser/ui/default_ios_web_view_factory.h" | 168 #include "ios/public/provider/chrome/browser/ui/default_ios_web_view_factory.h" |
| 169 #import "ios/public/provider/chrome/browser/voice/voice_search_bar.h" | 169 #import "ios/public/provider/chrome/browser/voice/voice_search_bar.h" |
| 170 #import "ios/public/provider/chrome/browser/voice/voice_search_bar_owner.h" | 170 #import "ios/public/provider/chrome/browser/voice/voice_search_bar_owner.h" |
| 171 #include "ios/public/provider/chrome/browser/voice/voice_search_controller.h" | 171 #include "ios/public/provider/chrome/browser/voice/voice_search_controller.h" |
| 172 #include "ios/public/provider/chrome/browser/voice/voice_search_controller_deleg
ate.h" | 172 #include "ios/public/provider/chrome/browser/voice/voice_search_controller_deleg
ate.h" |
| 173 #include "ios/public/provider/chrome/browser/voice/voice_search_provider.h" | 173 #include "ios/public/provider/chrome/browser/voice/voice_search_provider.h" |
| 174 #import "ios/shared/chrome/browser/tabs/web_state_list.h" |
| 175 #import "ios/shared/chrome/browser/tabs/web_state_opener.h" |
| 174 #include "ios/web/navigation/navigation_manager_impl.h" | 176 #include "ios/web/navigation/navigation_manager_impl.h" |
| 175 #include "ios/web/public/active_state_manager.h" | 177 #include "ios/web/public/active_state_manager.h" |
| 176 #include "ios/web/public/navigation_item.h" | 178 #include "ios/web/public/navigation_item.h" |
| 177 #import "ios/web/public/navigation_manager.h" | 179 #import "ios/web/public/navigation_manager.h" |
| 178 #include "ios/web/public/referrer_util.h" | 180 #include "ios/web/public/referrer_util.h" |
| 179 #include "ios/web/public/ssl_status.h" | 181 #include "ios/web/public/ssl_status.h" |
| 180 #include "ios/web/public/url_scheme_util.h" | 182 #include "ios/web/public/url_scheme_util.h" |
| 181 #include "ios/web/public/user_agent.h" | 183 #include "ios/web/public/user_agent.h" |
| 182 #include "ios/web/public/web_client.h" | 184 #include "ios/web/public/web_client.h" |
| 183 #import "ios/web/public/web_state/context_menu_params.h" | 185 #import "ios/web/public/web_state/context_menu_params.h" |
| (...skipping 3472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3656 // ending up in the history causign the app to crash at every subsequent | 3658 // ending up in the history causign the app to crash at every subsequent |
| 3657 // restart. | 3659 // restart. |
| 3658 if (url.host() == kChromeUIBrowserCrashHost) { | 3660 if (url.host() == kChromeUIBrowserCrashHost) { |
| 3659 [self induceBrowserCrash]; | 3661 [self induceBrowserCrash]; |
| 3660 // In debug the app can continue working even after the CHECK. Adding a | 3662 // In debug the app can continue working even after the CHECK. Adding a |
| 3661 // return avoids the crash url to be added to the history. | 3663 // return avoids the crash url to be added to the history. |
| 3662 return; | 3664 return; |
| 3663 } | 3665 } |
| 3664 | 3666 |
| 3665 if (url == [_preloadController prerenderedURL]) { | 3667 if (url == [_preloadController prerenderedURL]) { |
| 3668 std::unique_ptr<web::WebState> newWebState = |
| 3669 [_preloadController releasePrerenderContents]; |
| 3670 DCHECK(newWebState); |
| 3671 |
| 3666 Tab* oldTab = [_model currentTab]; | 3672 Tab* oldTab = [_model currentTab]; |
| 3667 Tab* newTab = [_preloadController releasePrerenderContents]; | 3673 Tab* newTab = LegacyTabHelper::GetTabForWebState(newWebState.get()); |
| 3668 DCHECK(oldTab); | 3674 DCHECK(oldTab); |
| 3669 DCHECK(newTab); | 3675 DCHECK(newTab); |
| 3676 |
| 3670 bool canPruneItems = | 3677 bool canPruneItems = |
| 3671 [newTab navigationManager]->CanPruneAllButLastCommittedItem(); | 3678 [newTab navigationManager]->CanPruneAllButLastCommittedItem(); |
| 3679 |
| 3672 if (oldTab && newTab && canPruneItems) { | 3680 if (oldTab && newTab && canPruneItems) { |
| 3673 [oldTab recordStateInHistory]; | 3681 [oldTab recordStateInHistory]; |
| 3674 [newTab navigationManager]->CopyStateFromAndPrune( | 3682 [newTab navigationManager]->CopyStateFromAndPrune( |
| 3675 [oldTab navigationManager]); | 3683 [oldTab navigationManager]); |
| 3676 [[newTab nativeAppNavigationController] | 3684 [[newTab nativeAppNavigationController] |
| 3677 copyStateFrom:[oldTab nativeAppNavigationController]]; | 3685 copyStateFrom:[oldTab nativeAppNavigationController]]; |
| 3678 [_model replaceTab:oldTab withTab:newTab]; | 3686 |
| 3687 [_model webStateList]->ReplaceWebStateAt([_model indexOfTab:oldTab], |
| 3688 std::move(newWebState)); |
| 3679 | 3689 |
| 3680 // Set isPrerenderTab to NO after replacing the tab. This will allow the | 3690 // Set isPrerenderTab to NO after replacing the tab. This will allow the |
| 3681 // BrowserViewController to detect that a pre-rendered tab is switched in, | 3691 // BrowserViewController to detect that a pre-rendered tab is switched in, |
| 3682 // and show the prerendering animation. | 3692 // and show the prerendering animation. |
| 3683 newTab.isPrerenderTab = NO; | 3693 newTab.isPrerenderTab = NO; |
| 3684 | 3694 |
| 3685 [self tabLoadComplete:newTab withSuccess:newTab.loadFinished]; | 3695 [self tabLoadComplete:newTab withSuccess:newTab.loadFinished]; |
| 3686 | |
| 3687 return; | 3696 return; |
| 3688 } | 3697 } |
| 3689 } | 3698 } |
| 3690 | 3699 |
| 3691 GURL urlToLoad = url; | 3700 GURL urlToLoad = url; |
| 3692 if ([_preloadController hasPrefetchedURL:url]) { | 3701 if ([_preloadController hasPrefetchedURL:url]) { |
| 3693 // Prefetched URLs have modified URLs, so load the prefetched version of | 3702 // Prefetched URLs have modified URLs, so load the prefetched version of |
| 3694 // |url| instead of the original |url|. | 3703 // |url| instead of the original |url|. |
| 3695 urlToLoad = [_preloadController prefetchedURL]; | 3704 urlToLoad = [_preloadController prefetchedURL]; |
| 3696 } | 3705 } |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4660 [self updateToolbarControlsAlpha:1.0]; | 4669 [self updateToolbarControlsAlpha:1.0]; |
| 4661 [self updateToolbarBackgroundAlpha:1.0]; | 4670 [self updateToolbarBackgroundAlpha:1.0]; |
| 4662 [_tabStripController view].alpha = 1.0; | 4671 [_tabStripController view].alpha = 1.0; |
| 4663 }; | 4672 }; |
| 4664 | 4673 |
| 4665 // After the transition animation completes, add the tab to the tab model | 4674 // After the transition animation completes, add the tab to the tab model |
| 4666 // (on iPad this triggers the tab strip animation too), then fade out the | 4675 // (on iPad this triggers the tab strip animation too), then fade out the |
| 4667 // transitioning panel and remove it. | 4676 // transitioning panel and remove it. |
| 4668 void (^completion)(BOOL) = ^(BOOL finished) { | 4677 void (^completion)(BOOL) = ^(BOOL finished) { |
| 4669 _contextualSearchMask.alpha = 0; | 4678 _contextualSearchMask.alpha = 0; |
| 4670 Tab* newTab = [tabProvider releaseTab]; | 4679 std::unique_ptr<web::WebState> webState = [tabProvider releaseWebState]; |
| 4671 DCHECK(newTab); | 4680 DCHECK(webState); |
| 4672 DCHECK([newTab navigationManager]); | 4681 DCHECK(webState->GetNavigationManager()); |
| 4673 // Add the new tab to the tab model. | 4682 |
| 4674 [newTab setParentTabModel:_model]; | 4683 Tab* newTab = LegacyTabHelper::GetTabForWebState(webState.get()); |
| 4675 // Insert the new tab one after the current tab. | 4684 WebStateList* webStateList = [_model webStateList]; |
| 4676 Tab* currentTab = [_model currentTab]; | 4685 |
| 4677 NSUInteger index = [_model indexOfTab:currentTab]; | 4686 // Insert the new tab after the current tab. |
| 4678 [_model insertTab:newTab atIndex:index + 1]; | 4687 DCHECK_NE(webStateList->active_index(), WebStateList::kInvalidIndex); |
| 4688 DCHECK_NE(webStateList->active_index(), INT_MAX); |
| 4689 int insertion_index = webStateList->active_index() + 1; |
| 4690 webStateList->InsertWebState(insertion_index, std::move(webState)); |
| 4691 webStateList->SetOpenerOfWebStateAt(insertion_index, |
| 4692 [tabProvider webStateOpener]); |
| 4679 | 4693 |
| 4680 // Set isPrerenderTab to NO after inserting the tab. This will allow the | 4694 // Set isPrerenderTab to NO after inserting the tab. This will allow the |
| 4681 // BrowserViewController to detect that a pre-rendered tab is switched in, | 4695 // BrowserViewController to detect that a pre-rendered tab is switched in, |
| 4682 // and show the prerendering animation. This needs to happen before the | 4696 // and show the prerendering animation. This needs to happen before the |
| 4683 // tab is made the current tab. | 4697 // tab is made the current tab. |
| 4684 // This also enables contextual search (if otherwise applicable) on | 4698 // This also enables contextual search (if otherwise applicable) on |
| 4685 // |newTab|. | 4699 // |newTab|. |
| 4700 |
| 4686 newTab.isPrerenderTab = NO; | 4701 newTab.isPrerenderTab = NO; |
| 4687 [_model setCurrentTab:newTab]; | 4702 [_model setCurrentTab:newTab]; |
| 4688 | 4703 |
| 4689 if (newTab.loadFinished) | 4704 if (newTab.loadFinished) |
| 4690 [self tabLoadComplete:newTab withSuccess:YES]; | 4705 [self tabLoadComplete:newTab withSuccess:YES]; |
| 4691 | 4706 |
| 4692 if (focusInput) { | 4707 if (focusInput) { |
| 4693 [_toolbarController focusOmnibox]; | 4708 [_toolbarController focusOmnibox]; |
| 4694 } | 4709 } |
| 4695 _infoBarContainer->RestoreInfobars(); | 4710 _infoBarContainer->RestoreInfobars(); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5126 | 5141 |
| 5127 - (UIView*)voiceSearchButton { | 5142 - (UIView*)voiceSearchButton { |
| 5128 return _voiceSearchButton; | 5143 return _voiceSearchButton; |
| 5129 } | 5144 } |
| 5130 | 5145 |
| 5131 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5146 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 5132 return [self currentLogoAnimationControllerOwner]; | 5147 return [self currentLogoAnimationControllerOwner]; |
| 5133 } | 5148 } |
| 5134 | 5149 |
| 5135 @end | 5150 @end |
| OLD | NEW |