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

Side by Side Diff: chrome/browser/password_manager/password_manager_util_mac.mm

Issue 817333002: Do not use hardcoded identifier in password manager user authorization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 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
« 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 2013 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/password_manager/password_manager_util.h" 5 #include "chrome/browser/password_manager/password_manager_util.h"
6 6
7 #include <CoreFoundation/CoreFoundation.h> 7 #include <CoreFoundation/CoreFoundation.h>
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 #include <Security/Authorization.h> 9 #include <Security/Authorization.h>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/mac/authorization_util.h" 12 #include "base/mac/authorization_util.h"
13 #include "base/mac/bundle_locations.h"
13 #include "base/mac/foundation_util.h" 14 #include "base/mac/foundation_util.h"
14 #include "base/mac/scoped_authorizationref.h" 15 #include "base/mac/scoped_authorizationref.h"
15 #include "chrome/grit/chromium_strings.h" 16 #include "chrome/grit/chromium_strings.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 18
18 namespace password_manager_util { 19 namespace password_manager_util {
19 20
20 bool AuthenticateUser(gfx::NativeWindow window) { 21 bool AuthenticateUser(gfx::NativeWindow window) {
22 NSString* identifier = [base::mac::MainBundle() bundleIdentifier];
23 AuthorizationString name =
24 [[identifier stringByAppendingString:@".show-passwords"] UTF8String];
dconnelly 2015/01/08 17:56:36 Don't use [NSString UTF8String]. Use base::SysNSSt
Jiang Jiang 2015/01/08 21:41:58 But I will have to call c_str() out of this still,
dconnelly 2015/01/09 09:06:03 No, this is fine then. git grep shows more uses of
21 AuthorizationItem right_items[] = { 25 AuthorizationItem right_items[] = {
22 {"com.google.Chrome.show-passwords", 0, NULL, 0} 26 {name, 0, NULL, 0}
23 }; 27 };
24 AuthorizationRights rights = {arraysize(right_items), right_items}; 28 AuthorizationRights rights = {arraysize(right_items), right_items};
25 29
26 NSString* prompt = 30 NSString* prompt =
27 l10n_util::GetNSString(IDS_PASSWORDS_PAGE_AUTHENTICATION_PROMPT); 31 l10n_util::GetNSString(IDS_PASSWORDS_PAGE_AUTHENTICATION_PROMPT);
28 32
29 // Pass kAuthorizationFlagDestroyRights to prevent the OS from saving the 33 // Pass kAuthorizationFlagDestroyRights to prevent the OS from saving the
30 // authorization and not prompting the user when future requests are made. 34 // authorization and not prompting the user when future requests are made.
31 base::mac::ScopedAuthorizationRef authorization( 35 base::mac::ScopedAuthorizationRef authorization(
32 base::mac::GetAuthorizationRightsWithPrompt( 36 base::mac::GetAuthorizationRightsWithPrompt(
33 &rights, base::mac::NSToCFCast(prompt), 37 &rights, base::mac::NSToCFCast(prompt),
34 kAuthorizationFlagDestroyRights)); 38 kAuthorizationFlagDestroyRights));
35 return authorization.get() != NULL; 39 return authorization.get() != NULL;
36 } 40 }
37 41
38 // TODO(dubroy): Implement on Mac. 42 // TODO(dubroy): Implement on Mac.
39 void GetOsPasswordStatus(const base::Callback<void(OsPasswordStatus)>& reply) { 43 void GetOsPasswordStatus(const base::Callback<void(OsPasswordStatus)>& reply) {
40 reply.Run(PASSWORD_STATUS_UNSUPPORTED); 44 reply.Run(PASSWORD_STATUS_UNSUPPORTED);
41 } 45 }
42 46
43 } // namespace password_manager_util 47 } // namespace password_manager_util
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