| 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 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 | 934 |
| 935 - (instancetype)initWithCoder:(NSCoder*)aDecoder { | 935 - (instancetype)initWithCoder:(NSCoder*)aDecoder { |
| 936 NOTREACHED(); | 936 NOTREACHED(); |
| 937 return nil; | 937 return nil; |
| 938 } | 938 } |
| 939 | 939 |
| 940 - (void)dealloc { | 940 - (void)dealloc { |
| 941 _tabStripController.reset(); | 941 _tabStripController.reset(); |
| 942 _infoBarContainer.reset(); | 942 _infoBarContainer.reset(); |
| 943 _readingListMenuNotifier.reset(); | 943 _readingListMenuNotifier.reset(); |
| 944 _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get()); | 944 if (_bookmarkModel) |
| 945 _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get()); |
| 945 [_model removeObserver:self]; | 946 [_model removeObserver:self]; |
| 946 [[UpgradeCenter sharedInstance] unregisterClient:self]; | 947 [[UpgradeCenter sharedInstance] unregisterClient:self]; |
| 947 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 948 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 948 [_toolbarController setDelegate:nil]; | 949 [_toolbarController setDelegate:nil]; |
| 949 if (_voiceSearchController.get()) | 950 if (_voiceSearchController.get()) |
| 950 _voiceSearchController->SetDelegate(nil); | 951 _voiceSearchController->SetDelegate(nil); |
| 951 [_rateThisAppDialog setDelegate:nil]; | 952 [_rateThisAppDialog setDelegate:nil]; |
| 952 [_model closeAllTabs]; | 953 [_model closeAllTabs]; |
| 953 [super dealloc]; | 954 [super dealloc]; |
| 954 } | 955 } |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 } | 1650 } |
| 1650 NSUInteger count = [_model count]; | 1651 NSUInteger count = [_model count]; |
| 1651 for (NSUInteger index = 0; index < count; ++index) | 1652 for (NSUInteger index = 0; index < count; ++index) |
| 1652 [self installDelegatesForTab:[_model tabAtIndex:index]]; | 1653 [self installDelegatesForTab:[_model tabAtIndex:index]]; |
| 1653 | 1654 |
| 1654 [self registerForNotifications]; | 1655 [self registerForNotifications]; |
| 1655 | 1656 |
| 1656 _imageFetcher->SetRequestContextGetter(_browserState->GetRequestContext()); | 1657 _imageFetcher->SetRequestContextGetter(_browserState->GetRequestContext()); |
| 1657 _dominantColorCache.reset([[NSMutableDictionary alloc] init]); | 1658 _dominantColorCache.reset([[NSMutableDictionary alloc] init]); |
| 1658 | 1659 |
| 1659 // Register for bookmark changed notification. | 1660 // Register for bookmark changed notification (BookmarkModel may be null |
| 1660 _bookmarkModelBridge.reset(new BrowserBookmarkModelBridge(self)); | 1661 // during testing, so explicitly support this). |
| 1661 _bookmarkModel = ios::BookmarkModelFactory::GetForBrowserState(_browserState); | 1662 _bookmarkModel = ios::BookmarkModelFactory::GetForBrowserState(_browserState); |
| 1662 _bookmarkModel->AddObserver(_bookmarkModelBridge.get()); | 1663 if (_bookmarkModel) { |
| 1664 _bookmarkModelBridge.reset(new BrowserBookmarkModelBridge(self)); |
| 1665 _bookmarkModel->AddObserver(_bookmarkModelBridge.get()); |
| 1666 } |
| 1663 } | 1667 } |
| 1664 | 1668 |
| 1665 - (void)ensureViewCreated { | 1669 - (void)ensureViewCreated { |
| 1666 ignore_result([self view]); | 1670 ignore_result([self view]); |
| 1667 } | 1671 } |
| 1668 | 1672 |
| 1669 - (void)browserStateDestroyed { | 1673 - (void)browserStateDestroyed { |
| 1670 [self setActive:NO]; | 1674 [self setActive:NO]; |
| 1671 // Reset the toolbar opacity in case it was changed for contextual search. | 1675 // Reset the toolbar opacity in case it was changed for contextual search. |
| 1672 [self updateToolbarControlsAlpha:1.0]; | 1676 [self updateToolbarControlsAlpha:1.0]; |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2148 } | 2152 } |
| 2149 } | 2153 } |
| 2150 | 2154 |
| 2151 #pragma mark - External files | 2155 #pragma mark - External files |
| 2152 | 2156 |
| 2153 - (NSSet*)referencedExternalFiles { | 2157 - (NSSet*)referencedExternalFiles { |
| 2154 NSSet* filesReferencedByTabs = [_model currentlyReferencedExternalFiles]; | 2158 NSSet* filesReferencedByTabs = [_model currentlyReferencedExternalFiles]; |
| 2155 | 2159 |
| 2156 // TODO(noyau): this is incorrect, the caller should know that the model is | 2160 // TODO(noyau): this is incorrect, the caller should know that the model is |
| 2157 // not loaded yet. | 2161 // not loaded yet. |
| 2158 if (!_bookmarkModel->loaded()) | 2162 if (!_bookmarkModel || !_bookmarkModel->loaded()) |
| 2159 return filesReferencedByTabs; | 2163 return filesReferencedByTabs; |
| 2160 | 2164 |
| 2161 std::vector<bookmarks::BookmarkModel::URLAndTitle> bookmarks; | 2165 std::vector<bookmarks::BookmarkModel::URLAndTitle> bookmarks; |
| 2162 _bookmarkModel->GetBookmarks(&bookmarks); | 2166 _bookmarkModel->GetBookmarks(&bookmarks); |
| 2163 NSMutableSet* bookmarkedFiles = [NSMutableSet set]; | 2167 NSMutableSet* bookmarkedFiles = [NSMutableSet set]; |
| 2164 for (const auto& bookmark : bookmarks) { | 2168 for (const auto& bookmark : bookmarks) { |
| 2165 GURL bookmarkUrl = bookmark.url; | 2169 GURL bookmarkUrl = bookmark.url; |
| 2166 if (UrlIsExternalFileReference(bookmarkUrl)) { | 2170 if (UrlIsExternalFileReference(bookmarkUrl)) { |
| 2167 [bookmarkedFiles | 2171 [bookmarkedFiles |
| 2168 addObject:base::SysUTF8ToNSString(bookmarkUrl.ExtractFileName())]; | 2172 addObject:base::SysUTF8ToNSString(bookmarkUrl.ExtractFileName())]; |
| (...skipping 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5137 | 5141 |
| 5138 - (UIView*)voiceSearchButton { | 5142 - (UIView*)voiceSearchButton { |
| 5139 return _voiceSearchButton; | 5143 return _voiceSearchButton; |
| 5140 } | 5144 } |
| 5141 | 5145 |
| 5142 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5146 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 5143 return [self currentLogoAnimationControllerOwner]; | 5147 return [self currentLogoAnimationControllerOwner]; |
| 5144 } | 5148 } |
| 5145 | 5149 |
| 5146 @end | 5150 @end |
| OLD | NEW |