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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 flow->FireAndForget(); | 110 flow->FireAndForget(); |
111 } | 111 } |
112 | 112 |
113 void PermissionsUpdater::DispatchEvent( | 113 void PermissionsUpdater::DispatchEvent( |
114 const std::string& extension_id, | 114 const std::string& extension_id, |
115 const char* event_name, | 115 const char* event_name, |
116 const PermissionSet* changed_permissions) { | 116 const PermissionSet* changed_permissions) { |
117 if (!profile_ || !profile_->GetExtensionEventRouter()) | 117 if (!profile_ || !profile_->GetExtensionEventRouter()) |
118 return; | 118 return; |
119 | 119 |
120 ListValue value; | 120 scoped_ptr<ListValue> value(new ListValue()); |
121 scoped_ptr<api::permissions::Permissions> permissions = | 121 scoped_ptr<api::permissions::Permissions> permissions = |
122 PackPermissionSet(changed_permissions); | 122 PackPermissionSet(changed_permissions); |
123 value.Append(permissions->ToValue().release()); | 123 value->Append(permissions->ToValue().release()); |
124 std::string json_value; | |
125 base::JSONWriter::Write(&value, &json_value); | |
126 profile_->GetExtensionEventRouter()->DispatchEventToExtension( | 124 profile_->GetExtensionEventRouter()->DispatchEventToExtension( |
127 extension_id, event_name, json_value, profile_, GURL()); | 125 extension_id, event_name, value.Pass(), profile_, GURL()); |
128 } | 126 } |
129 | 127 |
130 void PermissionsUpdater::NotifyPermissionsUpdated( | 128 void PermissionsUpdater::NotifyPermissionsUpdated( |
131 EventType event_type, | 129 EventType event_type, |
132 const Extension* extension, | 130 const Extension* extension, |
133 const PermissionSet* changed) { | 131 const PermissionSet* changed) { |
134 if (!changed || changed->IsEmpty()) | 132 if (!changed || changed->IsEmpty()) |
135 return; | 133 return; |
136 | 134 |
137 UpdatedExtensionPermissionsInfo::Reason reason; | 135 UpdatedExtensionPermissionsInfo::Reason reason; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 168 |
171 // Trigger the onAdded and onRemoved events in the extension. | 169 // Trigger the onAdded and onRemoved events in the extension. |
172 DispatchEvent(extension->id(), event_name, changed); | 170 DispatchEvent(extension->id(), event_name, changed); |
173 } | 171 } |
174 | 172 |
175 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { | 173 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { |
176 return profile_->GetExtensionService()->extension_prefs(); | 174 return profile_->GetExtensionService()->extension_prefs(); |
177 } | 175 } |
178 | 176 |
179 } // namespace extensions | 177 } // namespace extensions |
OLD | NEW |