Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: ios/chrome/browser/ui/browser_view_controller.mm

Issue 2632393002: Allow using a BrowserViewController without BookmarkModel for testing. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/ui/main/browser_view_wrangler_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/ui/browser_view_controller.mm
diff --git a/ios/chrome/browser/ui/browser_view_controller.mm b/ios/chrome/browser/ui/browser_view_controller.mm
index 6749fc2a2c6904960a6bef19e4f1cf0d71eeb4fb..2054d20570d587cd09a78b0d685a8878f4286a00 100644
--- a/ios/chrome/browser/ui/browser_view_controller.mm
+++ b/ios/chrome/browser/ui/browser_view_controller.mm
@@ -941,7 +941,8 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
_tabStripController.reset();
_infoBarContainer.reset();
_readingListMenuNotifier.reset();
- _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get());
+ if (_bookmarkModel)
+ _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get());
[_model removeObserver:self];
[[UpgradeCenter sharedInstance] unregisterClient:self];
[[NSNotificationCenter defaultCenter] removeObserver:self];
@@ -1656,10 +1657,13 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
_imageFetcher->SetRequestContextGetter(_browserState->GetRequestContext());
_dominantColorCache.reset([[NSMutableDictionary alloc] init]);
- // Register for bookmark changed notification.
- _bookmarkModelBridge.reset(new BrowserBookmarkModelBridge(self));
+ // Register for bookmark changed notification (BookmarkModel may be null
+ // during testing, so explicitly support this).
_bookmarkModel = ios::BookmarkModelFactory::GetForBrowserState(_browserState);
- _bookmarkModel->AddObserver(_bookmarkModelBridge.get());
+ if (_bookmarkModel) {
+ _bookmarkModelBridge.reset(new BrowserBookmarkModelBridge(self));
+ _bookmarkModel->AddObserver(_bookmarkModelBridge.get());
+ }
}
- (void)ensureViewCreated {
@@ -2155,7 +2159,7 @@ class BrowserBookmarkModelBridge : public bookmarks::BookmarkModelObserver {
// TODO(noyau): this is incorrect, the caller should know that the model is
// not loaded yet.
- if (!_bookmarkModel->loaded())
+ if (!_bookmarkModel || !_bookmarkModel->loaded())
return filesReferencedByTabs;
std::vector<bookmarks::BookmarkModel::URLAndTitle> bookmarks;
« no previous file with comments | « no previous file | ios/chrome/browser/ui/main/browser_view_wrangler_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698