Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "extensions/browser/extension_util.h" | 5 #include "extensions/browser/extension_util.h" |
| 6 | 6 |
| 7 #include "content/public/browser/browser_context.h" | |
| 8 #include "content/public/browser/site_instance.h" | |
| 7 #include "extensions/browser/extension_prefs.h" | 9 #include "extensions/browser/extension_prefs.h" |
| 8 #include "extensions/browser/extension_registry.h" | 10 #include "extensions/browser/extension_registry.h" |
| 9 #include "extensions/common/manifest_handlers/app_isolation_info.h" | 11 #include "extensions/common/manifest_handlers/app_isolation_info.h" |
| 10 #include "extensions/common/manifest_handlers/incognito_info.h" | 12 #include "extensions/common/manifest_handlers/incognito_info.h" |
| 11 | 13 |
| 12 namespace extensions { | 14 namespace extensions { |
| 13 namespace util { | 15 namespace util { |
| 14 | 16 |
| 17 namespace { | |
| 18 | |
| 19 GURL GetSiteForExtensionId(const std::string& extension_id, | |
|
Devlin
2016/10/05 17:02:25
nit: if this is only used here, inline it.
lazyboy
2016/10/06 01:02:06
Done.
| |
| 20 content::BrowserContext* context) { | |
| 21 return content::SiteInstance::GetSiteForURL( | |
| 22 context, Extension::GetBaseURLFromExtensionId(extension_id)); | |
| 23 } | |
| 24 | |
| 25 } // namespace | |
| 26 | |
| 15 bool HasIsolatedStorage(const ExtensionInfo& info) { | 27 bool HasIsolatedStorage(const ExtensionInfo& info) { |
| 16 if (!info.extension_manifest.get()) | 28 if (!info.extension_manifest.get()) |
| 17 return false; | 29 return false; |
| 18 | 30 |
| 19 std::string error; | 31 std::string error; |
| 20 scoped_refptr<const Extension> extension(Extension::Create( | 32 scoped_refptr<const Extension> extension(Extension::Create( |
| 21 info.extension_path, | 33 info.extension_path, |
| 22 info.extension_location, | 34 info.extension_location, |
| 23 *info.extension_manifest, | 35 *info.extension_manifest, |
| 24 Extension::NO_FLAGS, | 36 Extension::NO_FLAGS, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 36 | 48 |
| 37 return extension && AppIsolationInfo::HasIsolatedStorage(extension); | 49 return extension && AppIsolationInfo::HasIsolatedStorage(extension); |
| 38 } | 50 } |
| 39 | 51 |
| 40 bool CanBeIncognitoEnabled(const Extension* extension) { | 52 bool CanBeIncognitoEnabled(const Extension* extension) { |
| 41 return IncognitoInfo::IsIncognitoAllowed(extension) && | 53 return IncognitoInfo::IsIncognitoAllowed(extension) && |
| 42 (!extension->is_platform_app() || | 54 (!extension->is_platform_app() || |
| 43 extension->location() == Manifest::COMPONENT); | 55 extension->location() == Manifest::COMPONENT); |
| 44 } | 56 } |
| 45 | 57 |
| 58 content::StoragePartition* GetStoragePartitionForExtensionId( | |
| 59 const std::string& extension_id, | |
| 60 content::BrowserContext* browser_context) { | |
| 61 GURL site_url = GetSiteForExtensionId(extension_id, browser_context); | |
| 62 content::StoragePartition* storage_partition = | |
| 63 content::BrowserContext::GetStoragePartitionForSite(browser_context, | |
| 64 site_url); | |
| 65 DCHECK(storage_partition); | |
|
Devlin
2016/10/05 17:02:25
seems like this should be relaxed if the extension
lazyboy
2016/10/06 01:02:06
Done.
| |
| 66 return storage_partition; | |
| 67 } | |
| 68 | |
| 46 } // namespace util | 69 } // namespace util |
| 47 } // namespace extensions | 70 } // namespace extensions |
| OLD | NEW |