| 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/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "ios/chrome/browser/app_startup_parameters.h" | 12 #include "ios/chrome/browser/app_startup_parameters.h" |
| 13 #include "ios/chrome/browser/experimental_flags.h" | |
| 14 #include "ios/chrome/common/app_group/app_group_constants.h" | 13 #include "ios/chrome/common/app_group/app_group_constants.h" |
| 15 #include "ios/chrome/grit/ios_strings.h" | 14 #include "ios/chrome/grit/ios_strings.h" |
| 16 #include "net/base/mac/url_conversions.h" | 15 #include "net/base/mac/url_conversions.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 19 | 18 |
| 20 #if !defined(__has_feature) || !__has_feature(objc_arc) | 19 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 21 #error "This file requires ARC support." | 20 #error "This file requires ARC support." |
| 22 #endif | 21 #endif |
| 23 | 22 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 dispatch_get_main_queue(), ^{ | 124 dispatch_get_main_queue(), ^{ |
| 126 ActionsSpotlightManager* strongSelf = weakSelf; | 125 ActionsSpotlightManager* strongSelf = weakSelf; |
| 127 [strongSelf clearAndAddSpotlightActions]; | 126 [strongSelf clearAndAddSpotlightActions]; |
| 128 }); | 127 }); |
| 129 } | 128 } |
| 130 | 129 |
| 131 #pragma mark private methods | 130 #pragma mark private methods |
| 132 | 131 |
| 133 - (void)clearAndAddSpotlightActions { | 132 - (void)clearAndAddSpotlightActions { |
| 134 [self clearAllSpotlightItems:^(NSError* error) { | 133 [self clearAllSpotlightItems:^(NSError* error) { |
| 135 if (!experimental_flags::IsSpotlightActionsEnabled()) { | |
| 136 return; | |
| 137 } | |
| 138 __weak ActionsSpotlightManager* weakSelf = self; | 134 __weak ActionsSpotlightManager* weakSelf = self; |
| 139 dispatch_after( | 135 dispatch_after( |
| 140 dispatch_time(DISPATCH_TIME_NOW, | 136 dispatch_time(DISPATCH_TIME_NOW, |
| 141 static_cast<int64_t>(1 * NSEC_PER_SEC)), | 137 static_cast<int64_t>(1 * NSEC_PER_SEC)), |
| 142 dispatch_get_main_queue(), ^{ | 138 dispatch_get_main_queue(), ^{ |
| 143 ActionsSpotlightManager* strongSelf = weakSelf; | 139 ActionsSpotlightManager* strongSelf = weakSelf; |
| 144 | 140 |
| 145 if (!strongSelf) { | 141 if (!strongSelf) { |
| 146 return; | 142 return; |
| 147 } | 143 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 [attributeSet setDisplayName:title]; | 186 [attributeSet setDisplayName:title]; |
| 191 | 187 |
| 192 NSString* domainID = | 188 NSString* domainID = |
| 193 spotlight::StringFromSpotlightDomain(spotlight::DOMAIN_ACTIONS); | 189 spotlight::StringFromSpotlightDomain(spotlight::DOMAIN_ACTIONS); |
| 194 NSString* itemID = [NSString stringWithFormat:@"%@.%@", domainID, action]; | 190 NSString* itemID = [NSString stringWithFormat:@"%@.%@", domainID, action]; |
| 195 | 191 |
| 196 return [self spotlightItemWithItemID:itemID attributeSet:attributeSet]; | 192 return [self spotlightItemWithItemID:itemID attributeSet:attributeSet]; |
| 197 } | 193 } |
| 198 | 194 |
| 199 @end | 195 @end |
| OLD | NEW |