| 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/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 UpdatedExtensionPermissionsInfo info = UpdatedExtensionPermissionsInfo( | 301 UpdatedExtensionPermissionsInfo info = UpdatedExtensionPermissionsInfo( |
| 302 extension, changed, reason); | 302 extension, changed, reason); |
| 303 Profile* profile = Profile::FromBrowserContext(browser_context_); | 303 Profile* profile = Profile::FromBrowserContext(browser_context_); |
| 304 content::NotificationService::current()->Notify( | 304 content::NotificationService::current()->Notify( |
| 305 chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED, | 305 chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED, |
| 306 content::Source<Profile>(profile), | 306 content::Source<Profile>(profile), |
| 307 content::Details<UpdatedExtensionPermissionsInfo>(&info)); | 307 content::Details<UpdatedExtensionPermissionsInfo>(&info)); |
| 308 | 308 |
| 309 ExtensionMsg_UpdatePermissions_Params params; | 309 ExtensionMsg_UpdatePermissions_Params params; |
| 310 params.extension_id = extension->id(); | 310 params.extension_id = extension->id(); |
| 311 params.was_added = event_type == ADDED; |
| 311 params.active_permissions = ExtensionMsg_PermissionSetStruct( | 312 params.active_permissions = ExtensionMsg_PermissionSetStruct( |
| 312 extension->permissions_data()->active_permissions()); | 313 extension->permissions_data()->active_permissions()); |
| 313 params.withheld_permissions = ExtensionMsg_PermissionSetStruct( | 314 params.withheld_permissions = ExtensionMsg_PermissionSetStruct( |
| 314 extension->permissions_data()->withheld_permissions()); | 315 extension->permissions_data()->withheld_permissions()); |
| 315 | 316 |
| 316 // Send the new permissions to the renderers. | 317 // Send the new permissions to the renderers. |
| 317 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 318 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
| 318 !i.IsAtEnd(); i.Advance()) { | 319 !i.IsAtEnd(); i.Advance()) { |
| 319 RenderProcessHost* host = i.GetCurrentValue(); | 320 RenderProcessHost* host = i.GetCurrentValue(); |
| 320 if (profile->IsSameProfile( | 321 if (profile->IsSameProfile( |
| 321 Profile::FromBrowserContext(host->GetBrowserContext()))) { | 322 Profile::FromBrowserContext(host->GetBrowserContext()))) { |
| 322 host->Send(new ExtensionMsg_UpdatePermissions(params)); | 323 host->Send(new ExtensionMsg_UpdatePermissions(params)); |
| 323 } | 324 } |
| 324 } | 325 } |
| 325 | 326 |
| 326 // Trigger the onAdded and onRemoved events in the extension. | 327 // Trigger the onAdded and onRemoved events in the extension. |
| 327 DispatchEvent(extension->id(), event_name, changed); | 328 DispatchEvent(extension->id(), event_name, changed); |
| 328 } | 329 } |
| 329 | 330 |
| 330 } // namespace extensions | 331 } // namespace extensions |
| OLD | NEW |