| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void PermissionsUpdater::DispatchEvent( | 166 void PermissionsUpdater::DispatchEvent( |
| 167 const std::string& extension_id, | 167 const std::string& extension_id, |
| 168 const char* event_name, | 168 const char* event_name, |
| 169 const PermissionSet* changed_permissions) { | 169 const PermissionSet* changed_permissions) { |
| 170 if (!profile_ || | 170 if (!profile_ || |
| 171 !extensions::ExtensionSystem::Get(profile_)->event_router()) | 171 !extensions::ExtensionSystem::Get(profile_)->event_router()) |
| 172 return; | 172 return; |
| 173 | 173 |
| 174 scoped_ptr<ListValue> value(new ListValue()); | 174 scoped_ptr<ListValue> value(new ListValue()); |
| 175 scoped_ptr<api::permissions::Permissions> permissions = | 175 scoped_ptr<api::permissions::Permissions> permissions = |
| 176 PackPermissionSet(changed_permissions); | 176 PackPermissionSet(changed_permissions); |
| 177 value->Append(permissions->ToValue().release()); | 177 value->Append(permissions->ToValue().release()); |
| 178 extensions::ExtensionSystem::Get(profile_)->event_router()-> | 178 scoped_ptr<Event> event(new Event(event_name, value.Pass())); |
| 179 DispatchEventToExtension(extension_id, event_name, value.Pass(), | 179 event->restrict_to_profile = profile_; |
| 180 profile_, GURL()); | 180 ExtensionSystem::Get(profile_)->event_router()-> |
| 181 DispatchEventToExtension(extension_id, event.Pass()); |
| 181 } | 182 } |
| 182 | 183 |
| 183 void PermissionsUpdater::NotifyPermissionsUpdated( | 184 void PermissionsUpdater::NotifyPermissionsUpdated( |
| 184 EventType event_type, | 185 EventType event_type, |
| 185 const Extension* extension, | 186 const Extension* extension, |
| 186 const PermissionSet* changed) { | 187 const PermissionSet* changed) { |
| 187 if (!changed || changed->IsEmpty()) | 188 if (!changed || changed->IsEmpty()) |
| 188 return; | 189 return; |
| 189 | 190 |
| 190 UpdatedExtensionPermissionsInfo::Reason reason; | 191 UpdatedExtensionPermissionsInfo::Reason reason; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // Trigger the onAdded and onRemoved events in the extension. | 225 // Trigger the onAdded and onRemoved events in the extension. |
| 225 DispatchEvent(extension->id(), event_name, changed); | 226 DispatchEvent(extension->id(), event_name, changed); |
| 226 } | 227 } |
| 227 | 228 |
| 228 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { | 229 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { |
| 229 return extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 230 return extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
| 230 extension_prefs(); | 231 extension_prefs(); |
| 231 } | 232 } |
| 232 | 233 |
| 233 } // namespace extensions | 234 } // namespace extensions |
| OLD | NEW |