Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(674)

Side by Side Diff: chrome/browser/extensions/permissions_updater.cc

Issue 10694085: Refactor extension event distribution to use Values instead of JSON strings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix. Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698