google_api_keys_mac.mm 712 B

12345678910111213141516171819202122
  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
  3. // found in the LICENSE file.
  4. #import "google_api_keys_mac.h"
  5. #import <Foundation/Foundation.h>
  6. #include "base/mac/bundle_locations.h"
  7. #include "base/mac/foundation_util.h"
  8. #include "base/strings/sys_string_conversions.h"
  9. namespace google_apis {
  10. std::string GetAPIKeyFromInfoPlist(const std::string& key_name) {
  11. NSString* keyName = base::SysUTF8ToNSString(key_name);
  12. NSString* keyValue = base::mac::ObjCCast<NSString>(
  13. [base::mac::FrameworkBundle() objectForInfoDictionaryKey:keyName]);
  14. return base::SysNSStringToUTF8(keyValue);
  15. }
  16. } // namespace google_apis