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

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

Issue 7695003: Fix issue with permissions extension API event listeners. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/permissions/optional/background.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_permissions_api.h" 5 #include "chrome/browser/extensions/extension_permissions_api.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/extension_event_router.h" 9 #include "chrome/browser/extensions/extension_event_router.h"
10 #include "chrome/browser/extensions/extension_permissions_api_constants.h" 10 #include "chrome/browser/extensions/extension_permissions_api_constants.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 195
196 // Notify other APIs or interested parties. 196 // Notify other APIs or interested parties.
197 UpdatedExtensionPermissionsInfo info = UpdatedExtensionPermissionsInfo( 197 UpdatedExtensionPermissionsInfo info = UpdatedExtensionPermissionsInfo(
198 extension, changed, reason); 198 extension, changed, reason);
199 NotificationService::current()->Notify( 199 NotificationService::current()->Notify(
200 chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED, 200 chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED,
201 Source<Profile>(extension_service_->profile()), 201 Source<Profile>(extension_service_->profile()),
202 Details<UpdatedExtensionPermissionsInfo>(&info)); 202 Details<UpdatedExtensionPermissionsInfo>(&info));
203 203
204 // Trigger the onAdded and onRemoved events in the extension.
205 DispatchEvent(extension->id(), event_name, changed);
206
207 // Send the new permissions to the renderers. 204 // Send the new permissions to the renderers.
208 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); 205 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
209 !i.IsAtEnd(); i.Advance()) { 206 !i.IsAtEnd(); i.Advance()) {
210 RenderProcessHost* host = i.GetCurrentValue(); 207 RenderProcessHost* host = i.GetCurrentValue();
211 Profile* profile = Profile::FromBrowserContext(host->browser_context()); 208 Profile* profile = Profile::FromBrowserContext(host->browser_context());
212 if (extension_service_->profile()->IsSameProfile(profile)) 209 if (extension_service_->profile()->IsSameProfile(profile))
213 host->Send(new ExtensionMsg_UpdatePermissions( 210 host->Send(new ExtensionMsg_UpdatePermissions(
214 static_cast<int>(reason), 211 static_cast<int>(reason),
215 extension->id(), 212 extension->id(),
216 changed->apis(), 213 changed->apis(),
217 changed->explicit_hosts(), 214 changed->explicit_hosts(),
218 changed->scriptable_hosts())); 215 changed->scriptable_hosts()));
219 } 216 }
217
218 // Trigger the onAdded and onRemoved events in the extension.
219 DispatchEvent(extension->id(), event_name, changed);
220 } 220 }
221 221
222 bool ContainsPermissionsFunction::RunImpl() { 222 bool ContainsPermissionsFunction::RunImpl() {
223 DictionaryValue* args = NULL; 223 DictionaryValue* args = NULL;
224 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args)); 224 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0, &args));
225 std::string error; 225 std::string error;
226 if (!args) 226 if (!args)
227 return false; 227 return false;
228 228
229 scoped_refptr<ExtensionPermissionSet> permissions; 229 scoped_refptr<ExtensionPermissionSet> permissions;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 382
383 void RequestPermissionsFunction::InstallUIAbort(bool user_initiated) { 383 void RequestPermissionsFunction::InstallUIAbort(bool user_initiated) {
384 install_ui_.reset(); 384 install_ui_.reset();
385 result_.reset(Value::CreateBooleanValue(false)); 385 result_.reset(Value::CreateBooleanValue(false));
386 requested_permissions_ = NULL; 386 requested_permissions_ = NULL;
387 387
388 SendResponse(true); 388 SendResponse(true);
389 Release(); 389 Release();
390 } 390 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/permissions/optional/background.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698