OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/chrome/app/spotlight/spotlight_manager.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "ios/chrome/app/spotlight/actions_spotlight_manager.h" |
| 10 #include "ios/chrome/app/spotlight/bookmarks_spotlight_manager.h" |
| 11 #include "ios/chrome/app/spotlight/topsites_spotlight_manager.h" |
| 12 #include "ios/chrome/browser/experimental_flags.h" |
| 13 |
| 14 // Called from the BrowserBookmarkModelBridge from C++ -> ObjC. |
| 15 @interface SpotlightManager ()<BookmarkUpdatedDelegate> { |
| 16 base::scoped_nsobject<BookmarksSpotlightManager> _bookmarkManager; |
| 17 base::scoped_nsobject<TopSitesSpotlightManager> _topSitesManager; |
| 18 base::scoped_nsobject<ActionsSpotlightManager> _actionsManager; |
| 19 } |
| 20 |
| 21 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState |
| 22 NS_DESIGNATED_INITIALIZER; |
| 23 |
| 24 - (instancetype)init NS_UNAVAILABLE; |
| 25 @end |
| 26 |
| 27 @implementation SpotlightManager |
| 28 |
| 29 + (SpotlightManager*)spotlightManagerWithBrowserState: |
| 30 (ios::ChromeBrowserState*)browserState { |
| 31 DCHECK(spotlight::IsSpotlightAvailable()); |
| 32 return [[[SpotlightManager alloc] initWithBrowserState:browserState] |
| 33 autorelease]; |
| 34 } |
| 35 |
| 36 - (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState { |
| 37 self = [super init]; |
| 38 if (self) { |
| 39 _topSitesManager.reset([[TopSitesSpotlightManager |
| 40 topSitesSpotlightManagerWithBrowserState:browserState] retain]); |
| 41 _bookmarkManager.reset([[BookmarksSpotlightManager |
| 42 bookmarksSpotlightManagerWithBrowserState:browserState] retain]); |
| 43 [_bookmarkManager setDelegate:self]; |
| 44 _actionsManager.reset( |
| 45 [[ActionsSpotlightManager actionsSpotlightManager] retain]); |
| 46 } |
| 47 return self; |
| 48 } |
| 49 |
| 50 - (instancetype)init { |
| 51 NOTREACHED(); |
| 52 return nil; |
| 53 } |
| 54 |
| 55 - (void)dealloc { |
| 56 [super dealloc]; |
| 57 } |
| 58 |
| 59 - (void)resyncIndex { |
| 60 [_bookmarkManager reindexBookmarksIfNeeded]; |
| 61 [_actionsManager indexActions]; |
| 62 } |
| 63 |
| 64 - (void)bookmarkUpdated { |
| 65 [_topSitesManager reindexTopSites]; |
| 66 } |
| 67 |
| 68 @end |
OLD | NEW |