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

Side by Side Diff: ios/chrome/app/spotlight/spotlight_util.h

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 unified diff | Download patch
OLDNEW
(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 #ifndef IOS_CHROME_APP_SPOTLIGHT_SPOTLIGHT_UTIL_H_
6 #define IOS_CHROME_APP_SPOTLIGHT_SPOTLIGHT_UTIL_H_
7
8 #import <UIKit/UIKit.h>
9
10 typedef void (^BlockWithError)(NSError*);
11 typedef void (^BlockWithNSURL)(NSURL*);
12
13 namespace spotlight {
14
15 // This enum is used for Histogram. Domains should not be removed or reordered
16 // and this enum should be kept synced with histograms.xml.
17 // DOMAIN_UNKNOWN may be reported if Spotlight is not synced with chrome and
18 // a domain has been removed since last indexation (should not happen in stable
19 // channel).
20 enum Domain {
21 DOMAIN_UNKNOWN = 0,
22 DOMAIN_BOOKMARKS = 1,
23 DOMAIN_TOPSITES = 2,
24 DOMAIN_ACTIONS = 3,
25 DOMAIN_COUNT
26 };
27
28 // The key of a custom attribute containing the item ID so the item is
29 // searchable using CSSearchQuery.
30 NSString* GetSpotlightCustomAttributeItemID();
31
32 // NSUserDefaults key of entry containing date of the latest bookmarks indexing.
33 extern const char kSpotlightLastIndexingDateKey[];
34
35 // The current version of the Spotlight index format.
36 // Change this value if there are change int the information indexed in
37 // Spotlight. This will force reindexation on next startup.
38 // Value is stored in |kSpotlightLastIndexingVersionKey|.
39 extern const int kCurrentSpotlightIndexVersion;
40
41 // NSUserDefault key of entry containing Chrome version of the latest bookmarks
42 // indexing.
43 extern const char kSpotlightLastIndexingVersionKey[];
44
45 // Utility methods deleting nodes in Spotlight index. Will be retried in case of
46 // failure as required by Apple documentation.
47 void DeleteSearchableDomainItems(Domain domain, BlockWithError callback);
48 void DeleteItemsWithIdentifiers(NSArray* items, BlockWithError callback);
49 void ClearAllSpotlightEntries(BlockWithError callback);
50
51 // Converts the spotlight::Domain enum to Spotlight domain string
52 NSString* StringFromSpotlightDomain(Domain domain);
53
54 // Converts the Spotlight domain string to spotlight::Domain enum.
55 Domain SpotlightDomainFromString(NSString* domain);
56
57 // Returns whether Spotlight is available on the device. Must be tested before
58 // calling other methods of this class.
59 bool IsSpotlightAvailable();
60
61 // Clears the current Spotlight index of the device. Method is static to allow
62 // clearing the index without instantiating SpotlightManager.
63 // This method must not be called if |isSpotlightAvailable| returns NO.
64 // This method is asynchronous and can fail. Completion is called with a
65 // parameter indicating if the deletion was a success.
66 void ClearSpotlightIndexWithCompletion(BlockWithError completion);
67
68 // Finds the Spoglight itemID and calls |completion| with the corresponding URL.
69 // Calls |completion| with nil if none was found.
70 // |completion| is called on the Spotlight Thread.
71 void GetURLForSpotlightItemID(NSString* itemID, BlockWithNSURL completion);
72
73 } // namespace spotlight
74
75 #endif // IOS_CHROME_APP_SPOTLIGHT_SPOTLIGHT_UTIL_H_
OLDNEW
« no previous file with comments | « ios/chrome/app/spotlight/spotlight_manager_unittest.mm ('k') | ios/chrome/app/spotlight/spotlight_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698