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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 CHECK_EQ(ADDED, event_type); | 295 CHECK_EQ(ADDED, event_type); |
296 reason = UpdatedExtensionPermissionsInfo::ADDED; | 296 reason = UpdatedExtensionPermissionsInfo::ADDED; |
297 event_name = permissions::OnAdded::kEventName; | 297 event_name = permissions::OnAdded::kEventName; |
298 } | 298 } |
299 | 299 |
300 // Notify other APIs or interested parties. | 300 // Notify other APIs or interested parties. |
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 extensions::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.active_permissions = ExtensionMsg_PermissionSetStruct( | 311 params.active_permissions = ExtensionMsg_PermissionSetStruct( |
312 extension->permissions_data()->active_permissions()); | 312 extension->permissions_data()->active_permissions()); |
313 params.withheld_permissions = ExtensionMsg_PermissionSetStruct( | 313 params.withheld_permissions = ExtensionMsg_PermissionSetStruct( |
314 extension->permissions_data()->withheld_permissions()); | 314 extension->permissions_data()->withheld_permissions()); |
315 | 315 |
316 // Send the new permissions to the renderers. | 316 // Send the new permissions to the renderers. |
317 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 317 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
318 !i.IsAtEnd(); i.Advance()) { | 318 !i.IsAtEnd(); i.Advance()) { |
319 RenderProcessHost* host = i.GetCurrentValue(); | 319 RenderProcessHost* host = i.GetCurrentValue(); |
320 if (profile->IsSameProfile( | 320 if (profile->IsSameProfile( |
321 Profile::FromBrowserContext(host->GetBrowserContext()))) { | 321 Profile::FromBrowserContext(host->GetBrowserContext()))) { |
322 host->Send(new ExtensionMsg_UpdatePermissions(params)); | 322 host->Send(new ExtensionMsg_UpdatePermissions(params)); |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 // Trigger the onAdded and onRemoved events in the extension. | 326 // Trigger the onAdded and onRemoved events in the extension. |
327 DispatchEvent(extension->id(), event_name, changed); | 327 DispatchEvent(extension->id(), event_name, changed); |
328 } | 328 } |
329 | 329 |
330 } // namespace extensions | 330 } // namespace extensions |
OLD | NEW |