| 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" |
| 11 #include "chrome/browser/extensions/event_router.h" | 11 #include "chrome/browser/extensions/event_router.h" |
| 12 #include "chrome/browser/extensions/extension_prefs.h" | 12 #include "chrome/browser/extensions/extension_prefs.h" |
| 13 #include "chrome/browser/extensions/extension_system.h" | 13 #include "chrome/browser/extensions/extension_system.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/common/extensions/api/permissions.h" | 16 #include "chrome/common/extensions/api/permissions.h" |
| 17 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 18 #include "chrome/common/extensions/extension_messages.h" | 18 #include "chrome/common/extensions/extension_messages.h" |
| 19 #include "chrome/common/extensions/permissions/permissions_data.h" |
| 19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
| 20 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
| 21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 23 | 24 |
| 24 using content::RenderProcessHost; | 25 using content::RenderProcessHost; |
| 25 using extensions::permissions_api_helpers::PackPermissionSet; | 26 using extensions::permissions_api_helpers::PackPermissionSet; |
| 26 using extensions::PermissionSet; | |
| 27 | 27 |
| 28 namespace extensions { | 28 namespace extensions { |
| 29 | 29 |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 const char kOnAdded[] = "permissions.onAdded"; | 32 const char kOnAdded[] = "permissions.onAdded"; |
| 33 const char kOnRemoved[] = "permissions.onRemoved"; | 33 const char kOnRemoved[] = "permissions.onRemoved"; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return; | 83 return; |
| 84 | 84 |
| 85 ExtensionPrefs::Get(profile_)->AddGrantedPermissions( | 85 ExtensionPrefs::Get(profile_)->AddGrantedPermissions( |
| 86 extension->id(), extension->GetActivePermissions()); | 86 extension->id(), extension->GetActivePermissions()); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void PermissionsUpdater::UpdateActivePermissions( | 89 void PermissionsUpdater::UpdateActivePermissions( |
| 90 const Extension* extension, const PermissionSet* permissions) { | 90 const Extension* extension, const PermissionSet* permissions) { |
| 91 ExtensionPrefs::Get(profile_)->SetActivePermissions( | 91 ExtensionPrefs::Get(profile_)->SetActivePermissions( |
| 92 extension->id(), permissions); | 92 extension->id(), permissions); |
| 93 extension->SetActivePermissions(permissions); | 93 PermissionsData::SetActivePermissions(extension, permissions); |
| 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 |
| (...skipping 46 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 |