1 // Copyright 2013 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 "chrome/browser/password_manager/password_manager_util.h"
7 #include <CoreFoundation/CoreFoundation.h>
8 #import <Foundation/Foundation.h>
9 #include <Security/Authorization.h>
11 #include "base/basictypes.h"
12 #include "base/mac/authorization_util.h"
13 #include "base/mac/foundation_util.h"
14 #include "base/mac/scoped_authorizationref.h"
15 #include "chrome/grit/chromium_strings.h"
16 #include "ui/base/l10n/l10n_util.h"
18 namespace password_manager_util {
20 bool AuthenticateUser(gfx::NativeWindow window) {
21 AuthorizationItem right_items[] = {
22 {"com.google.Chrome.show-passwords", 0, NULL, 0}
24 AuthorizationRights rights = {arraysize(right_items), right_items};
27 l10n_util::GetNSString(IDS_PASSWORDS_PAGE_AUTHENTICATION_PROMPT);
29 // Pass kAuthorizationFlagDestroyRights to prevent the OS from saving the
30 // authorization and not prompting the user when future requests are made.
31 base::mac::ScopedAuthorizationRef authorization(
32 base::mac::GetAuthorizationRightsWithPrompt(
33 &rights, base::mac::NSToCFCast(prompt),
34 kAuthorizationFlagDestroyRights));
35 return authorization.get() != NULL;
38 // TODO(dubroy): Implement on Mac.
39 OsPasswordStatus GetOsPasswordStatus() {
40 return PASSWORD_STATUS_UNSUPPORTED;
43 } // namespace password_manager_util