| 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 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 void ExtensionManagedModeEventRouter::Observe( | 52 void ExtensionManagedModeEventRouter::Observe( |
| 53 int type, | 53 int type, |
| 54 const content::NotificationSource& source, | 54 const content::NotificationSource& source, |
| 55 const content::NotificationDetails& details) { | 55 const content::NotificationDetails& details) { |
| 56 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); | 56 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); |
| 57 const std::string& pref_name = | 57 const std::string& pref_name = |
| 58 *content::Details<std::string>(details).ptr(); | 58 *content::Details<std::string>(details).ptr(); |
| 59 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name); | 59 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name); |
| 60 | 60 |
| 61 ListValue args; | |
| 62 DictionaryValue* dict = new DictionaryValue(); | 61 DictionaryValue* dict = new DictionaryValue(); |
| 63 args.Append(dict); | |
| 64 dict->SetBoolean(extension_preference_api_constants::kValue, | 62 dict->SetBoolean(extension_preference_api_constants::kValue, |
| 65 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); | 63 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); |
| 66 std::string json_args; | 64 ListValue* arguments = new ListValue(); |
| 67 base::JSONWriter::Write(&args, &json_args); | 65 arguments->Set(0, dict); |
| 66 |
| 68 ExtensionEventRouter* event_router = profile_->GetExtensionEventRouter(); | 67 ExtensionEventRouter* event_router = profile_->GetExtensionEventRouter(); |
| 69 event_router->DispatchEventToRenderers(kChangeEventName, json_args, NULL, | 68 event_router->DispatchEventToRenderers(kChangeEventName, arguments, NULL, |
| 70 GURL(), | 69 GURL(), |
| 71 extensions::EventFilteringInfo()); | 70 extensions::EventFilteringInfo()); |
| 72 } | 71 } |
| 73 | 72 |
| 74 GetManagedModeFunction::~GetManagedModeFunction() { } | 73 GetManagedModeFunction::~GetManagedModeFunction() { } |
| 75 | 74 |
| 76 bool GetManagedModeFunction::RunImpl() { | 75 bool GetManagedModeFunction::RunImpl() { |
| 77 bool in_managed_mode = ManagedMode::IsInManagedMode(); | 76 bool in_managed_mode = ManagedMode::IsInManagedMode(); |
| 78 | 77 |
| 79 scoped_ptr<DictionaryValue> result(new DictionaryValue); | 78 scoped_ptr<DictionaryValue> result(new DictionaryValue); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key)); | 119 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &key)); |
| 121 base::Value* value = NULL; | 120 base::Value* value = NULL; |
| 122 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); | 121 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); |
| 123 #if defined(ENABLE_CONFIGURATION_POLICY) | 122 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 124 policy::ManagedModePolicyProvider* policy_provider = | 123 policy::ManagedModePolicyProvider* policy_provider = |
| 125 ManagedModePolicyProviderFactory::GetForProfile(profile_); | 124 ManagedModePolicyProviderFactory::GetForProfile(profile_); |
| 126 policy_provider->SetPolicy(key, value); | 125 policy_provider->SetPolicy(key, value); |
| 127 #endif | 126 #endif |
| 128 return true; | 127 return true; |
| 129 } | 128 } |
| OLD | NEW |