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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 void ManagedModeEventRouter::OnInManagedModeChanged() { | 54 void ManagedModeEventRouter::OnInManagedModeChanged() { |
55 DictionaryValue* dict = new DictionaryValue(); | 55 DictionaryValue* dict = new DictionaryValue(); |
56 dict->SetBoolean( | 56 dict->SetBoolean( |
57 keys::kValue, | 57 keys::kValue, |
58 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); | 58 g_browser_process->local_state()->GetBoolean(prefs::kInManagedMode)); |
59 scoped_ptr<ListValue> args(new ListValue()); | 59 scoped_ptr<ListValue> args(new ListValue()); |
60 args->Set(0, dict); | 60 args->Set(0, dict); |
61 | 61 |
62 extensions::EventRouter* event_router = | 62 extensions::EventRouter* event_router = |
63 extensions::ExtensionSystem::Get(profile_)->event_router(); | 63 extensions::ExtensionSystem::Get(profile_)->event_router(); |
64 event_router->DispatchEventToRenderers(kChangeEventName, args.Pass(), NULL, | 64 scoped_ptr<extensions::Event> event(new extensions::Event( |
65 GURL(), | 65 kChangeEventName, args.Pass())); |
66 extensions::EventFilteringInfo()); | 66 event_router->BroadcastEvent(event.Pass()); |
67 } | 67 } |
68 | 68 |
69 GetManagedModeFunction::~GetManagedModeFunction() { } | 69 GetManagedModeFunction::~GetManagedModeFunction() { } |
70 | 70 |
71 bool GetManagedModeFunction::RunImpl() { | 71 bool GetManagedModeFunction::RunImpl() { |
72 bool in_managed_mode = ManagedMode::IsInManagedMode(); | 72 bool in_managed_mode = ManagedMode::IsInManagedMode(); |
73 | 73 |
74 scoped_ptr<DictionaryValue> result(new DictionaryValue); | 74 scoped_ptr<DictionaryValue> result(new DictionaryValue); |
75 result->SetBoolean(keys::kValue, in_managed_mode); | 75 result->SetBoolean(keys::kValue, in_managed_mode); |
76 SetResult(result.release()); | 76 SetResult(result.release()); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 136 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
137 } | 137 } |
138 | 138 |
139 void ManagedModeAPI::OnListenerAdded( | 139 void ManagedModeAPI::OnListenerAdded( |
140 const extensions::EventListenerInfo& details) { | 140 const extensions::EventListenerInfo& details) { |
141 managed_mode_event_router_.reset(new ManagedModeEventRouter(profile_)); | 141 managed_mode_event_router_.reset(new ManagedModeEventRouter(profile_)); |
142 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); | 142 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); |
143 } | 143 } |
144 | 144 |
145 } // namespace extensions | 145 } // namespace extensions |
OLD | NEW |