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

Unified Diff: chrome/browser/extensions/extension_managed_mode_api.cc

Issue 9566007: Initial Managed Mode extension API, supporting querying the setting and a stub for enabling the mod… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Addressing Bernhard's comments Created 8 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698