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

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

Issue 874683005: [Extensions] Enable the scripts-require-action feature based on all-urls pref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // it in preferences. 175 // it in preferences.
176 if (init_flag_ & INIT_FLAG_TRANSIENT) { 176 if (init_flag_ & INIT_FLAG_TRANSIENT) {
177 bounded_active = active_permissions = 177 bounded_active = active_permissions =
178 extension->permissions_data()->active_permissions(); 178 extension->permissions_data()->active_permissions();
179 } else { 179 } else {
180 active_permissions = ExtensionPrefs::Get(browser_context_) 180 active_permissions = ExtensionPrefs::Get(browser_context_)
181 ->GetActivePermissions(extension->id()); 181 ->GetActivePermissions(extension->id());
182 bounded_active = GetBoundedActivePermissions(extension, active_permissions); 182 bounded_active = GetBoundedActivePermissions(extension, active_permissions);
183 } 183 }
184 184
185 // Withhold permissions if the switch applies to this extension. 185 // Determine whether or not to withhold host permissions.
186 // Non-transient extensions also must not have the preference to allow 186 bool should_withhold_permissions = false;
187 // scripting on all urls. 187 if (util::ScriptsMayRequireActionForExtension(extension, bounded_active)) {
188 bool should_withhold_permissions = 188 should_withhold_permissions =
189 util::ScriptsMayRequireActionForExtension(extension); 189 init_flag_ & INIT_FLAG_TRANSIENT ?
190 if ((init_flag_ & INIT_FLAG_TRANSIENT) == 0) { 190 !util::DefaultAllowedScriptingOnAllUrls() :
191 should_withhold_permissions &= 191 !util::AllowedScriptingOnAllUrls(extension->id(), browser_context_);
192 !util::AllowedScriptingOnAllUrls(extension->id(), browser_context_);
193 } 192 }
194 193
195 URLPatternSet granted_explicit_hosts; 194 URLPatternSet granted_explicit_hosts;
196 URLPatternSet withheld_explicit_hosts; 195 URLPatternSet withheld_explicit_hosts;
197 SegregateUrlPermissions(bounded_active->explicit_hosts(), 196 SegregateUrlPermissions(bounded_active->explicit_hosts(),
198 should_withhold_permissions, 197 should_withhold_permissions,
199 &granted_explicit_hosts, 198 &granted_explicit_hosts,
200 &withheld_explicit_hosts); 199 &withheld_explicit_hosts);
201 200
202 URLPatternSet granted_scriptable_hosts; 201 URLPatternSet granted_scriptable_hosts;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 Profile::FromBrowserContext(host->GetBrowserContext()))) { 368 Profile::FromBrowserContext(host->GetBrowserContext()))) {
370 host->Send(new ExtensionMsg_UpdatePermissions(params)); 369 host->Send(new ExtensionMsg_UpdatePermissions(params));
371 } 370 }
372 } 371 }
373 372
374 // Trigger the onAdded and onRemoved events in the extension. 373 // Trigger the onAdded and onRemoved events in the extension.
375 DispatchEvent(extension->id(), event_name, changed); 374 DispatchEvent(extension->id(), event_name, changed);
376 } 375 }
377 376
378 } // namespace extensions 377 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698