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

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

Issue 9222013: Prevent unnecessary prompts when unpacked extensions use chrome.permissions.request. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 UpdateActivePermissions(extension, total.get()); 68 UpdateActivePermissions(extension, total.get());
69 69
70 NotifyPermissionsUpdated(REMOVED, extension, removed.get()); 70 NotifyPermissionsUpdated(REMOVED, extension, removed.get());
71 } 71 }
72 72
73 void PermissionsUpdater::GrantActivePermissions(const Extension* extension) { 73 void PermissionsUpdater::GrantActivePermissions(const Extension* extension) {
74 CHECK(extension); 74 CHECK(extension);
75 75
76 // We only maintain the granted permissions prefs for extensions that can't 76 // We only maintain the granted permissions prefs for extensions that can't
77 // silently increase their permissions. 77 // silently increase their permissions.
78 if (extension->CanSilentlyIncreasePermissions()) 78 if (extension->CanSilentlyIncreasePermissionsWhileRunning())
79 return; 79 return;
80 80
81 GetExtensionPrefs()->AddGrantedPermissions( 81 GetExtensionPrefs()->AddGrantedPermissions(
82 extension->id(), extension->GetActivePermissions()); 82 extension->id(), extension->GetActivePermissions());
83 } 83 }
84 84
85 void PermissionsUpdater::UpdateActivePermissions( 85 void PermissionsUpdater::UpdateActivePermissions(
86 const Extension* extension, const ExtensionPermissionSet* permissions) { 86 const Extension* extension, const ExtensionPermissionSet* permissions) {
87 GetExtensionPrefs()->SetActivePermissions(extension->id(), permissions); 87 GetExtensionPrefs()->SetActivePermissions(extension->id(), permissions);
88 extension->SetActivePermissions(permissions); 88 extension->SetActivePermissions(permissions);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 // Trigger the onAdded and onRemoved events in the extension. 147 // Trigger the onAdded and onRemoved events in the extension.
148 DispatchEvent(extension->id(), event_name, changed); 148 DispatchEvent(extension->id(), event_name, changed);
149 } 149 }
150 150
151 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() { 151 ExtensionPrefs* PermissionsUpdater::GetExtensionPrefs() {
152 return profile_->GetExtensionService()->extension_prefs(); 152 return profile_->GetExtensionService()->extension_prefs();
153 } 153 }
154 154
155 } // namespace extensions 155 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698