OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 #include "ios/chrome/common/app_group/app_group_constants.h" | 5 #include "ios/chrome/common/app_group/app_group_constants.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "components/version_info/version_info.h" | 9 #include "components/version_info/version_info.h" |
10 | 10 |
| 11 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 12 #error "This file requires ARC support." |
| 13 #endif |
| 14 |
11 namespace { | 15 namespace { |
12 NSString* const kChromeAppGroupIdentifier = | 16 NSString* const kChromeAppGroupIdentifier = |
13 @"group." IOS_BUNDLE_ID_PREFIX ".chrome"; | 17 @"group." IOS_BUNDLE_ID_PREFIX ".chrome"; |
14 } | 18 } |
15 | 19 |
16 namespace app_group { | 20 namespace app_group { |
17 | 21 |
18 const char kChromeAppGroupXCallbackCommand[] = "app-group-command"; | 22 const char kChromeAppGroupXCallbackCommand[] = "app-group-command"; |
19 | 23 |
20 const char kChromeAppGroupCommandPreference[] = | 24 const char kChromeAppGroupCommandPreference[] = |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 return base::SysUTF8ToNSString(version_info::GetProductName()); | 62 return base::SysUTF8ToNSString(version_info::GetProductName()); |
59 case APP_GROUP_TODAY_EXTENSION: | 63 case APP_GROUP_TODAY_EXTENSION: |
60 return @"TodayExtension"; | 64 return @"TodayExtension"; |
61 } | 65 } |
62 } | 66 } |
63 | 67 |
64 NSUserDefaults* GetGroupUserDefaults() { | 68 NSUserDefaults* GetGroupUserDefaults() { |
65 NSUserDefaults* defaults = nil; | 69 NSUserDefaults* defaults = nil; |
66 NSString* applicationGroup = ApplicationGroup(); | 70 NSString* applicationGroup = ApplicationGroup(); |
67 if (applicationGroup) { | 71 if (applicationGroup) { |
68 defaults = [[[NSUserDefaults alloc] initWithSuiteName:applicationGroup] | 72 defaults = [[NSUserDefaults alloc] initWithSuiteName:applicationGroup]; |
69 autorelease]; | |
70 if (defaults) | 73 if (defaults) |
71 return defaults; | 74 return defaults; |
72 } | 75 } |
73 | 76 |
74 // On a device, the entitlements should always provide an application group to | 77 // On a device, the entitlements should always provide an application group to |
75 // the application. This is not the case on simulator. | 78 // the application. This is not the case on simulator. |
76 DCHECK(TARGET_IPHONE_SIMULATOR); | 79 DCHECK(TARGET_IPHONE_SIMULATOR); |
77 return [NSUserDefaults standardUserDefaults]; | 80 return [NSUserDefaults standardUserDefaults]; |
78 } | 81 } |
79 | 82 |
80 NSURL* ShareExtensionItemsFolder() { | 83 NSURL* ShareExtensionItemsFolder() { |
81 NSURL* groupURL = [[NSFileManager defaultManager] | 84 NSURL* groupURL = [[NSFileManager defaultManager] |
82 containerURLForSecurityApplicationGroupIdentifier:ApplicationGroup()]; | 85 containerURLForSecurityApplicationGroupIdentifier:ApplicationGroup()]; |
83 NSURL* readingListURL = | 86 NSURL* readingListURL = |
84 [groupURL URLByAppendingPathComponent:@"ShareExtensionItems" | 87 [groupURL URLByAppendingPathComponent:@"ShareExtensionItems" |
85 isDirectory:YES]; | 88 isDirectory:YES]; |
86 return readingListURL; | 89 return readingListURL; |
87 } | 90 } |
88 | 91 |
89 } // namespace app_group | 92 } // namespace app_group |
OLD | NEW |