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

Unified Diff: chrome/browser/password_manager/password_manager_util_mac.mm

Issue 28713002: [Mac] Add option to reauthenticate the OS user before revealing passwords. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rerebase. Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/password_manager_util_mac.mm
diff --git a/chrome/browser/password_manager/password_manager_util_mac.mm b/chrome/browser/password_manager/password_manager_util_mac.mm
new file mode 100644
index 0000000000000000000000000000000000000000..cf65c82fac9086bf59e5781b6a309f01405768e7
--- /dev/null
+++ b/chrome/browser/password_manager/password_manager_util_mac.mm
@@ -0,0 +1,39 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/password_manager/password_manager_util.h"
+
+#import <Foundation/Foundation.h>
+#include <CoreFoundation/CoreFoundation.h>
+#include <Security/Authorization.h>
+
+#include "base/basictypes.h"
+#include "base/mac/authorization_util.h"
+#include "base/mac/foundation_util.h"
+#include "base/mac/scoped_authorizationref.h"
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace password_manager_util {
+
+bool AuthenticateUser() {
+ AuthorizationItem right_items[] = {
+ {"com.google.Chrome.show-passwords", 0, NULL, 0}
+ };
+ AuthorizationRights rights = {arraysize(right_items), right_items};
+
+ NSString* prompt =
+ l10n_util::GetNSString(IDS_PASSWORDS_PAGE_AUTHENTICATION_PROMPT);
+
+ // Pass kAuthorizationFlagDestroyRights to prevent the OS from saving the
+ // authorization and not prompting the user when future requests are made.
+ base::mac::ScopedAuthorizationRef authorization(
+ base::mac::GetAuthorizationRightsWithPrompt(
+ &rights, base::mac::NSToCFCast(prompt),
+ kAuthorizationFlagDestroyRights));
+ return authorization.get() != NULL;
+}
+
+} // namespace password_manager_util
« no previous file with comments | « chrome/browser/password_manager/password_manager_util.h ('k') | chrome/browser/password_manager/password_manager_util_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698