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

Unified Diff: chrome/browser/extensions/permissions_updater.cc

Issue 501273002: Update extension install prompt to reflect withheld permissions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Permissions helper method, init flag changes in updater 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/permissions_updater.cc
diff --git a/chrome/browser/extensions/permissions_updater.cc b/chrome/browser/extensions/permissions_updater.cc
index 385d5e9b95e7f2518a93e6dd8da62308792ad452..fbddb8f094dde8af623d9b206e9bce1d551ef5c3 100644
--- a/chrome/browser/extensions/permissions_updater.cc
+++ b/chrome/browser/extensions/permissions_updater.cc
@@ -110,7 +110,8 @@ void SegregateUrlPermissions(const URLPatternSet& url_patterns,
} // namespace
PermissionsUpdater::PermissionsUpdater(content::BrowserContext* browser_context)
- : browser_context_(browser_context) {
+ : browser_context_(browser_context),
+ init_flag_(INIT_FLAG_NONE) {
gpdavis 2014/09/09 20:28:15 How about something like this? The init flag is n
Devlin 2014/09/10 22:00:44 Yeah, we should make another constructor Permissio
gpdavis 2014/09/11 20:09:21 Awesome. Done.
}
PermissionsUpdater::~PermissionsUpdater() {}
@@ -163,12 +164,25 @@ void PermissionsUpdater::GrantActivePermissions(const Extension* extension) {
extension->permissions_data()->active_permissions().get());
}
+void PermissionsUpdater::InitializePermissions(const Extension* extension,
+ InitFlag init_flag) {
+ init_flag_ = init_flag;
+ InitializePermissions(extension);
+}
+
void PermissionsUpdater::InitializePermissions(const Extension* extension) {
- scoped_refptr<const PermissionSet> active_permissions =
- ExtensionPrefs::Get(browser_context_)
- ->GetActivePermissions(extension->id());
- scoped_refptr<const PermissionSet> bounded_active =
- GetBoundedActivePermissions(extension, active_permissions);
+ scoped_refptr<const PermissionSet> active_permissions(NULL);
+ scoped_refptr<const PermissionSet> bounded_active(NULL);
+ // If |extension| is a transient dummy extension, we do not want to look for
+ // it in preferences.
+ if (init_flag_ & INIT_FLAG_TRANSIENT) {
+ bounded_active = active_permissions =
+ extension->permissions_data()->active_permissions();
+ } else {
+ active_permissions = ExtensionPrefs::Get(browser_context_)
+ ->GetActivePermissions(extension->id());
+ bounded_active = GetBoundedActivePermissions(extension, active_permissions);
+ }
// Withhold permissions only if the switch applies to this extension and the
// extension doesn't have the preference to allow scripting on all urls.
@@ -286,8 +300,10 @@ void PermissionsUpdater::SetPermissions(
withheld = withheld.get() ? withheld
: extension->permissions_data()->withheld_permissions();
extension->permissions_data()->SetPermissions(active, withheld);
- ExtensionPrefs::Get(browser_context_)->SetActivePermissions(
- extension->id(), active.get());
+ if (init_flag_ & INIT_FLAG_NONE) {
Devlin 2014/09/10 22:00:44 I think more correct would be if (init_flag_ & INI
gpdavis 2014/09/11 20:09:21 I'm not really sure why I didn't do it this way to
+ ExtensionPrefs::Get(browser_context_)->SetActivePermissions(
+ extension->id(), active.get());
+ }
}
void PermissionsUpdater::DispatchEvent(

Powered by Google App Engine
This is Rietveld 408576698