| Index: chrome/browser/extensions/extension_managed_mode_api.cc
|
| ===================================================================
|
| --- chrome/browser/extensions/extension_managed_mode_api.cc (revision 0)
|
| +++ chrome/browser/extensions/extension_managed_mode_api.cc (revision 0)
|
| @@ -0,0 +1,64 @@
|
| +// 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 enable managed mode succeeded.
|
| +const char kEnableSuccessKey[] = "success";
|
| +
|
| +} // namespace
|
| +
|
| +namespace keys = extension_preference_api_constants;
|
| +
|
| +GetManagedModeFunction::~GetManagedModeFunction() { }
|
| +
|
| +bool GetManagedModeFunction::RunImpl() {
|
| + PrefService* local_state = g_browser_process->local_state();
|
| + bool enabled = local_state->GetBoolean(prefs::kInManagedMode);
|
| +
|
| + // Since only one managed-mode extension can be active at a time, this
|
| + // extension can control the value iff it is not currently enabled.
|
| + // (This will need to be fixed if we ever have a policy or command-line
|
| + // switch to prohibit managed mode.)
|
| + std::string level_of_control = enabled ? keys::kNotControllable
|
| + : keys::kControllableByThisExtension;
|
| +
|
| + scoped_ptr<DictionaryValue> result(new DictionaryValue);
|
| + result->SetBoolean(keys::kValue, enabled);
|
| + result->SetString(keys::kLevelOfControl, level_of_control);
|
| + result_.reset(result.release());
|
| + return true;
|
| +}
|
| +
|
| +EnableManagedModeFunction::~EnableManagedModeFunction() { }
|
| +
|
| +bool EnableManagedModeFunction::RunImpl() {
|
| + PrefService* local_state = g_browser_process->local_state();
|
| + bool enabled = local_state->GetBoolean(prefs::kInManagedMode);
|
| +
|
| + bool confirmed = true;
|
| + if (!enabled) {
|
| + // TODO(pamg): WIP. Show modal password dialog and save hashed password. Set
|
| + // callback_result to false if user cancels dialog.
|
| +
|
| + if (confirmed)
|
| + local_state->SetBoolean(prefs::kInManagedMode, true);
|
| + }
|
| +
|
| + scoped_ptr<DictionaryValue> result(new DictionaryValue);
|
| + result->SetBoolean(kEnableSuccessKey, confirmed);
|
| + result_.reset(result.release());
|
| + return true;
|
| +}
|
|
|
| Property changes on: chrome\browser\extensions\extension_managed_mode_api.cc
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|