OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/app/spotlight/actions_spotlight_manager.h" | 5 #import "ios/chrome/app/spotlight/actions_spotlight_manager.h" |
6 | 6 |
7 #import <CoreSpotlight/CoreSpotlight.h> | 7 #import <CoreSpotlight/CoreSpotlight.h> |
8 | 8 |
9 #include "base/ios/weak_nsobject.h" | 9 #include "base/ios/weak_nsobject.h" |
10 #include "base/mac/foundation_util.h" | 10 #include "base/mac/foundation_util.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 NSString* newTabTitle = | 153 NSString* newTabTitle = |
154 l10n_util::GetNSString(IDS_IOS_APPLICATION_SHORTCUT_NEWTAB_TITLE); | 154 l10n_util::GetNSString(IDS_IOS_APPLICATION_SHORTCUT_NEWTAB_TITLE); |
155 NSString* newTabAction = | 155 NSString* newTabAction = |
156 base::SysUTF8ToNSString(spotlight::kSpotlightActionNewTab); | 156 base::SysUTF8ToNSString(spotlight::kSpotlightActionNewTab); |
157 | 157 |
158 NSString* incognitoTitle = l10n_util::GetNSString( | 158 NSString* incognitoTitle = l10n_util::GetNSString( |
159 IDS_IOS_APPLICATION_SHORTCUT_NEWINCOGNITOTAB_TITLE); | 159 IDS_IOS_APPLICATION_SHORTCUT_NEWINCOGNITOTAB_TITLE); |
160 NSString* incognitoAction = base::SysUTF8ToNSString( | 160 NSString* incognitoAction = base::SysUTF8ToNSString( |
161 spotlight::kSpotlightActionNewIncognitoTab); | 161 spotlight::kSpotlightActionNewIncognitoTab); |
162 | 162 |
163 NSMutableArray* spotlightItems = [NSMutableArray | 163 NSString* qrScannerTitle = l10n_util::GetNSString( |
164 arrayWithObjects:[strongSelf getItemForAction:voiceSearchAction | 164 IDS_IOS_APPLICATION_SHORTCUT_QR_SCANNER_TITLE); |
165 title:voiceSearchTitle], | 165 NSString* qrScannerAction = |
166 [strongSelf getItemForAction:newTabAction | 166 base::SysUTF8ToNSString(spotlight::kSpotlightActionQRScanner); |
167 title:newTabTitle], | |
168 [strongSelf getItemForAction:incognitoAction | |
169 title:incognitoTitle], | |
170 nil]; | |
171 | 167 |
172 if (experimental_flags::IsQRCodeReaderEnabled()) { | 168 NSArray* spotlightItems = @[ |
173 NSString* qrScannerTitle = l10n_util::GetNSString( | 169 [strongSelf getItemForAction:voiceSearchAction |
174 IDS_IOS_APPLICATION_SHORTCUT_QR_SCANNER_TITLE); | 170 title:voiceSearchTitle], |
175 NSString* qrScannerAction = | 171 [strongSelf getItemForAction:newTabAction title:newTabTitle], |
176 base::SysUTF8ToNSString(spotlight::kSpotlightActionQRScanner); | 172 [strongSelf getItemForAction:incognitoAction title:incognitoTitle], |
177 | 173 [strongSelf getItemForAction:qrScannerAction title:qrScannerTitle] |
sdefresne
2017/02/03 16:16:42
nit: keep the trailing comma :-)
jif
2017/02/03 16:22:21
Done.
| |
178 [spotlightItems | 174 ]; |
179 addObject:[strongSelf getItemForAction:qrScannerAction | |
180 title:qrScannerTitle]]; | |
181 } | |
182 | 175 |
183 [[CSSearchableIndex defaultSearchableIndex] | 176 [[CSSearchableIndex defaultSearchableIndex] |
184 indexSearchableItems:spotlightItems | 177 indexSearchableItems:spotlightItems |
185 completionHandler:nil]; | 178 completionHandler:nil]; |
186 }); | 179 }); |
187 }]; | 180 }]; |
188 } | 181 } |
189 | 182 |
190 - (CSSearchableItem*)getItemForAction:(NSString*)action title:(NSString*)title { | 183 - (CSSearchableItem*)getItemForAction:(NSString*)action title:(NSString*)title { |
191 base::scoped_nsobject<CSSearchableItemAttributeSet> attributeSet( | 184 base::scoped_nsobject<CSSearchableItemAttributeSet> attributeSet( |
192 [[CSSearchableItemAttributeSet alloc] | 185 [[CSSearchableItemAttributeSet alloc] |
193 initWithItemContentType:spotlight::StringFromSpotlightDomain( | 186 initWithItemContentType:spotlight::StringFromSpotlightDomain( |
194 spotlight::DOMAIN_ACTIONS)]); | 187 spotlight::DOMAIN_ACTIONS)]); |
195 [attributeSet setTitle:title]; | 188 [attributeSet setTitle:title]; |
196 [attributeSet setDisplayName:title]; | 189 [attributeSet setDisplayName:title]; |
197 | 190 |
198 NSString* domainID = | 191 NSString* domainID = |
199 spotlight::StringFromSpotlightDomain(spotlight::DOMAIN_ACTIONS); | 192 spotlight::StringFromSpotlightDomain(spotlight::DOMAIN_ACTIONS); |
200 NSString* itemID = [NSString stringWithFormat:@"%@.%@", domainID, action]; | 193 NSString* itemID = [NSString stringWithFormat:@"%@.%@", domainID, action]; |
201 | 194 |
202 return [self spotlightItemWithItemID:itemID attributeSet:attributeSet]; | 195 return [self spotlightItemWithItemID:itemID attributeSet:attributeSet]; |
203 } | 196 } |
204 | 197 |
205 @end | 198 @end |
OLD | NEW |