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/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
| 20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 21 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
| 22 | 22 |
| 23 #ifdef ENABLE_CONFIGURATION_POLICY | |
|
Joao da Silva
2012/06/08 10:30:58
#if defined(ENABLE_CONFIGURATION_POLICY) is the co
| |
| 24 #include "chrome/browser/policy/managed_mode_policy_provider.h" | |
| 25 #include "chrome/browser/policy/managed_mode_policy_provider_factory.h" | |
| 26 #endif | |
| 27 | |
| 23 namespace { | 28 namespace { |
| 24 | 29 |
| 25 // Event that is fired when we enter or leave managed mode. | 30 // Event that is fired when we enter or leave managed mode. |
| 26 const char kChangeEventName[] = "managedModePrivate.onChange"; | 31 const char kChangeEventName[] = "managedModePrivate.onChange"; |
| 27 | 32 |
| 28 // Key to report whether the attempt to enter managed mode succeeded. | 33 // Key to report whether the attempt to enter managed mode succeeded. |
| 29 const char kEnterSuccessKey[] = "success"; | 34 const char kEnterSuccessKey[] = "success"; |
| 30 | 35 |
| 31 } // namespace | 36 } // namespace |
| 32 | 37 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 base::Bind(&EnterManagedModeFunction::SendResult, this)); | 89 base::Bind(&EnterManagedModeFunction::SendResult, this)); |
| 85 return true; | 90 return true; |
| 86 } | 91 } |
| 87 | 92 |
| 88 void EnterManagedModeFunction::SendResult(bool success) { | 93 void EnterManagedModeFunction::SendResult(bool success) { |
| 89 scoped_ptr<DictionaryValue> result(new DictionaryValue); | 94 scoped_ptr<DictionaryValue> result(new DictionaryValue); |
| 90 result->SetBoolean(kEnterSuccessKey, success); | 95 result->SetBoolean(kEnterSuccessKey, success); |
| 91 result_.reset(result.release()); | 96 result_.reset(result.release()); |
| 92 SendResponse(true); | 97 SendResponse(true); |
| 93 } | 98 } |
| 99 | |
| 100 GetPolicyFunction::~GetPolicyFunction() { } | |
| 101 | |
| 102 bool GetPolicyFunction::RunImpl() { | |
| 103 std::string key; | |
| 104 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key)); | |
| 105 #ifdef ENABLE_CONFIGURATION_POLICY | |
|
Joao da Silva
2012/06/08 10:30:58
#if defined()
| |
| 106 policy::ManagedModePolicyProvider* policy_provider = | |
| 107 ManagedModePolicyProviderFactory::GetForProfile(profile_); | |
| 108 const base::Value* policy = policy_provider->GetPolicy(key); | |
| 109 if (policy) | |
| 110 result_.reset(policy->DeepCopy()); | |
| 111 #endif | |
| 112 return true; | |
| 113 } | |
| 114 | |
| 115 SetPolicyFunction::~SetPolicyFunction() { } | |
| 116 | |
| 117 bool SetPolicyFunction::RunImpl() { | |
| 118 std::string key; | |
| 119 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key)); | |
| 120 base::Value* value = NULL; | |
| 121 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); | |
| 122 #ifdef ENABLE_CONFIGURATION_POLICY | |
|
Joao da Silva
2012/06/08 10:30:58
#if defined()
| |
| 123 policy::ManagedModePolicyProvider* policy_provider = | |
| 124 ManagedModePolicyProviderFactory::GetForProfile(profile_); | |
| 125 policy_provider->SetPolicy(key, value); | |
| 126 #endif | |
| 127 return true; | |
| 128 } | |
| OLD | NEW |