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

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: Fixing memory leak in a test. Created 8 years, 4 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « chrome/browser/extensions/menu_manager_unittest.cc ('k') | chrome/browser/extensions/settings/settings_frontend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698