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"
11 namespace extensions
{
14 bool IsExtensionInstalledPermanently(const std::string
& extension_id
,
15 content::BrowserContext
* context
) {
16 const Extension
* extension
= ExtensionRegistry::Get(context
)->
17 GetExtensionById(extension_id
, ExtensionRegistry::EVERYTHING
);
18 return extension
&& !IsEphemeralApp(extension_id
, context
);
21 bool IsEphemeralApp(const std::string
& extension_id
,
22 content::BrowserContext
* context
) {
23 return ExtensionPrefs::Get(context
)->IsEphemeralApp(extension_id
);
26 bool HasIsolatedStorage(const ExtensionInfo
& info
) {
27 if (!info
.extension_manifest
.get())
31 scoped_refptr
<const Extension
> extension(Extension::Create(
33 info
.extension_location
,
34 *info
.extension_manifest
,
39 return extension
.get() &&
40 AppIsolationInfo::HasIsolatedStorage(extension
.get());
43 bool SiteHasIsolatedStorage(const GURL
& extension_site_url
,
44 content::BrowserContext
* context
) {
45 const Extension
* extension
= ExtensionRegistry::Get(context
)->
46 enabled_extensions().GetExtensionOrAppByURL(extension_site_url
);
48 return extension
&& AppIsolationInfo::HasIsolatedStorage(extension
);
52 } // namespace extensions