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

Side by Side Diff: chrome/browser/ui/webui/options/managed_user_passphrase_handler.cc

Issue 12208068: Add a set passphrase dialog for managed user accounts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile error on linux_clang. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 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.
4
5 #include "chrome/browser/ui/webui/options/managed_user_passphrase_handler.h"
6
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h"
10 #include "base/values.h"
11 #include "chrome/browser/managed_mode/managed_user_passphrase.h"
12 #include "chrome/browser/managed_mode/managed_user_service.h"
13 #include "chrome/browser/managed_mode/managed_user_service_factory.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/pref_names.h"
16 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_ui.h"
18 #include "grit/generated_resources.h"
19
20 namespace options {
21
22 ManagedUserPassphraseHandler::ManagedUserPassphraseHandler()
23 : weak_ptr_factory_(this) {
24 }
25
26 ManagedUserPassphraseHandler::~ManagedUserPassphraseHandler() {
27 }
28
29 void ManagedUserPassphraseHandler::InitializeHandler() {
30 }
31
32 void ManagedUserPassphraseHandler::RegisterMessages() {
33 web_ui()->RegisterMessageCallback(
34 "setPassphrase",
35 base::Bind(&ManagedUserPassphraseHandler::SetLocalPassphrase,
36 weak_ptr_factory_.GetWeakPtr()));
37 }
38
39 void ManagedUserPassphraseHandler::GetLocalizedValues(
40 base::DictionaryValue* localized_strings) {
41 DCHECK(localized_strings);
42
43 static OptionsStringResource resources[] = {
44 { "confirmPassphrase", IDS_CONFIRM_PASSPHRASE_LABEL },
45 { "enterPassphrase", IDS_ENTER_PASSPHRASE_LABEL },
46 { "savePassphrase", IDS_SAVE_PASSPHRASE_BUTTON },
47 { "setPassphraseInstructions", IDS_SET_PASSPHRASE_INSTRUCTIONS },
48 { "passphraseMismatch", IDS_PASSPHRASE_MISMATCH },
49 };
50 RegisterStrings(localized_strings, resources, arraysize(resources));
51
52 RegisterTitle(localized_strings,
53 "setPassphraseTitle",
54 IDS_SET_PASSPHRASE_TITLE);
55 }
56
57 void ManagedUserPassphraseHandler::SetLocalPassphrase(
58 const base::ListValue* args) {
59 std::string passphrase;
60 args->GetString(0, &passphrase);
61 ManagedUserPassphrase passphrase_key_generator((std::string()));
62 std::string encoded_passphrase_hash;
63 bool success = passphrase_key_generator.GenerateHashFromPassphrase(
64 passphrase,
65 &encoded_passphrase_hash);
66 if (success) {
67 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
68 pref_service->SetString(prefs::kManagedModeLocalPassphrase,
69 encoded_passphrase_hash);
70 pref_service->SetString(prefs::kManagedModeLocalSalt,
71 passphrase_key_generator.GetSalt());
72 }
73 // TODO(akuegel): Give failure back to the UI.
74 }
75
76 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698