Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / extensions / browser / extension_util.cc
blob23de13057948d4202e70473872f8961d63ec582e
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "extensions/browser/extension_util.h"
7 #include "extensions/browser/extension_prefs.h"
8 #include "extensions/browser/extension_registry.h"
9 #include "extensions/common/manifest_handlers/app_isolation_info.h"
10 #include "extensions/common/manifest_handlers/incognito_info.h"
12 namespace extensions {
13 namespace util {
15 bool IsExtensionInstalledPermanently(const std::string& extension_id,
16 content::BrowserContext* context) {
17 const Extension* extension = ExtensionRegistry::Get(context)->
18 GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING);
19 return extension && !IsEphemeralApp(extension_id, context);
22 bool IsEphemeralApp(const std::string& extension_id,
23 content::BrowserContext* context) {
24 return ExtensionPrefs::Get(context)->IsEphemeralApp(extension_id);
27 bool HasIsolatedStorage(const ExtensionInfo& info) {
28 if (!info.extension_manifest.get())
29 return false;
31 std::string error;
32 scoped_refptr<const Extension> extension(Extension::Create(
33 info.extension_path,
34 info.extension_location,
35 *info.extension_manifest,
36 Extension::NO_FLAGS,
37 info.extension_id,
38 &error));
40 return extension.get() &&
41 AppIsolationInfo::HasIsolatedStorage(extension.get());
44 bool SiteHasIsolatedStorage(const GURL& extension_site_url,
45 content::BrowserContext* context) {
46 const Extension* extension = ExtensionRegistry::Get(context)->
47 enabled_extensions().GetExtensionOrAppByURL(extension_site_url);
49 return extension && AppIsolationInfo::HasIsolatedStorage(extension);
52 bool CanBeIncognitoEnabled(const Extension* extension) {
53 return IncognitoInfo::IsIncognitoAllowed(extension) &&
54 (!extension->is_platform_app() ||
55 extension->location() == Manifest::COMPONENT);
58 } // namespace util
59 } // namespace extensions