OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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 // Implementation of the Chrome Extensions Managed Mode API. |
| 6 |
| 7 #include "chrome/browser/extensions/extension_managed_mode_api.h" |
| 8 |
| 9 #include <string> |
| 10 |
| 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/extensions/extension_preference_api_constants.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/common/pref_names.h" |
| 15 |
| 16 namespace { |
| 17 |
| 18 // Key to report whether the attempt to enter managed mode succeeded. |
| 19 const char kEnterSuccessKey[] = "success"; |
| 20 |
| 21 } // namespace |
| 22 |
| 23 namespace keys = extension_preference_api_constants; |
| 24 |
| 25 GetManagedModeFunction::~GetManagedModeFunction() { } |
| 26 |
| 27 bool GetManagedModeFunction::RunImpl() { |
| 28 PrefService* local_state = g_browser_process->local_state(); |
| 29 bool in_managed_mode = local_state->GetBoolean(prefs::kInManagedMode); |
| 30 |
| 31 scoped_ptr<DictionaryValue> result(new DictionaryValue); |
| 32 result->SetBoolean(keys::kValue, in_managed_mode); |
| 33 result_.reset(result.release()); |
| 34 return true; |
| 35 } |
| 36 |
| 37 EnterManagedModeFunction::~EnterManagedModeFunction() { } |
| 38 |
| 39 bool EnterManagedModeFunction::RunImpl() { |
| 40 PrefService* local_state = g_browser_process->local_state(); |
| 41 bool in_managed_mode = local_state->GetBoolean(prefs::kInManagedMode); |
| 42 |
| 43 bool confirmed = true; |
| 44 if (!in_managed_mode) { |
| 45 // TODO(pamg): WIP. Show modal password dialog and save hashed password. Set |
| 46 // |confirmed| to false if user cancels dialog. |
| 47 |
| 48 if (confirmed) |
| 49 local_state->SetBoolean(prefs::kInManagedMode, true); |
| 50 } |
| 51 |
| 52 scoped_ptr<DictionaryValue> result(new DictionaryValue); |
| 53 result->SetBoolean(kEnterSuccessKey, confirmed); |
| 54 result_.reset(result.release()); |
| 55 return true; |
| 56 } |
OLD | NEW |