Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / ios / chrome / common / app_group / app_group_constants.mm
blob48e46b1e855f788e6268fe8155cb5e930ba91d82
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.
5 #include "ios/chrome/common/app_group/app_group_constants.h"
7 #include "base/logging.h"
8 #include "base/strings/sys_string_conversions.h"
9 #include "components/version_info/version_info.h"
11 namespace {
12 NSString* const kChromeAppGroupIdentifier = @"group.com.google.chrome";
15 namespace app_group {
17 const char kChromeAppGroupXCallbackCommand[] = "app-group-command";
19 const char kChromeAppGroupCommandPreference[] =
20     "GroupApp.ChromeAppGroupCommand";
22 const char kChromeAppGroupCommandTimePreference[] = "CommandTime";
24 const char kChromeAppGroupCommandAppPreference[] = "SourceApp";
26 const char kChromeAppGroupCommandCommandPreference[] = "Command";
28 const char kChromeAppGroupCommandParameterPreference[] = "Parameter";
30 const char kChromeAppGroupOpenURLCommand[] = "openurl";
31 const char kChromeAppGroupVoiceSearchCommand[] = "voicesearch";
32 const char kChromeAppGroupNewTabCommand[] = "newtab";
34 const char kChromeAppClientID[] = "ClientID";
35 const char kUserMetricsEnabledDate[] = "UserMetricsEnabledDate";
36 const char kInstallDate[] = "InstallDate";
37 const char kBrandCode[] = "BrandCode";
39 NSString* ApplicationGroup() {
40   NSBundle* bundle = [NSBundle mainBundle];
41   NSString* group = [bundle objectForInfoDictionaryKey:@"KSApplicationGroup"];
42   if (![group length]) {
43     return kChromeAppGroupIdentifier;
44   }
45   return group;
48 NSString* ApplicationName(AppGroupApplications application) {
49   switch (application) {
50     case APP_GROUP_CHROME:
51       return base::SysUTF8ToNSString(version_info::GetProductName());
52     case APP_GROUP_TODAY_EXTENSION:
53       return @"TodayExtension";
54   }
57 NSUserDefaults* GetGroupUserDefaults() {
58   NSUserDefaults* defaults = nil;
59   NSString* applicationGroup = ApplicationGroup();
60   if (applicationGroup) {
61     defaults = [[[NSUserDefaults alloc] initWithSuiteName:applicationGroup]
62         autorelease];
63     if (defaults)
64       return defaults;
65   }
67   // On a device, the entitlements should always provide an application group to
68   // the application. This is not the case on simulator.
69   DCHECK(TARGET_IPHONE_SIMULATOR);
70   return [NSUserDefaults standardUserDefaults];
73 }  // namespace app_group