| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 ExtensionPrefs::Get(profile_)->AddGrantedPermissions( | 79 ExtensionPrefs::Get(profile_)->AddGrantedPermissions( |
| 80 extension->id(), extension->GetActivePermissions().get()); | 80 extension->id(), extension->GetActivePermissions().get()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void PermissionsUpdater::UpdateActivePermissions( | 83 void PermissionsUpdater::UpdateActivePermissions( |
| 84 const Extension* extension, const PermissionSet* permissions) { | 84 const Extension* extension, const PermissionSet* permissions) { |
| 85 ExtensionPrefs::Get(profile_)->SetActivePermissions( | 85 ExtensionPrefs::Get(profile_)->SetActivePermissions( |
| 86 extension->id(), permissions); | 86 extension->id(), permissions); |
| 87 PermissionsData::ForExtension(extension)->SetActivePermissions(permissions); | 87 extension->permissions_data()->SetActivePermissions(permissions); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void PermissionsUpdater::DispatchEvent( | 90 void PermissionsUpdater::DispatchEvent( |
| 91 const std::string& extension_id, | 91 const std::string& extension_id, |
| 92 const char* event_name, | 92 const char* event_name, |
| 93 const PermissionSet* changed_permissions) { | 93 const PermissionSet* changed_permissions) { |
| 94 if (!profile_ || !EventRouter::Get(profile_)) | 94 if (!profile_ || !EventRouter::Get(profile_)) |
| 95 return; | 95 return; |
| 96 | 96 |
| 97 scoped_ptr<base::ListValue> value(new base::ListValue()); | 97 scoped_ptr<base::ListValue> value(new base::ListValue()); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 info.scriptable_hosts = changed->scriptable_hosts(); | 146 info.scriptable_hosts = changed->scriptable_hosts(); |
| 147 host->Send(new ExtensionMsg_UpdatePermissions(info)); | 147 host->Send(new ExtensionMsg_UpdatePermissions(info)); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 // Trigger the onAdded and onRemoved events in the extension. | 151 // Trigger the onAdded and onRemoved events in the extension. |
| 152 DispatchEvent(extension->id(), event_name, changed); | 152 DispatchEvent(extension->id(), event_name, changed); |
| 153 } | 153 } |
| 154 | 154 |
| 155 } // namespace extensions | 155 } // namespace extensions |
| OLD | NEW |