| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 void ExtensionManagedModeEventRouter::Init() { | 45 void ExtensionManagedModeEventRouter::Init() { |
| 46 registrar_.Init(g_browser_process->local_state()); | 46 registrar_.Init(g_browser_process->local_state()); |
| 47 registrar_.Add(prefs::kInManagedMode, this); | 47 registrar_.Add(prefs::kInManagedMode, this); |
| 48 } | 48 } |
| 49 | 49 |
| 50 ExtensionManagedModeEventRouter::~ExtensionManagedModeEventRouter() { | 50 ExtensionManagedModeEventRouter::~ExtensionManagedModeEventRouter() { |
| 51 } | 51 } |
| 52 | 52 |
| 53 void ExtensionManagedModeEventRouter::Observe( | 53 void ExtensionManagedModeEventRouter::OnPreferenceChanged( |
| 54 int type, | 54 PrefServiceBase* service, |
| 55 const content::NotificationSource& source, | 55 const std::string& pref_name) { |
| 56 const content::NotificationDetails& details) { | |
| 57 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); | |
| 58 const std::string& pref_name = | |
| 59 *content::Details<std::string>(details).ptr(); | |
| 60 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name); | 56 DCHECK_EQ(std::string(prefs::kInManagedMode), pref_name); |
| 61 | 57 |
| 62 DictionaryValue* dict = new DictionaryValue(); | 58 DictionaryValue* dict = new DictionaryValue(); |
| 63 dict->SetBoolean( | 59 dict->SetBoolean( |
| 64 keys::kValue, | 60 keys::kValue, |
| 65 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); | 61 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); |
| 66 scoped_ptr<ListValue> args(new ListValue()); | 62 scoped_ptr<ListValue> args(new ListValue()); |
| 67 args->Set(0, dict); | 63 args->Set(0, dict); |
| 68 | 64 |
| 69 extensions::EventRouter* event_router = profile_->GetExtensionEventRouter(); | 65 extensions::EventRouter* event_router = profile_->GetExtensionEventRouter(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); | 119 EXTENSION_FUNCTION_VALIDATE(args_->Get(1, &value)); |
| 124 #if defined(ENABLE_CONFIGURATION_POLICY) | 120 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 125 policy::ManagedModePolicyProvider* policy_provider = | 121 policy::ManagedModePolicyProvider* policy_provider = |
| 126 profile_->GetManagedModePolicyProvider(); | 122 profile_->GetManagedModePolicyProvider(); |
| 127 policy_provider->SetPolicy(key, value); | 123 policy_provider->SetPolicy(key, value); |
| 128 #endif | 124 #endif |
| 129 return true; | 125 return true; |
| 130 } | 126 } |
| 131 | 127 |
| 132 } // namespace extensions | 128 } // namespace extensions |
| OLD | NEW |