| 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 3463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3647 // ending up in the history causign the app to crash at every subsequent | 3649 // ending up in the history causign the app to crash at every subsequent |
| 3648 // restart. | 3650 // restart. |
| 3649 if (url.host() == kChromeUIBrowserCrashHost) { | 3651 if (url.host() == kChromeUIBrowserCrashHost) { |
| 3650 [self induceBrowserCrash]; | 3652 [self induceBrowserCrash]; |
| 3651 // In debug the app can continue working even after the CHECK. Adding a | 3653 // In debug the app can continue working even after the CHECK. Adding a |
| 3652 // return avoids the crash url to be added to the history. | 3654 // return avoids the crash url to be added to the history. |
| 3653 return; | 3655 return; |
| 3654 } | 3656 } |
| 3655 | 3657 |
| 3656 if (url == [_preloadController prerenderedURL]) { | 3658 if (url == [_preloadController prerenderedURL]) { |
| 3659 std::unique_ptr<web::WebState> newWebState = |
| 3660 [_preloadController releasePrerenderContents]; |
| 3661 DCHECK(newWebState); |
| 3662 |
| 3657 Tab* oldTab = [_model currentTab]; | 3663 Tab* oldTab = [_model currentTab]; |
| 3658 Tab* newTab = [_preloadController releasePrerenderContents]; | 3664 Tab* newTab = LegacyTabHelper::GetTabForWebState(newWebState.get()); |
| 3659 DCHECK(oldTab); | 3665 DCHECK(oldTab); |
| 3660 DCHECK(newTab); | 3666 DCHECK(newTab); |
| 3667 |
| 3661 bool canPruneItems = | 3668 bool canPruneItems = |
| 3662 [newTab navigationManager]->CanPruneAllButLastCommittedItem(); | 3669 [newTab navigationManager]->CanPruneAllButLastCommittedItem(); |
| 3670 |
| 3663 if (oldTab && newTab && canPruneItems) { | 3671 if (oldTab && newTab && canPruneItems) { |
| 3664 [oldTab recordStateInHistory]; | 3672 [oldTab recordStateInHistory]; |
| 3665 [newTab navigationManager]->CopyStateFromAndPrune( | 3673 [newTab navigationManager]->CopyStateFromAndPrune( |
| 3666 [oldTab navigationManager]); | 3674 [oldTab navigationManager]); |
| 3667 [[newTab nativeAppNavigationController] | 3675 [[newTab nativeAppNavigationController] |
| 3668 copyStateFrom:[oldTab nativeAppNavigationController]]; | 3676 copyStateFrom:[oldTab nativeAppNavigationController]]; |
| 3669 [_model replaceTab:oldTab withTab:newTab]; | 3677 |
| 3678 [_model webStateList]->ReplaceWebStateAt([_model indexOfTab:oldTab], |
| 3679 std::move(newWebState)); |
| 3670 | 3680 |
| 3671 // Set isPrerenderTab to NO after replacing the tab. This will allow the | 3681 // Set isPrerenderTab to NO after replacing the tab. This will allow the |
| 3672 // BrowserViewController to detect that a pre-rendered tab is switched in, | 3682 // BrowserViewController to detect that a pre-rendered tab is switched in, |
| 3673 // and show the prerendering animation. | 3683 // and show the prerendering animation. |
| 3674 newTab.isPrerenderTab = NO; | 3684 newTab.isPrerenderTab = NO; |
| 3675 | 3685 |
| 3676 [self tabLoadComplete:newTab withSuccess:newTab.loadFinished]; | 3686 [self tabLoadComplete:newTab withSuccess:newTab.loadFinished]; |
| 3677 | |
| 3678 return; | 3687 return; |
| 3679 } | 3688 } |
| 3680 } | 3689 } |
| 3681 | 3690 |
| 3682 GURL urlToLoad = url; | 3691 GURL urlToLoad = url; |
| 3683 if ([_preloadController hasPrefetchedURL:url]) { | 3692 if ([_preloadController hasPrefetchedURL:url]) { |
| 3684 // Prefetched URLs have modified URLs, so load the prefetched version of | 3693 // Prefetched URLs have modified URLs, so load the prefetched version of |
| 3685 // |url| instead of the original |url|. | 3694 // |url| instead of the original |url|. |
| 3686 urlToLoad = [_preloadController prefetchedURL]; | 3695 urlToLoad = [_preloadController prefetchedURL]; |
| 3687 } | 3696 } |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4651 [self updateToolbarControlsAlpha:1.0]; | 4660 [self updateToolbarControlsAlpha:1.0]; |
| 4652 [self updateToolbarBackgroundAlpha:1.0]; | 4661 [self updateToolbarBackgroundAlpha:1.0]; |
| 4653 [_tabStripController view].alpha = 1.0; | 4662 [_tabStripController view].alpha = 1.0; |
| 4654 }; | 4663 }; |
| 4655 | 4664 |
| 4656 // After the transition animation completes, add the tab to the tab model | 4665 // After the transition animation completes, add the tab to the tab model |
| 4657 // (on iPad this triggers the tab strip animation too), then fade out the | 4666 // (on iPad this triggers the tab strip animation too), then fade out the |
| 4658 // transitioning panel and remove it. | 4667 // transitioning panel and remove it. |
| 4659 void (^completion)(BOOL) = ^(BOOL finished) { | 4668 void (^completion)(BOOL) = ^(BOOL finished) { |
| 4660 _contextualSearchMask.alpha = 0; | 4669 _contextualSearchMask.alpha = 0; |
| 4661 Tab* newTab = [tabProvider releaseTab]; | 4670 std::unique_ptr<web::WebState> webState = [tabProvider releaseWebState]; |
| 4662 DCHECK(newTab); | 4671 DCHECK(webState); |
| 4663 DCHECK([newTab navigationManager]); | 4672 DCHECK(webState->GetNavigationManager()); |
| 4664 // Add the new tab to the tab model. | 4673 |
| 4665 [newTab setParentTabModel:_model]; | 4674 Tab* newTab = LegacyTabHelper::GetTabForWebState(webState.get()); |
| 4666 // Insert the new tab one after the current tab. | 4675 WebStateList* webStateList = [_model webStateList]; |
| 4667 Tab* currentTab = [_model currentTab]; | 4676 |
| 4668 NSUInteger index = [_model indexOfTab:currentTab]; | 4677 // Insert the new tab after the current tab. |
| 4669 [_model insertTab:newTab atIndex:index + 1]; | 4678 DCHECK_NE(webStateList->active_index(), WebStateList::kInvalidIndex); |
| 4679 DCHECK_NE(webStateList->active_index(), INT_MAX); |
| 4680 int insertion_index = webStateList->active_index() + 1; |
| 4681 webStateList->InsertWebState(insertion_index, std::move(webState)); |
| 4682 webStateList->SetOpenerOfWebStateAt(insertion_index, |
| 4683 [tabProvider webStateOpener]); |
| 4670 | 4684 |
| 4671 // Set isPrerenderTab to NO after inserting the tab. This will allow the | 4685 // Set isPrerenderTab to NO after inserting the tab. This will allow the |
| 4672 // BrowserViewController to detect that a pre-rendered tab is switched in, | 4686 // BrowserViewController to detect that a pre-rendered tab is switched in, |
| 4673 // and show the prerendering animation. This needs to happen before the | 4687 // and show the prerendering animation. This needs to happen before the |
| 4674 // tab is made the current tab. | 4688 // tab is made the current tab. |
| 4675 // This also enables contextual search (if otherwise applicable) on | 4689 // This also enables contextual search (if otherwise applicable) on |
| 4676 // |newTab|. | 4690 // |newTab|. |
| 4691 |
| 4677 newTab.isPrerenderTab = NO; | 4692 newTab.isPrerenderTab = NO; |
| 4678 [_model setCurrentTab:newTab]; | 4693 [_model setCurrentTab:newTab]; |
| 4679 | 4694 |
| 4680 if (newTab.loadFinished) | 4695 if (newTab.loadFinished) |
| 4681 [self tabLoadComplete:newTab withSuccess:YES]; | 4696 [self tabLoadComplete:newTab withSuccess:YES]; |
| 4682 | 4697 |
| 4683 if (focusInput) { | 4698 if (focusInput) { |
| 4684 [_toolbarController focusOmnibox]; | 4699 [_toolbarController focusOmnibox]; |
| 4685 } | 4700 } |
| 4686 _infoBarContainer->RestoreInfobars(); | 4701 _infoBarContainer->RestoreInfobars(); |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5117 | 5132 |
| 5118 - (UIView*)voiceSearchButton { | 5133 - (UIView*)voiceSearchButton { |
| 5119 return _voiceSearchButton; | 5134 return _voiceSearchButton; |
| 5120 } | 5135 } |
| 5121 | 5136 |
| 5122 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5137 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 5123 return [self currentLogoAnimationControllerOwner]; | 5138 return [self currentLogoAnimationControllerOwner]; |
| 5124 } | 5139 } |
| 5125 | 5140 |
| 5126 @end | 5141 @end |
| OLD | NEW |