Chromium Code Reviews| Index: chrome/browser/extensions/extension_managed_mode_api.cc |
| diff --git a/chrome/browser/extensions/extension_managed_mode_api.cc b/chrome/browser/extensions/extension_managed_mode_api.cc |
| index 0e747d5a75bba13f1b9415a747e251b284b8daab..c7194a8d91bf211866630ab6393d56a3aaaecbd2 100644 |
| --- a/chrome/browser/extensions/extension_managed_mode_api.cc |
| +++ b/chrome/browser/extensions/extension_managed_mode_api.cc |
| @@ -14,6 +14,8 @@ |
| #include "chrome/browser/extensions/extension_event_router.h" |
| #include "chrome/browser/extensions/extension_preference_api_constants.h" |
| #include "chrome/browser/managed_mode.h" |
| +#include "chrome/browser/policy/managed_mode_policy_provider.h" |
| +#include "chrome/browser/policy/managed_mode_policy_provider_factory.h" |
|
Joao da Silva
2012/06/06 16:36:38
#ifdef ENABLE_CONFIGURATION_POLICY
Bernhard Bauer
2012/06/08 10:06:44
Done.
|
| #include "chrome/browser/prefs/pref_service.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/common/chrome_notification_types.h" |
| @@ -91,3 +93,29 @@ void EnterManagedModeFunction::SendResult(bool success) { |
| result_.reset(result.release()); |
| SendResponse(true); |
| } |
| + |
| +GetPolicyFunction::~GetPolicyFunction() { } |
| + |
| +bool GetPolicyFunction::RunImpl() { |
| + std::string key; |
| + EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key)); |
| + policy::ManagedModePolicyProvider* policy_provider = |
| + ManagedModePolicyProviderFactory::GetForProfile(profile_); |
|
Joao da Silva
2012/06/06 16:36:38
#ifdef ENABLE_CONFIGURATION_POLICY
Bernhard Bauer
2012/06/08 10:06:44
Done.
|
| + const base::Value* policy = policy_provider->GetPolicy(key); |
|
Joao da Silva
2012/06/06 16:36:38
This only reads policies from the ManagedModePolic
Bernhard Bauer
2012/06/08 10:06:44
I think so. I don't want the extension to have to
|
| + if (policy) |
| + result_.reset(policy->DeepCopy()); |
| + return true; |
| +} |
| + |
| +SetPolicyFunction::~SetPolicyFunction() { } |
| + |
| +bool SetPolicyFunction::RunImpl() { |
| + std::string key; |
| + EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key)); |
| + base::Value* value = NULL; |
| + EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); |
| + policy::ManagedModePolicyProvider* policy_provider = |
|
Joao da Silva
2012/06/06 16:36:38
#ifdef ENABLE_CONFIGURATION_POLICY
Bernhard Bauer
2012/06/08 10:06:44
Done.
|
| + ManagedModePolicyProviderFactory::GetForProfile(profile_); |
| + policy_provider->SetPolicy(key, value); |
| + return true; |
| +} |