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