OLD | NEW |
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 Loading... |
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, |
188 bool should_withhold_permissions = | 188 bounded_active.get())) { |
189 util::ScriptsMayRequireActionForExtension(extension); | 189 should_withhold_permissions = |
190 if ((init_flag_ & INIT_FLAG_TRANSIENT) == 0) { | 190 init_flag_ & INIT_FLAG_TRANSIENT ? |
191 should_withhold_permissions &= | 191 !util::DefaultAllowedScriptingOnAllUrls() : |
192 !util::AllowedScriptingOnAllUrls(extension->id(), browser_context_); | 192 !util::AllowedScriptingOnAllUrls(extension->id(), browser_context_); |
193 } | 193 } |
194 | 194 |
195 URLPatternSet granted_explicit_hosts; | 195 URLPatternSet granted_explicit_hosts; |
196 URLPatternSet withheld_explicit_hosts; | 196 URLPatternSet withheld_explicit_hosts; |
197 SegregateUrlPermissions(bounded_active->explicit_hosts(), | 197 SegregateUrlPermissions(bounded_active->explicit_hosts(), |
198 should_withhold_permissions, | 198 should_withhold_permissions, |
199 &granted_explicit_hosts, | 199 &granted_explicit_hosts, |
200 &withheld_explicit_hosts); | 200 &withheld_explicit_hosts); |
201 | 201 |
202 URLPatternSet granted_scriptable_hosts; | 202 URLPatternSet granted_scriptable_hosts; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 Profile::FromBrowserContext(host->GetBrowserContext()))) { | 369 Profile::FromBrowserContext(host->GetBrowserContext()))) { |
370 host->Send(new ExtensionMsg_UpdatePermissions(params)); | 370 host->Send(new ExtensionMsg_UpdatePermissions(params)); |
371 } | 371 } |
372 } | 372 } |
373 | 373 |
374 // Trigger the onAdded and onRemoved events in the extension. | 374 // Trigger the onAdded and onRemoved events in the extension. |
375 DispatchEvent(extension->id(), event_name, changed); | 375 DispatchEvent(extension->id(), event_name, changed); |
376 } | 376 } |
377 | 377 |
378 } // namespace extensions | 378 } // namespace extensions |
OLD | NEW |