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

Unified Diff: ios/chrome/app/spotlight/spotlight_manager.mm

Issue 2580363002: Upstream Chrome on iOS source code [1/11]. (Closed)
Patch Set: Created 4 years 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
Index: ios/chrome/app/spotlight/spotlight_manager.mm
diff --git a/ios/chrome/app/spotlight/spotlight_manager.mm b/ios/chrome/app/spotlight/spotlight_manager.mm
new file mode 100644
index 0000000000000000000000000000000000000000..22c83bdf8e7a76a867a7777c39800b0951f034d5
--- /dev/null
+++ b/ios/chrome/app/spotlight/spotlight_manager.mm
@@ -0,0 +1,68 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/chrome/app/spotlight/spotlight_manager.h"
+
+#include "base/logging.h"
+#include "base/mac/scoped_nsobject.h"
+#include "ios/chrome/app/spotlight/actions_spotlight_manager.h"
+#include "ios/chrome/app/spotlight/bookmarks_spotlight_manager.h"
+#include "ios/chrome/app/spotlight/topsites_spotlight_manager.h"
+#include "ios/chrome/browser/experimental_flags.h"
+
+// Called from the BrowserBookmarkModelBridge from C++ -> ObjC.
+@interface SpotlightManager ()<BookmarkUpdatedDelegate> {
+ base::scoped_nsobject<BookmarksSpotlightManager> _bookmarkManager;
+ base::scoped_nsobject<TopSitesSpotlightManager> _topSitesManager;
+ base::scoped_nsobject<ActionsSpotlightManager> _actionsManager;
+}
+
+- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState
+ NS_DESIGNATED_INITIALIZER;
+
+- (instancetype)init NS_UNAVAILABLE;
+@end
+
+@implementation SpotlightManager
+
++ (SpotlightManager*)spotlightManagerWithBrowserState:
+ (ios::ChromeBrowserState*)browserState {
+ DCHECK(spotlight::IsSpotlightAvailable());
+ return [[[SpotlightManager alloc] initWithBrowserState:browserState]
+ autorelease];
+}
+
+- (instancetype)initWithBrowserState:(ios::ChromeBrowserState*)browserState {
+ self = [super init];
+ if (self) {
+ _topSitesManager.reset([[TopSitesSpotlightManager
+ topSitesSpotlightManagerWithBrowserState:browserState] retain]);
+ _bookmarkManager.reset([[BookmarksSpotlightManager
+ bookmarksSpotlightManagerWithBrowserState:browserState] retain]);
+ [_bookmarkManager setDelegate:self];
+ _actionsManager.reset(
+ [[ActionsSpotlightManager actionsSpotlightManager] retain]);
+ }
+ return self;
+}
+
+- (instancetype)init {
+ NOTREACHED();
+ return nil;
+}
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+- (void)resyncIndex {
+ [_bookmarkManager reindexBookmarksIfNeeded];
+ [_actionsManager indexActions];
+}
+
+- (void)bookmarkUpdated {
+ [_topSitesManager reindexTopSites];
+}
+
+@end
« no previous file with comments | « ios/chrome/app/spotlight/spotlight_manager.h ('k') | ios/chrome/app/spotlight/spotlight_manager_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698