Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: components/encryptor/keychain_password_mac.mm

Issue 200623002: [Mac] Chromium builds shouldn't ask for access to Chrome's own secure data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/encryptor/keychain_password_mac.h" 5 #include "components/encryptor/keychain_password_mac.h"
6 6
7 #import <Security/Security.h> 7 #import <Security/Security.h>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/mac/mac_logging.h" 10 #include "base/mac/mac_logging.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 return password; 45 return password;
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 std::string KeychainPassword::GetPassword() const { 50 std::string KeychainPassword::GetPassword() const {
51 // These two strings ARE indeed user facing. But they are used to access 51 // These two strings ARE indeed user facing. But they are used to access
52 // the encryption keyword. So as to not lose encrypted data when system 52 // the encryption keyword. So as to not lose encrypted data when system
53 // locale changes we DO NOT LOCALIZE. 53 // locale changes we DO NOT LOCALIZE.
54 #if defined(OFFICIAL_BUILD)
54 const std::string service_name = "Chrome Safe Storage"; 55 const std::string service_name = "Chrome Safe Storage";
55 const std::string account_name = "Chrome"; 56 const std::string account_name = "Chrome";
57 #else
58 const std::string service_name = "Chromium Safe Storage";
59 const std::string account_name = "Chromium";
60 #endif
56 61
57 UInt32 password_length = 0; 62 UInt32 password_length = 0;
58 void* password_data = NULL; 63 void* password_data = NULL;
59 OSStatus error = keychain_.FindGenericPassword(NULL, 64 OSStatus error = keychain_.FindGenericPassword(NULL,
60 service_name.size(), 65 service_name.size(),
61 service_name.data(), 66 service_name.data(),
62 account_name.size(), 67 account_name.size(),
63 account_name.data(), 68 account_name.data(),
64 &password_length, 69 &password_length,
65 &password_data, 70 &password_data,
66 NULL); 71 NULL);
67 72
68 if (error == noErr) { 73 if (error == noErr) {
69 std::string password = 74 std::string password =
70 std::string(static_cast<char*>(password_data), password_length); 75 std::string(static_cast<char*>(password_data), password_length);
71 keychain_.ItemFreeContent(NULL, password_data); 76 keychain_.ItemFreeContent(NULL, password_data);
72 return password; 77 return password;
73 } else if (error == errSecItemNotFound) { 78 } else if (error == errSecItemNotFound) {
74 return AddRandomPasswordToKeychain(keychain_, service_name, account_name); 79 return AddRandomPasswordToKeychain(keychain_, service_name, account_name);
75 } else { 80 } else {
76 OSSTATUS_DLOG(ERROR, error) << "Keychain lookup failed"; 81 OSSTATUS_DLOG(ERROR, error) << "Keychain lookup failed";
77 return std::string(); 82 return std::string();
78 } 83 }
79 } 84 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698