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 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1911 FindInPageController* controller = GetFindInPageController(tab); | 1911 FindInPageController* controller = GetFindInPageController(tab); |
1912 if (controller.findInPageModel.enabled) { | 1912 if (controller.findInPageModel.enabled) { |
1913 [self showFindBarWithAnimation:NO | 1913 [self showFindBarWithAnimation:NO |
1914 selectText:YES | 1914 selectText:YES |
1915 shouldFocus:[_findBarController isFocused]]; | 1915 shouldFocus:[_findBarController isFocused]]; |
1916 } | 1916 } |
1917 | 1917 |
1918 // Hide the toolbar if displaying phone NTP. | 1918 // Hide the toolbar if displaying phone NTP. |
1919 if (!IsIPadIdiom()) { | 1919 if (!IsIPadIdiom()) { |
1920 CRWSessionEntry* entry = | 1920 CRWSessionEntry* entry = |
1921 [[tab navigationManager]->GetSessionController() currentEntry]; | 1921 [[tab navigationManagerImpl]->GetSessionController() currentEntry]; |
1922 BOOL hideToolbar = NO; | 1922 BOOL hideToolbar = NO; |
1923 if (entry) { | 1923 if (entry) { |
1924 GURL url = [entry navigationItem]->GetURL(); | 1924 GURL url = [entry navigationItem]->GetURL(); |
1925 BOOL isNTP = url.GetOrigin() == GURL(kChromeUINewTabURL); | 1925 BOOL isNTP = url.GetOrigin() == GURL(kChromeUINewTabURL); |
1926 hideToolbar = isNTP && !_isOffTheRecord && | 1926 hideToolbar = isNTP && !_isOffTheRecord && |
1927 ![_toolbarController isOmniboxFirstResponder] && | 1927 ![_toolbarController isOmniboxFirstResponder] && |
1928 ![_toolbarController showingOmniboxPopup]; | 1928 ![_toolbarController showingOmniboxPopup]; |
1929 } | 1929 } |
1930 [[_toolbarController view] setHidden:hideToolbar]; | 1930 [[_toolbarController view] setHidden:hideToolbar]; |
1931 } | 1931 } |
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3357 - (void)showTabHistoryPopupForBackwardHistory { | 3357 - (void)showTabHistoryPopupForBackwardHistory { |
3358 DCHECK(self.visible || self.dismissingModal); | 3358 DCHECK(self.visible || self.dismissingModal); |
3359 | 3359 |
3360 // Dismiss the omnibox (if open). | 3360 // Dismiss the omnibox (if open). |
3361 [_toolbarController cancelOmniboxEdit]; | 3361 [_toolbarController cancelOmniboxEdit]; |
3362 // Dismiss the soft keyboard (if open). | 3362 // Dismiss the soft keyboard (if open). |
3363 Tab* tab = [_model currentTab]; | 3363 Tab* tab = [_model currentTab]; |
3364 [tab.webController dismissKeyboard]; | 3364 [tab.webController dismissKeyboard]; |
3365 | 3365 |
3366 DCHECK([tab navigationManager]); | 3366 DCHECK([tab navigationManager]); |
3367 CRWSessionController* sc = [tab navigationManager]->GetSessionController(); | 3367 CRWSessionController* sc = |
| 3368 [tab navigationManagerImpl]->GetSessionController(); |
3368 [_toolbarController showTabHistoryPopupInView:[self view] | 3369 [_toolbarController showTabHistoryPopupInView:[self view] |
3369 withSessionEntries:[sc backwardEntries] | 3370 withSessionEntries:[sc backwardEntries] |
3370 forBackHistory:YES]; | 3371 forBackHistory:YES]; |
3371 } | 3372 } |
3372 | 3373 |
3373 - (void)showTabHistoryPopupForForwardHistory { | 3374 - (void)showTabHistoryPopupForForwardHistory { |
3374 DCHECK(self.visible || self.dismissingModal); | 3375 DCHECK(self.visible || self.dismissingModal); |
3375 | 3376 |
3376 // Dismiss the omnibox (if open). | 3377 // Dismiss the omnibox (if open). |
3377 [_toolbarController cancelOmniboxEdit]; | 3378 [_toolbarController cancelOmniboxEdit]; |
3378 // Dismiss the soft keyboard (if open). | 3379 // Dismiss the soft keyboard (if open). |
3379 Tab* tab = [_model currentTab]; | 3380 Tab* tab = [_model currentTab]; |
3380 [tab.webController dismissKeyboard]; | 3381 [tab.webController dismissKeyboard]; |
3381 | 3382 |
3382 DCHECK([tab navigationManager]); | 3383 DCHECK([tab navigationManager]); |
3383 CRWSessionController* sc = [tab navigationManager]->GetSessionController(); | 3384 CRWSessionController* sc = |
| 3385 [tab navigationManagerImpl]->GetSessionController(); |
3384 [_toolbarController showTabHistoryPopupInView:[self view] | 3386 [_toolbarController showTabHistoryPopupInView:[self view] |
3385 withSessionEntries:[sc forwardEntries] | 3387 withSessionEntries:[sc forwardEntries] |
3386 forBackHistory:NO]; | 3388 forBackHistory:NO]; |
3387 } | 3389 } |
3388 | 3390 |
3389 - (void)navigateToSelectedEntry:(id)sender { | 3391 - (void)navigateToSelectedEntry:(id)sender { |
3390 DCHECK([sender isKindOfClass:[TabHistoryCell class]]); | 3392 DCHECK([sender isKindOfClass:[TabHistoryCell class]]); |
3391 TabHistoryCell* selectedCell = (TabHistoryCell*)sender; | 3393 TabHistoryCell* selectedCell = (TabHistoryCell*)sender; |
3392 [[_model currentTab] goToItem:selectedCell.entry.navigationItem]; | 3394 [[_model currentTab] goToItem:selectedCell.entry.navigationItem]; |
3393 [_toolbarController dismissTabHistoryPopup]; | 3395 [_toolbarController dismissTabHistoryPopup]; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3570 | 3572 |
3571 if (url == [_preloadController prerenderedURL]) { | 3573 if (url == [_preloadController prerenderedURL]) { |
3572 Tab* oldTab = [_model currentTab]; | 3574 Tab* oldTab = [_model currentTab]; |
3573 Tab* newTab = [_preloadController releasePrerenderContents]; | 3575 Tab* newTab = [_preloadController releasePrerenderContents]; |
3574 DCHECK(oldTab); | 3576 DCHECK(oldTab); |
3575 DCHECK(newTab); | 3577 DCHECK(newTab); |
3576 if (oldTab && newTab) { | 3578 if (oldTab && newTab) { |
3577 [oldTab recordStateInHistory]; | 3579 [oldTab recordStateInHistory]; |
3578 DCHECK([newTab navigationManager]); | 3580 DCHECK([newTab navigationManager]); |
3579 CRWSessionController* newHistory = | 3581 CRWSessionController* newHistory = |
3580 [newTab navigationManager]->GetSessionController(); | 3582 [newTab navigationManagerImpl]->GetSessionController(); |
3581 DCHECK([oldTab navigationManager]); | 3583 DCHECK([oldTab navigationManager]); |
3582 CRWSessionController* oldHistory = | 3584 CRWSessionController* oldHistory = |
3583 [oldTab navigationManager]->GetSessionController(); | 3585 [oldTab navigationManagerImpl]->GetSessionController(); |
3584 [newHistory insertStateFromSessionController:oldHistory]; | 3586 [newHistory insertStateFromSessionController:oldHistory]; |
3585 [[newTab nativeAppNavigationController] | 3587 [[newTab nativeAppNavigationController] |
3586 copyStateFrom:[oldTab nativeAppNavigationController]]; | 3588 copyStateFrom:[oldTab nativeAppNavigationController]]; |
3587 [_model replaceTab:oldTab withTab:newTab]; | 3589 [_model replaceTab:oldTab withTab:newTab]; |
3588 | 3590 |
3589 // Set isPrerenderTab to NO after replacing the tab. This will allow the | 3591 // Set isPrerenderTab to NO after replacing the tab. This will allow the |
3590 // BrowserViewController to detect that a pre-rendered tab is switched in, | 3592 // BrowserViewController to detect that a pre-rendered tab is switched in, |
3591 // and show the prerendering animation. | 3593 // and show the prerendering animation. |
3592 newTab.isPrerenderTab = NO; | 3594 newTab.isPrerenderTab = NO; |
3593 | 3595 |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4799 #pragma mark - PreloadControllerDelegate methods | 4801 #pragma mark - PreloadControllerDelegate methods |
4800 | 4802 |
4801 - (BOOL)shouldUseDesktopUserAgent { | 4803 - (BOOL)shouldUseDesktopUserAgent { |
4802 return [_model currentTab].usesDesktopUserAgent; | 4804 return [_model currentTab].usesDesktopUserAgent; |
4803 } | 4805 } |
4804 | 4806 |
4805 - (CRWSessionEntry*)currentSessionEntry { | 4807 - (CRWSessionEntry*)currentSessionEntry { |
4806 Tab* tab = [_model currentTab]; | 4808 Tab* tab = [_model currentTab]; |
4807 if (![tab navigationManager]) | 4809 if (![tab navigationManager]) |
4808 return nil; | 4810 return nil; |
4809 return [[tab navigationManager]->GetSessionController() currentEntry]; | 4811 return [[tab navigationManagerImpl]->GetSessionController() currentEntry]; |
4810 } | 4812 } |
4811 | 4813 |
4812 #pragma mark - BookmarkBridgeMethods | 4814 #pragma mark - BookmarkBridgeMethods |
4813 | 4815 |
4814 // If an added or removed bookmark is the same as the current url, update the | 4816 // If an added or removed bookmark is the same as the current url, update the |
4815 // toolbar so the star highlight is kept in sync. | 4817 // toolbar so the star highlight is kept in sync. |
4816 - (void)bookmarkNodeModified:(const BookmarkNode*)node { | 4818 - (void)bookmarkNodeModified:(const BookmarkNode*)node { |
4817 if ([_model currentTab] && node->url() == [_model currentTab].url) | 4819 if ([_model currentTab] && node->url() == [_model currentTab].url) |
4818 [self updateToolbar]; | 4820 [self updateToolbar]; |
4819 } | 4821 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5010 | 5012 |
5011 - (UIView*)voiceSearchButton { | 5013 - (UIView*)voiceSearchButton { |
5012 return _voiceSearchButton; | 5014 return _voiceSearchButton; |
5013 } | 5015 } |
5014 | 5016 |
5015 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5017 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
5016 return [self currentLogoAnimationControllerOwner]; | 5018 return [self currentLogoAnimationControllerOwner]; |
5017 } | 5019 } |
5018 | 5020 |
5019 @end | 5021 @end |
OLD | NEW |