Index: google_apis/google_api_keys_mac.mm |
diff --git a/google_apis/google_api_keys_mac.mm b/google_apis/google_api_keys_mac.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e7c8c1e5d825c66053202498bf7e19b114c9c4c3 |
--- /dev/null |
+++ b/google_apis/google_api_keys_mac.mm |
@@ -0,0 +1,22 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#import "google_api_keys_mac.h" |
+ |
+#import <Foundation/Foundation.h> |
+ |
+#include "base/mac/bundle_locations.h" |
+#include "base/mac/foundation_util.h" |
+#include "base/strings/sys_string_conversions.h" |
+ |
+namespace google_apis { |
+ |
+std::string GetAPIKeyFromInfoPlist(const std::string& key_name) { |
+ NSString* keyName = base::SysUTF8ToNSString(key_name); |
+ NSString* keyValue = base::mac::ObjCCast<NSString>( |
+ [base::mac::FrameworkBundle() objectForInfoDictionaryKey:keyName]); |
+ return base::SysNSStringToUTF8(keyValue); |
+} |
+ |
+} // namespace google_apis |