Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Implementation of the Chrome Extensions Managed Mode API. | 5 // Implementation of the Chrome Extensions Managed Mode API. |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_managed_mode_api.h" | 7 #include "chrome/browser/extensions/extension_managed_mode_api.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/extensions/extension_event_router.h" | 14 #include "chrome/browser/extensions/extension_event_router.h" |
| 15 #include "chrome/browser/extensions/extension_preference_api_constants.h" | 15 #include "chrome/browser/extensions/extension_preference_api_constants.h" |
| 16 #include "chrome/browser/managed_mode.h" | 16 #include "chrome/browser/managed_mode.h" |
| 17 #include "chrome/browser/policy/managed_mode_policy_provider.h" | |
| 18 #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.
| |
| 17 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 21 #include "content/public/browser/notification_details.h" | 23 #include "content/public/browser/notification_details.h" |
| 22 | 24 |
| 23 namespace { | 25 namespace { |
| 24 | 26 |
| 25 // Event that is fired when we enter or leave managed mode. | 27 // Event that is fired when we enter or leave managed mode. |
| 26 const char kChangeEventName[] = "managedModePrivate.onChange"; | 28 const char kChangeEventName[] = "managedModePrivate.onChange"; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 base::Bind(&EnterManagedModeFunction::SendResult, this)); | 86 base::Bind(&EnterManagedModeFunction::SendResult, this)); |
| 85 return true; | 87 return true; |
| 86 } | 88 } |
| 87 | 89 |
| 88 void EnterManagedModeFunction::SendResult(bool success) { | 90 void EnterManagedModeFunction::SendResult(bool success) { |
| 89 scoped_ptr<DictionaryValue> result(new DictionaryValue); | 91 scoped_ptr<DictionaryValue> result(new DictionaryValue); |
| 90 result->SetBoolean(kEnterSuccessKey, success); | 92 result->SetBoolean(kEnterSuccessKey, success); |
| 91 result_.reset(result.release()); | 93 result_.reset(result.release()); |
| 92 SendResponse(true); | 94 SendResponse(true); |
| 93 } | 95 } |
| 96 | |
| 97 GetPolicyFunction::~GetPolicyFunction() { } | |
| 98 | |
| 99 bool GetPolicyFunction::RunImpl() { | |
| 100 std::string key; | |
| 101 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key)); | |
| 102 policy::ManagedModePolicyProvider* policy_provider = | |
| 103 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.
| |
| 104 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
| |
| 105 if (policy) | |
| 106 result_.reset(policy->DeepCopy()); | |
| 107 return true; | |
| 108 } | |
| 109 | |
| 110 SetPolicyFunction::~SetPolicyFunction() { } | |
| 111 | |
| 112 bool SetPolicyFunction::RunImpl() { | |
| 113 std::string key; | |
| 114 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key)); | |
| 115 base::Value* value = NULL; | |
| 116 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); | |
| 117 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.
| |
| 118 ManagedModePolicyProviderFactory::GetForProfile(profile_); | |
| 119 policy_provider->SetPolicy(key, value); | |
| 120 return true; | |
| 121 } | |
| OLD | NEW |