| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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/ui/webui/options/managed_user_passphrase_handler.h" | 5 #include "chrome/browser/ui/webui/options/managed_user_passphrase_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 103 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 104 base::FundamentalValue is_passphrase_set(!pref_service->GetString( | 104 base::FundamentalValue is_passphrase_set(!pref_service->GetString( |
| 105 prefs::kManagedModeLocalPassphrase).empty()); | 105 prefs::kManagedModeLocalPassphrase).empty()); |
| 106 web_ui()->CallJavascriptFunction(callback_function_name, | 106 web_ui()->CallJavascriptFunction(callback_function_name, |
| 107 is_passphrase_set); | 107 is_passphrase_set); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ManagedUserPassphraseHandler::ResetPassphrase( | 110 void ManagedUserPassphraseHandler::ResetPassphrase( |
| 111 const base::ListValue* args) { | 111 const base::ListValue* args) { |
| 112 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 112 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 113 pref_service->SetString(prefs::kManagedModeLocalPassphrase, ""); | 113 pref_service->SetString(prefs::kManagedModeLocalPassphrase, std::string()); |
| 114 pref_service->SetString(prefs::kManagedModeLocalSalt, ""); | 114 pref_service->SetString(prefs::kManagedModeLocalSalt, std::string()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ManagedUserPassphraseHandler::SetLocalPassphrase( | 117 void ManagedUserPassphraseHandler::SetLocalPassphrase( |
| 118 const base::ListValue* args) { | 118 const base::ListValue* args) { |
| 119 // Only change the passphrase if the custodian is authenticated. | 119 // Only change the passphrase if the custodian is authenticated. |
| 120 if (!ManagedModeNavigationObserver::FromWebContents( | 120 if (!ManagedModeNavigationObserver::FromWebContents( |
| 121 web_ui()->GetWebContents())->is_elevated()) | 121 web_ui()->GetWebContents())->is_elevated()) |
| 122 return; | 122 return; |
| 123 | 123 |
| 124 std::string passphrase; | 124 std::string passphrase; |
| 125 args->GetString(0, &passphrase); | 125 args->GetString(0, &passphrase); |
| 126 ManagedUserPassphrase passphrase_key_generator((std::string())); | 126 ManagedUserPassphrase passphrase_key_generator((std::string())); |
| 127 std::string encoded_passphrase_hash; | 127 std::string encoded_passphrase_hash; |
| 128 bool success = passphrase_key_generator.GenerateHashFromPassphrase( | 128 bool success = passphrase_key_generator.GenerateHashFromPassphrase( |
| 129 passphrase, | 129 passphrase, |
| 130 &encoded_passphrase_hash); | 130 &encoded_passphrase_hash); |
| 131 if (success) { | 131 if (success) { |
| 132 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 132 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 133 pref_service->SetString(prefs::kManagedModeLocalPassphrase, | 133 pref_service->SetString(prefs::kManagedModeLocalPassphrase, |
| 134 encoded_passphrase_hash); | 134 encoded_passphrase_hash); |
| 135 pref_service->SetString(prefs::kManagedModeLocalSalt, | 135 pref_service->SetString(prefs::kManagedModeLocalSalt, |
| 136 passphrase_key_generator.GetSalt()); | 136 passphrase_key_generator.GetSalt()); |
| 137 } | 137 } |
| 138 // TODO(akuegel): Give failure back to the UI. | 138 // TODO(akuegel): Give failure back to the UI. |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace options | 141 } // namespace options |
| OLD | NEW |