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

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

Issue 9320021: Fix crash in ExtensionService::InitializePermissions(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add the test data Created 8 years, 10 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
« no previous file with comments | « chrome/browser/extensions/installed_loader.cc ('k') | chrome/common/extensions/extension.cc » ('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) 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // the extension, not the user, removed the permissions. This allows the 67 // the extension, not the user, removed the permissions. This allows the
68 // extension to add them again without prompting the user. 68 // extension to add them again without prompting the user.
69 UpdateActivePermissions(extension, total.get()); 69 UpdateActivePermissions(extension, total.get());
70 70
71 NotifyPermissionsUpdated(REMOVED, extension, removed.get()); 71 NotifyPermissionsUpdated(REMOVED, extension, removed.get());
72 } 72 }
73 73
74 void PermissionsUpdater::GrantActivePermissions(const Extension* extension) { 74 void PermissionsUpdater::GrantActivePermissions(const Extension* extension) {
75 CHECK(extension); 75 CHECK(extension);
76 76
77 // We only maintain the granted permissions prefs for extensions that can't 77 // We only maintain the granted permissions prefs for INTERNAL and LOAD
78 // silently increase their permissions. 78 // extensions.
79 if (extension->CanSilentlyIncreasePermissions()) 79 if (extension->location() != Extension::LOAD &&
80 extension->location() != Extension::INTERNAL)
80 return; 81 return;
81 82
82 GetExtensionPrefs()->AddGrantedPermissions( 83 GetExtensionPrefs()->AddGrantedPermissions(
83 extension->id(), extension->GetActivePermissions()); 84 extension->id(), extension->GetActivePermissions());
84 } 85 }
85 86
86 void PermissionsUpdater::UpdateActivePermissions( 87 void PermissionsUpdater::UpdateActivePermissions(
87 const Extension* extension, const ExtensionPermissionSet* permissions) { 88 const Extension* extension, const ExtensionPermissionSet* permissions) {
88 GetExtensionPrefs()->SetActivePermissions(extension->id(), permissions); 89 GetExtensionPrefs()->SetActivePermissions(extension->id(), permissions);
89 extension->SetActivePermissions(permissions); 90 extension->SetActivePermissions(permissions);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 150
150 // Trigger the onAdded and onRemoved events in the extension. 151 // Trigger the onAdded and onRemoved events in the extension.
151 DispatchEvent(extension->id(), event_name, changed); 152 DispatchEvent(extension->id(), event_name, changed);
152 } 153 }
153 154
154 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { 155 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() {
155 return profile_->GetExtensionService()->extension_prefs(); 156 return profile_->GetExtensionService()->extension_prefs();
156 } 157 }
157 158
158 } // namespace extensions 159 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/installed_loader.cc ('k') | chrome/common/extensions/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698