Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / extensions / browser / extension_util.cc
blobd8dbe62e8396654c32c122d2938ac9d77102f2b1
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 {
12 namespace util {
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())
28 return false;
30 std::string error;
31 scoped_refptr<const Extension> extension(Extension::Create(
32 info.extension_path,
33 info.extension_location,
34 *info.extension_manifest,
35 Extension::NO_FLAGS,
36 info.extension_id,
37 &error));
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);
51 } // namespace util
52 } // namespace extensions