diff options
author | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-06 21:00:49 +0000 |
---|---|---|
committer | pam@chromium.org <pam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-06 21:00:49 +0000 |
commit | dcac1fecd5957b6ac16b57b24b3efbd1356a438b (patch) | |
tree | 9eab4b278c7e81ca5fcda105a356ee05717a2d12 /chrome/browser/extensions/extension_managed_mode_api.cc | |
parent | 330d5722d6efc69242e037eeeedf8c13a16fd57a (diff) | |
download | chromium_src-dcac1fecd5957b6ac16b57b24b3efbd1356a438b.zip chromium_src-dcac1fecd5957b6ac16b57b24b3efbd1356a438b.tar.gz chromium_src-dcac1fecd5957b6ac16b57b24b3efbd1356a438b.tar.bz2 |
Initial Managed Mode extension API, supporting querying the setting and a stub for enabling the mode.
BUG=115447, 115448
TEST=covered by automated tests (browser_tests --gtest_filter=ExtensionApiTest.ManagedMode*)
Review URL: http://codereview.chromium.org/9566007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@125218 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_managed_mode_api.cc')
-rw-r--r-- | chrome/browser/extensions/extension_managed_mode_api.cc | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_managed_mode_api.cc b/chrome/browser/extensions/extension_managed_mode_api.cc new file mode 100644 index 0000000..12da93d --- /dev/null +++ b/chrome/browser/extensions/extension_managed_mode_api.cc @@ -0,0 +1,56 @@ +// Copyright (c) 2012 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. + +// Implementation of the Chrome Extensions Managed Mode API. + +#include "chrome/browser/extensions/extension_managed_mode_api.h" + +#include <string> + +#include "chrome/browser/browser_process.h" +#include "chrome/browser/extensions/extension_preference_api_constants.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/common/pref_names.h" + +namespace { + +// Key to report whether the attempt to enter managed mode succeeded. +const char kEnterSuccessKey[] = "success"; + +} // namespace + +namespace keys = extension_preference_api_constants; + +GetManagedModeFunction::~GetManagedModeFunction() { } + +bool GetManagedModeFunction::RunImpl() { + PrefService* local_state = g_browser_process->local_state(); + bool in_managed_mode = local_state->GetBoolean(prefs::kInManagedMode); + + scoped_ptr<DictionaryValue> result(new DictionaryValue); + result->SetBoolean(keys::kValue, in_managed_mode); + result_.reset(result.release()); + return true; +} + +EnterManagedModeFunction::~EnterManagedModeFunction() { } + +bool EnterManagedModeFunction::RunImpl() { + PrefService* local_state = g_browser_process->local_state(); + bool in_managed_mode = local_state->GetBoolean(prefs::kInManagedMode); + + bool confirmed = true; + if (!in_managed_mode) { + // TODO(pamg): WIP. Show modal password dialog and save hashed password. Set + // |confirmed| to false if user cancels dialog. + + if (confirmed) + local_state->SetBoolean(prefs::kInManagedMode, true); + } + + scoped_ptr<DictionaryValue> result(new DictionaryValue); + result->SetBoolean(kEnterSuccessKey, confirmed); + result_.reset(result.release()); + return true; +} |