| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2009 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 |
| 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_INTERNAL_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_INTERNAL_H_ |
| 7 |
| 8 #include <Security/Security.h> |
| 9 |
| 10 #include <string> |
| 11 #include <vector> |
| 12 |
| 13 #include "base/time.h" |
| 14 #include "chrome/browser/keychain_mac.h" |
| 15 |
| 16 namespace internal_keychain_helpers { |
| 17 |
| 18 // Takes a PasswordForm's signon_realm and parses it into its component parts, |
| 19 // which are returned though the appropriate out parameters. |
| 20 // Returns true if it can be successfully parsed, in which case all out params |
| 21 // that are non-NULL will be set. If there is no port, port will be 0. |
| 22 // If the return value is false, the state of the our params is undefined. |
| 23 bool ExtractSignonRealmComponents(const std::string& signon_realm, |
| 24 std::string* server, int* port, |
| 25 bool* is_secure, |
| 26 std::string* security_domain); |
| 27 |
| 28 // Returns a URL built from the given components. To create a URL without a |
| 29 // port, pass kAnyPort for the |port| parameter. |
| 30 GURL URLFromComponents(bool is_secure, const std::string& host, int port, |
| 31 const std::string& path); |
| 32 |
| 33 // Converts a Keychain time string to a Time object, returning true if |
| 34 // time_string_bytes was parsable. If the return value is false, the value of |
| 35 // |time| is unchanged. |
| 36 bool TimeFromKeychainTimeString(const char* time_string_bytes, |
| 37 unsigned int byte_length, |
| 38 base::Time* time); |
| 39 |
| 40 // Returns the Keychain SecAuthenticationType type corresponding to |scheme|. |
| 41 SecAuthenticationType AuthTypeForScheme(PasswordForm::Scheme scheme); |
| 42 |
| 43 // Returns the PasswordForm Scheme corresponding to |auth_type|. |
| 44 PasswordForm::Scheme SchemeForAuthType(SecAuthenticationType auth_type); |
| 45 |
| 46 // Searches |keychain| for all items usable for the given signon_realm, and |
| 47 // puts them in |items|. The caller is responsible for calling keychain->Free |
| 48 // on each of them when it is finished with them. |
| 49 void FindMatchingKeychainItems(const MacKeychain& keychain, |
| 50 const std::string& signon_realm, |
| 51 PasswordForm::Scheme scheme, |
| 52 std::vector<SecKeychainItemRef>* items); |
| 53 |
| 54 // Sets the fields of |form| based on the keychain data from |keychain_item|. |
| 55 // Fields that can't be determined from |keychain_item| will be unchanged. |
| 56 // |
| 57 // IMPORTANT: This function can cause the OS to trigger UI (to allow access to |
| 58 // the keychain item if we aren't trusted for the item), and block until the UI |
| 59 // is dismissed. |
| 60 // |
| 61 // If excessive prompting for access to other applications' keychain items |
| 62 // becomes an issue, the password storage API will need to be refactored to |
| 63 // allow the password to be retrieved later (accessing other fields doesn't |
| 64 // require authorization). |
| 65 bool FillPasswordFormFromKeychainItem(const MacKeychain& keychain, |
| 66 const SecKeychainItemRef& keychain_item, |
| 67 PasswordForm* form); |
| 68 |
| 69 } // internal_keychain_helpers |
| 70 |
| 71 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_MAC_INTERNAL_H_ |
| OLD | NEW |