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 #include "chrome/browser/extensions/permissions_updater.h" | 5 #include "chrome/browser/extensions/permissions_updater.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" | 10 #include "chrome/browser/extensions/api/permissions/permissions_api_helpers.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 | 95 |
96 void PermissionsUpdater::DispatchEvent( | 96 void PermissionsUpdater::DispatchEvent( |
97 const std::string& extension_id, | 97 const std::string& extension_id, |
98 const char* event_name, | 98 const char* event_name, |
99 const PermissionSet* changed_permissions) { | 99 const PermissionSet* changed_permissions) { |
100 if (!profile_ || | 100 if (!profile_ || |
101 !ExtensionSystem::Get(profile_)->event_router()) | 101 !ExtensionSystem::Get(profile_)->event_router()) |
102 return; | 102 return; |
103 | 103 |
104 scoped_ptr<ListValue> value(new ListValue()); | 104 scoped_ptr<base::ListValue> value(new base::ListValue()); |
105 scoped_ptr<api::permissions::Permissions> permissions = | 105 scoped_ptr<api::permissions::Permissions> permissions = |
106 PackPermissionSet(changed_permissions); | 106 PackPermissionSet(changed_permissions); |
107 value->Append(permissions->ToValue().release()); | 107 value->Append(permissions->ToValue().release()); |
108 scoped_ptr<Event> event(new Event(event_name, value.Pass())); | 108 scoped_ptr<Event> event(new Event(event_name, value.Pass())); |
109 event->restrict_to_profile = profile_; | 109 event->restrict_to_profile = profile_; |
110 ExtensionSystem::Get(profile_)->event_router()-> | 110 ExtensionSystem::Get(profile_)->event_router()-> |
111 DispatchEventToExtension(extension_id, event.Pass()); | 111 DispatchEventToExtension(extension_id, event.Pass()); |
112 } | 112 } |
113 | 113 |
114 void PermissionsUpdater::NotifyPermissionsUpdated( | 114 void PermissionsUpdater::NotifyPermissionsUpdated( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 changed->apis(), | 150 changed->apis(), |
151 changed->explicit_hosts(), | 151 changed->explicit_hosts(), |
152 changed->scriptable_hosts())); | 152 changed->scriptable_hosts())); |
153 } | 153 } |
154 | 154 |
155 // Trigger the onAdded and onRemoved events in the extension. | 155 // Trigger the onAdded and onRemoved events in the extension. |
156 DispatchEvent(extension->id(), event_name, changed); | 156 DispatchEvent(extension->id(), event_name, changed); |
157 } | 157 } |
158 | 158 |
159 } // namespace extensions | 159 } // namespace extensions |
OLD | NEW |