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