OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extension_util.h" | 5 #include "chrome/browser/extensions/extension_util.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 return ExtensionPrefs::Get(context)->ReadPrefAsBoolean( | 245 return ExtensionPrefs::Get(context)->ReadPrefAsBoolean( |
246 extension_id, | 246 extension_id, |
247 kHasSetScriptOnAllUrlsPrefName, | 247 kHasSetScriptOnAllUrlsPrefName, |
248 &did_set) && did_set; | 248 &did_set) && did_set; |
249 } | 249 } |
250 | 250 |
251 bool DefaultAllowedScriptingOnAllUrls() { | 251 bool DefaultAllowedScriptingOnAllUrls() { |
252 return !FeatureSwitch::scripts_require_action()->IsEnabled(); | 252 return !FeatureSwitch::scripts_require_action()->IsEnabled(); |
253 } | 253 } |
254 | 254 |
255 bool ScriptsMayRequireActionForExtension( | |
256 const Extension* extension, | |
257 const PermissionSet* permissions) { | |
258 // An extension may require user action to execute scripts iff the extension | |
259 // shows up in chrome:extensions (so the user can grant withheld permissions), | |
260 // is not part of chrome or corporate policy, not on the scripting whitelist, | |
261 // and requires enough permissions that we should withhold them. | |
262 return extension->ShouldDisplayInExtensionSettings() && | |
263 !Manifest::IsPolicyLocation(extension->location()) && | |
264 !Manifest::IsComponentLocation(extension->location()) && | |
265 !PermissionsData::CanExecuteScriptEverywhere(extension) && | |
266 permissions->ShouldWarnAllHosts(); | |
267 } | |
268 | |
269 bool IsAppLaunchable(const std::string& extension_id, | 255 bool IsAppLaunchable(const std::string& extension_id, |
270 content::BrowserContext* context) { | 256 content::BrowserContext* context) { |
271 int reason = ExtensionPrefs::Get(context)->GetDisableReasons(extension_id); | 257 int reason = ExtensionPrefs::Get(context)->GetDisableReasons(extension_id); |
272 return !((reason & Extension::DISABLE_UNSUPPORTED_REQUIREMENT) || | 258 return !((reason & Extension::DISABLE_UNSUPPORTED_REQUIREMENT) || |
273 (reason & Extension::DISABLE_CORRUPTED)); | 259 (reason & Extension::DISABLE_CORRUPTED)); |
274 } | 260 } |
275 | 261 |
276 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id, | 262 bool IsAppLaunchableWithoutEnabling(const std::string& extension_id, |
277 content::BrowserContext* context) { | 263 content::BrowserContext* context) { |
278 return ExtensionRegistry::Get(context)->GetExtensionById( | 264 return ExtensionRegistry::Get(context)->GetExtensionById( |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 IDR_EXTENSION_DEFAULT_ICON); | 383 IDR_EXTENSION_DEFAULT_ICON); |
398 } | 384 } |
399 | 385 |
400 bool IsNewBookmarkAppsEnabled() { | 386 bool IsNewBookmarkAppsEnabled() { |
401 return !base::CommandLine::ForCurrentProcess()->HasSwitch( | 387 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
402 switches::kDisableNewBookmarkApps); | 388 switches::kDisableNewBookmarkApps); |
403 } | 389 } |
404 | 390 |
405 } // namespace util | 391 } // namespace util |
406 } // namespace extensions | 392 } // namespace extensions |
OLD | NEW |