Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / password_manager / password_manager_util_mac.mm
blob961c1e21245065a09076fdc00fdcf604853d17d6
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 "components/password_manager/core/browser/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/bundle_locations.h"
14 #include "base/mac/foundation_util.h"
15 #include "base/mac/scoped_authorizationref.h"
16 #include "chrome/grit/chromium_strings.h"
17 #include "ui/base/l10n/l10n_util.h"
19 namespace password_manager_util {
21 bool AuthenticateUser(gfx::NativeWindow window) {
22   NSString* identifier = [base::mac::MainBundle() bundleIdentifier];
23   AuthorizationString name =
24       [[identifier stringByAppendingString:@".show-passwords"] UTF8String];
25   AuthorizationItem right_items[] = {
26     {name, 0, NULL, 0}
27   };
28   AuthorizationRights rights = {arraysize(right_items), right_items};
30   NSString* prompt =
31       l10n_util::GetNSString(IDS_PASSWORDS_PAGE_AUTHENTICATION_PROMPT);
33   // Pass kAuthorizationFlagDestroyRights to prevent the OS from saving the
34   // authorization and not prompting the user when future requests are made.
35   base::mac::ScopedAuthorizationRef authorization(
36       base::mac::GetAuthorizationRightsWithPrompt(
37           &rights, base::mac::NSToCFCast(prompt),
38           kAuthorizationFlagDestroyRights));
39   return authorization.get() != NULL;
42 // TODO(dubroy): Implement on Mac.
43 void GetOsPasswordStatus(const base::Callback<void(OsPasswordStatus)>& reply) {
44   reply.Run(PASSWORD_STATUS_UNSUPPORTED);
47 }  // namespace password_manager_util