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

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

Issue 510313002: Extensions-related fixups for scoped_refptr conversion operator removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
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/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 scoped_refptr<const PermissionSet> required_permissions = 70 scoped_refptr<const PermissionSet> required_permissions =
71 PermissionsParser::GetRequiredPermissions(extension); 71 PermissionsParser::GetRequiredPermissions(extension);
72 72
73 // We restrict the active permissions to be within the bounds defined in the 73 // We restrict the active permissions to be within the bounds defined in the
74 // extension's manifest. 74 // extension's manifest.
75 // a) active permissions must be a subset of optional + default permissions 75 // a) active permissions must be a subset of optional + default permissions
76 // b) active permissions must contains all default permissions 76 // b) active permissions must contains all default permissions
77 scoped_refptr<PermissionSet> total_permissions = PermissionSet::CreateUnion( 77 scoped_refptr<PermissionSet> total_permissions = PermissionSet::CreateUnion(
78 required_permissions.get(), 78 required_permissions.get(),
79 PermissionsParser::GetOptionalPermissions(extension)); 79 PermissionsParser::GetOptionalPermissions(extension).get());
80 80
81 // Make sure the active permissions contain no more than optional + default. 81 // Make sure the active permissions contain no more than optional + default.
82 scoped_refptr<PermissionSet> adjusted_active = 82 scoped_refptr<PermissionSet> adjusted_active =
83 PermissionSet::CreateIntersection(total_permissions.get(), 83 PermissionSet::CreateIntersection(total_permissions.get(),
84 active_permissions.get()); 84 active_permissions.get());
85 85
86 // Make sure the active permissions contain the default permissions. 86 // Make sure the active permissions contain the default permissions.
87 adjusted_active = PermissionSet::CreateUnion(required_permissions.get(), 87 adjusted_active = PermissionSet::CreateUnion(required_permissions.get(),
88 adjusted_active.get()); 88 adjusted_active.get());
89 89
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 extension, changed, reason); 331 extension, changed, reason);
332 Profile* profile = Profile::FromBrowserContext(browser_context_); 332 Profile* profile = Profile::FromBrowserContext(browser_context_);
333 content::NotificationService::current()->Notify( 333 content::NotificationService::current()->Notify(
334 extensions::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED, 334 extensions::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED,
335 content::Source<Profile>(profile), 335 content::Source<Profile>(profile),
336 content::Details<UpdatedExtensionPermissionsInfo>(&info)); 336 content::Details<UpdatedExtensionPermissionsInfo>(&info));
337 337
338 ExtensionMsg_UpdatePermissions_Params params; 338 ExtensionMsg_UpdatePermissions_Params params;
339 params.extension_id = extension->id(); 339 params.extension_id = extension->id();
340 params.active_permissions = ExtensionMsg_PermissionSetStruct( 340 params.active_permissions = ExtensionMsg_PermissionSetStruct(
341 extension->permissions_data()->active_permissions()); 341 *extension->permissions_data()->active_permissions());
342 params.withheld_permissions = ExtensionMsg_PermissionSetStruct( 342 params.withheld_permissions = ExtensionMsg_PermissionSetStruct(
343 extension->permissions_data()->withheld_permissions()); 343 *extension->permissions_data()->withheld_permissions());
344 344
345 // Send the new permissions to the renderers. 345 // Send the new permissions to the renderers.
346 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); 346 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
347 !i.IsAtEnd(); i.Advance()) { 347 !i.IsAtEnd(); i.Advance()) {
348 RenderProcessHost* host = i.GetCurrentValue(); 348 RenderProcessHost* host = i.GetCurrentValue();
349 if (profile->IsSameProfile( 349 if (profile->IsSameProfile(
350 Profile::FromBrowserContext(host->GetBrowserContext()))) { 350 Profile::FromBrowserContext(host->GetBrowserContext()))) {
351 host->Send(new ExtensionMsg_UpdatePermissions(params)); 351 host->Send(new ExtensionMsg_UpdatePermissions(params));
352 } 352 }
353 } 353 }
354 354
355 // Trigger the onAdded and onRemoved events in the extension. 355 // Trigger the onAdded and onRemoved events in the extension.
356 DispatchEvent(extension->id(), event_name, changed); 356 DispatchEvent(extension->id(), event_name, changed);
357 } 357 }
358 358
359 } // namespace extensions 359 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model_unittest.cc ('k') | chrome/browser/extensions/sandboxed_unpacker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698