| 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 const char* event_name, | 333 const char* event_name, |
| 334 const PermissionSet* changed_permissions) { | 334 const PermissionSet* changed_permissions) { |
| 335 EventRouter* event_router = EventRouter::Get(browser_context_); | 335 EventRouter* event_router = EventRouter::Get(browser_context_); |
| 336 if (!event_router) | 336 if (!event_router) |
| 337 return; | 337 return; |
| 338 | 338 |
| 339 scoped_ptr<base::ListValue> value(new base::ListValue()); | 339 scoped_ptr<base::ListValue> value(new base::ListValue()); |
| 340 scoped_ptr<api::permissions::Permissions> permissions = | 340 scoped_ptr<api::permissions::Permissions> permissions = |
| 341 PackPermissionSet(changed_permissions); | 341 PackPermissionSet(changed_permissions); |
| 342 value->Append(permissions->ToValue().release()); | 342 value->Append(permissions->ToValue().release()); |
| 343 scoped_ptr<Event> event(new Event(event_name, value.Pass())); | 343 scoped_ptr<Event> event(new Event(events::UNKNOWN, event_name, value.Pass())); |
| 344 event->restrict_to_browser_context = browser_context_; | 344 event->restrict_to_browser_context = browser_context_; |
| 345 event_router->DispatchEventToExtension(extension_id, event.Pass()); | 345 event_router->DispatchEventToExtension(extension_id, event.Pass()); |
| 346 } | 346 } |
| 347 | 347 |
| 348 void PermissionsUpdater::NotifyPermissionsUpdated( | 348 void PermissionsUpdater::NotifyPermissionsUpdated( |
| 349 EventType event_type, | 349 EventType event_type, |
| 350 const Extension* extension, | 350 const Extension* extension, |
| 351 const PermissionSet* changed) { | 351 const PermissionSet* changed) { |
| 352 DCHECK((init_flag_ & INIT_FLAG_TRANSIENT) == 0); | 352 DCHECK((init_flag_ & INIT_FLAG_TRANSIENT) == 0); |
| 353 if (!changed || changed->IsEmpty()) | 353 if (!changed || changed->IsEmpty()) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 Profile::FromBrowserContext(host->GetBrowserContext()))) { | 389 Profile::FromBrowserContext(host->GetBrowserContext()))) { |
| 390 host->Send(new ExtensionMsg_UpdatePermissions(params)); | 390 host->Send(new ExtensionMsg_UpdatePermissions(params)); |
| 391 } | 391 } |
| 392 } | 392 } |
| 393 | 393 |
| 394 // Trigger the onAdded and onRemoved events in the extension. | 394 // Trigger the onAdded and onRemoved events in the extension. |
| 395 DispatchEvent(extension->id(), event_name, changed); | 395 DispatchEvent(extension->id(), event_name, changed); |
| 396 } | 396 } |
| 397 | 397 |
| 398 } // namespace extensions | 398 } // namespace extensions |
| OLD | NEW |