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" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 flow->FireAndForget(); | 130 flow->FireAndForget(); |
131 } | 131 } |
132 | 132 |
133 void PermissionsUpdater::DispatchEvent( | 133 void PermissionsUpdater::DispatchEvent( |
134 const std::string& extension_id, | 134 const std::string& extension_id, |
135 const char* event_name, | 135 const char* event_name, |
136 const PermissionSet* changed_permissions) { | 136 const PermissionSet* changed_permissions) { |
137 if (!profile_ || !profile_->GetExtensionEventRouter()) | 137 if (!profile_ || !profile_->GetExtensionEventRouter()) |
138 return; | 138 return; |
139 | 139 |
140 ListValue value; | 140 ListValue* value = new ListValue(); |
141 scoped_ptr<api::permissions::Permissions> permissions = | 141 scoped_ptr<api::permissions::Permissions> permissions = |
142 PackPermissionSet(changed_permissions); | 142 PackPermissionSet(changed_permissions); |
143 value.Append(permissions->ToValue().release()); | 143 value->Append(permissions->ToValue().release()); |
144 std::string json_value; | |
145 base::JSONWriter::Write(&value, &json_value); | |
146 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 144 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
147 extension_id, event_name, json_value, profile_, GURL()); | 145 extension_id, event_name, value, profile_, GURL()); |
148 } | 146 } |
149 | 147 |
150 void PermissionsUpdater::NotifyPermissionsUpdated( | 148 void PermissionsUpdater::NotifyPermissionsUpdated( |
151 EventType event_type, | 149 EventType event_type, |
152 const Extension* extension, | 150 const Extension* extension, |
153 const PermissionSet* changed) { | 151 const PermissionSet* changed) { |
154 if (!changed || changed->IsEmpty()) | 152 if (!changed || changed->IsEmpty()) |
155 return; | 153 return; |
156 | 154 |
157 UpdatedExtensionPermissionsInfo::Reason reason; | 155 UpdatedExtensionPermissionsInfo::Reason reason; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 188 |
191 // Trigger the onAdded and onRemoved events in the extension. | 189 // Trigger the onAdded and onRemoved events in the extension. |
192 DispatchEvent(extension->id(), event_name, changed); | 190 DispatchEvent(extension->id(), event_name, changed); |
193 } | 191 } |
194 | 192 |
195 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { | 193 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { |
196 return profile_->GetExtensionService()->extension_prefs(); | 194 return profile_->GetExtensionService()->extension_prefs(); |
197 } | 195 } |
198 | 196 |
199 } // namespace extensions | 197 } // namespace extensions |
OLD | NEW |