summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorilevy@chromium.org <ilevy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-31 07:58:57 +0000
committerilevy@chromium.org <ilevy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-31 07:58:57 +0000
commitc86a8268f6579bc82d4a615114ea810aab948a11 (patch)
tree95801959bdb91d9f8f3569da6d74d5c7e651a2fc /chrome
parent73b14fcad61ca35a19895cffadaf2739f2151f14 (diff)
downloadchromium_src-c86a8268f6579bc82d4a615114ea810aab948a11.zip
chromium_src-c86a8268f6579bc82d4a615114ea810aab948a11.tar.gz
chromium_src-c86a8268f6579bc82d4a615114ea810aab948a11.tar.bz2
Revert 191571 "Move AppIsolation out of Extension Class"
browser_tests and unit_tests failures on many bots. For example: IsolatedAppsManifestTest.IsolatedApps crashes here: http://goo.gl/3iAgy > Move AppIsolation out of Extension Class > > TBR=ben@chromium.org, joi@chromium.org > (ben - gypis, joi - public/browser/ comment update) > BUG=159265 > > > Review URL: https://chromiumcodereview.appspot.com/12770031 TBR=rdevlin.cronin@chromium.org git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191573 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chrome_content_browser_client.cc10
-rw-r--r--chrome/browser/extensions/chrome_manifest_parser.cc2
-rw-r--r--chrome/browser/extensions/extension_service.cc13
-rw-r--r--chrome/chrome_common.gypi2
-rw-r--r--chrome/common/extensions/extension.cc46
-rw-r--r--chrome/common/extensions/extension.h4
-rw-r--r--chrome/common/extensions/extension_process_policy.cc6
-rw-r--r--chrome/common/extensions/manifest_handlers/app_isolation_info.cc98
-rw-r--r--chrome/common/extensions/manifest_handlers/app_isolation_info.h44
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_isolatedapp_unittest.cc19
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc10
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc2
12 files changed, 66 insertions, 190 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 81548c6..45b0879 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -89,7 +89,6 @@
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_process_policy.h"
#include "chrome/common/extensions/extension_set.h"
-#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
#include "chrome/common/extensions/permissions/socket_permission.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/pref_names.h"
@@ -324,8 +323,7 @@ RenderProcessHostPrivilege GetPrivilegeRequiredByUrl(
if (url.SchemeIs(extensions::kExtensionScheme)) {
const Extension* extension =
service->extensions()->GetByID(url.host());
- if (extension &&
- extensions::AppIsolationInfo::HasIsolatedStorage(extension))
+ if (extension && extension->is_storage_isolated())
return PRIV_ISOLATED;
if (extension && extension->is_hosted_app())
return PRIV_HOSTED;
@@ -348,8 +346,7 @@ RenderProcessHostPrivilege GetProcessPrivilege(
for (std::set<std::string>::iterator iter = extension_ids.begin();
iter != extension_ids.end(); ++iter) {
const Extension* extension = service->GetExtensionById(*iter, false);
- if (extension &&
- extensions::AppIsolationInfo::HasIsolatedStorage(extension))
+ if (extension && extension->is_storage_isolated())
return PRIV_ISOLATED;
if (extension && extension->is_hosted_app())
return PRIV_HOSTED;
@@ -600,8 +597,7 @@ void ChromeContentBrowserClient::GetStoragePartitionConfigForSite(
if (extension_service) {
extension = extension_service->extensions()->
GetExtensionOrAppByURL(ExtensionURLInfo(site));
- if (extension &&
- extensions::AppIsolationInfo::HasIsolatedStorage(extension)) {
+ if (extension && extension->is_storage_isolated()) {
is_isolated = true;
}
}
diff --git a/chrome/browser/extensions/chrome_manifest_parser.cc b/chrome/browser/extensions/chrome_manifest_parser.cc
index 94ddd81..75c2a4d 100644
--- a/chrome/browser/extensions/chrome_manifest_parser.cc
+++ b/chrome/browser/extensions/chrome_manifest_parser.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/extensions/extension_web_ui.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
#include "chrome/common/extensions/manifest_handlers/kiosk_enabled_info.h"
#include "chrome/common/extensions/manifest_handlers/offline_enabled_info.h"
#include "chrome/common/extensions/manifest_handlers/requirements_handler.h"
@@ -20,7 +19,6 @@ namespace extensions {
ChromeManifestParser::ChromeManifestParser(Profile* profile)
: profile_(profile) {
- (new AppIsolationHandler)->Register();
(new DevToolsPageHandler)->Register();
(new KioskEnabledHandler)->Register();
(new HomepageURLHandler)->Register();
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 9993a94..e6f28b7 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -87,7 +87,6 @@
#include "chrome/common/extensions/features/feature.h"
#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest.h"
-#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/startup_metric_utils.h"
@@ -294,11 +293,10 @@ const Extension* ExtensionService::GetIsolatedAppForRenderer(
const extensions::Extension* extension =
extensions_.GetByID(*(extension_ids.begin()));
- // We still need to check if the extension has isolated storage,
+ // We still need to check is_storage_isolated(),
// because it's common for there to be one extension in a process
- // without isolated storage.
- if (extension &&
- extensions::AppIsolationInfo::HasIsolatedStorage(extension))
+ // with is_storage_isolated() == false.
+ if (extension && extension->is_storage_isolated())
return extension;
return NULL;
@@ -843,8 +841,7 @@ bool ExtensionService::UninstallExtension(
GURL launch_web_url_origin(extension->launch_web_url());
launch_web_url_origin = launch_web_url_origin.GetOrigin();
- bool is_storage_isolated =
- extensions::AppIsolationInfo::HasIsolatedStorage(extension);
+ bool is_storage_isolated = extension->is_storage_isolated();
if (is_storage_isolated) {
BrowserContext::AsyncObliterateStoragePartition(
@@ -3037,7 +3034,7 @@ void ExtensionService::GarbageCollectIsolatedStorage() {
new base::hash_set<base::FilePath>());
for (ExtensionSet::const_iterator it = extensions_.begin();
it != extensions_.end(); ++it) {
- if (extensions::AppIsolationInfo::HasIsolatedStorage(*it)) {
+ if ((*it)->is_storage_isolated()) {
active_paths->insert(
BrowserContext::GetStoragePartitionForSite(
profile_,
diff --git a/chrome/chrome_common.gypi b/chrome/chrome_common.gypi
index 9008438..4bfaa77 100644
--- a/chrome/chrome_common.gypi
+++ b/chrome/chrome_common.gypi
@@ -250,8 +250,6 @@
'common/extensions/manifest_handler.h',
'common/extensions/manifest_handler_helpers.cc',
'common/extensions/manifest_handler_helpers.h',
- 'common/extensions/manifest_handlers/app_isolation_info.cc',
- 'common/extensions/manifest_handlers/app_isolation_info.h',
'common/extensions/manifest_handlers/content_scripts_handler.cc',
'common/extensions/manifest_handlers/content_scripts_handler.h',
'common/extensions/manifest_handlers/kiosk_enabled_info.cc',
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index 6d6bace..964159e 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1124,6 +1124,7 @@ Extension::Extension(const base::FilePath& path,
converted_from_user_script_(false),
manifest_(manifest.release()),
finished_parsing_manifest_(false),
+ is_storage_isolated_(false),
launch_container_(extension_misc::LAUNCH_TAB),
launch_width_(0),
launch_height_(0),
@@ -1216,6 +1217,9 @@ bool Extension::InitFromValue(int flags, string16* error) {
return false;
}
+ if (!LoadAppIsolation(error))
+ return false;
+
if (!LoadSharedFeatures(error))
return false;
@@ -1241,6 +1245,48 @@ bool Extension::InitFromValue(int flags, string16* error) {
return true;
}
+bool Extension::LoadAppIsolation(string16* error) {
+ // Platform apps always get isolated storage.
+ if (is_platform_app()) {
+ is_storage_isolated_ = true;
+ return true;
+ }
+
+ // Other apps only get it if it is requested _and_ experimental APIs are
+ // enabled.
+ if (!initial_api_permissions()->count(APIPermission::kExperimental)
+ || !is_app())
+ return true;
+
+ const Value* tmp_isolation = NULL;
+ if (!manifest_->Get(keys::kIsolation, &tmp_isolation))
+ return true;
+
+ const ListValue* isolation_list = NULL;
+ if (!tmp_isolation->GetAsList(&isolation_list)) {
+ *error = ASCIIToUTF16(errors::kInvalidIsolation);
+ return false;
+ }
+
+ for (size_t i = 0; i < isolation_list->GetSize(); ++i) {
+ std::string isolation_string;
+ if (!isolation_list->GetString(i, &isolation_string)) {
+ *error = ErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidIsolationValue,
+ base::UintToString(i));
+ return false;
+ }
+
+ // Check for isolated storage.
+ if (isolation_string == values::kIsolatedStorage) {
+ is_storage_isolated_ = true;
+ } else {
+ DLOG(WARNING) << "Did not recognize isolation type: " << isolation_string;
+ }
+ }
+ return true;
+}
+
bool Extension::LoadRequiredFeatures(string16* error) {
if (!LoadName(error) ||
!LoadVersion(error))
diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h
index e1d0ae9..07df1a2 100644
--- a/chrome/common/extensions/extension.h
+++ b/chrome/common/extensions/extension.h
@@ -453,6 +453,7 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
bool is_hosted_app() const;
bool is_legacy_packaged_app() const;
bool is_extension() const;
+ bool is_storage_isolated() const { return is_storage_isolated_; }
bool can_be_incognito_enabled() const;
void AddWebExtentPattern(const URLPattern& pattern);
const URLPatternSet& web_extent() const { return extent_; }
@@ -642,6 +643,9 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// parts of the initialization process need information from previous parts).
base::ThreadChecker thread_checker_;
+ // Whether this extension requests isolated storage.
+ bool is_storage_isolated_;
+
// The local path inside the extension to use with the launcher.
std::string launch_local_path_;
diff --git a/chrome/common/extensions/extension_process_policy.cc b/chrome/common/extensions/extension_process_policy.cc
index b38f397..00256c49 100644
--- a/chrome/common/extensions/extension_process_policy.cc
+++ b/chrome/common/extensions/extension_process_policy.cc
@@ -4,9 +4,7 @@
#include "chrome/common/extensions/extension_process_policy.h"
-#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_set.h"
-#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
namespace extensions {
@@ -43,10 +41,10 @@ bool CrossesExtensionProcessBoundary(
if (should_consider_workaround) {
bool old_url_is_hosted_app = old_url_extension &&
!old_url_extension->web_extent().is_empty() &&
- !AppIsolationInfo::HasIsolatedStorage(old_url_extension);
+ !old_url_extension->is_storage_isolated();
bool new_url_is_normal_or_hosted = !new_url_extension ||
(!new_url_extension->web_extent().is_empty() &&
- !AppIsolationInfo::HasIsolatedStorage(new_url_extension));
+ !new_url_extension->is_storage_isolated());
bool either_is_web_store =
(old_url_extension &&
old_url_extension->id() == extension_misc::kWebStoreAppId) ||
diff --git a/chrome/common/extensions/manifest_handlers/app_isolation_info.cc b/chrome/common/extensions/manifest_handlers/app_isolation_info.cc
deleted file mode 100644
index 7f7e121..0000000
--- a/chrome/common/extensions/manifest_handlers/app_isolation_info.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
-
-#include "base/memory/scoped_ptr.h"
-#include "base/string16.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/utf_string_conversions.h"
-#include "base/values.h"
-#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/permissions/api_permission_set.h"
-#include "extensions/common/error_utils.h"
-
-namespace keys = extension_manifest_keys;
-
-namespace extensions {
-
-AppIsolationInfo::AppIsolationInfo(bool isolated_storage)
- : has_isolated_storage(isolated_storage) {
-}
-
-AppIsolationInfo::~AppIsolationInfo() {
-}
-
-// static
-bool AppIsolationInfo::HasIsolatedStorage(const Extension* extension) {
- AppIsolationInfo* info = static_cast<AppIsolationInfo*>(
- extension->GetManifestData(keys::kIsolation));
- return info ? info->has_isolated_storage : false;
-}
-
-AppIsolationHandler::AppIsolationHandler() {
-}
-
-AppIsolationHandler::~AppIsolationHandler() {
-}
-
-bool AppIsolationHandler::Parse(Extension* extension, string16* error) {
- // Platform apps always get isolated storage.
- if (extension->is_platform_app()) {
- extension->SetManifestData(keys::kIsolation, new AppIsolationInfo(true));
- return true;
- }
-
- // Other apps only get it if it is requested _and_ experimental APIs are
- // enabled.
- if (!extension->is_app() ||
- !extension->initial_api_permissions()->count(
- APIPermission::kExperimental)) {
- return true;
- }
-
- const Value* tmp_isolation = NULL;
- // We should only be parsing if the extension has the key in the manifest,
- // or is a platform app (which we already handled).
- DCHECK(extension->manifest()->Get(keys::kIsolation, &tmp_isolation));
-
- const ListValue* isolation_list = NULL;
- if (!tmp_isolation->GetAsList(&isolation_list)) {
- *error = ASCIIToUTF16(extension_manifest_errors::kInvalidIsolation);
- return false;
- }
-
- bool has_isolated_storage = false;
- for (size_t i = 0; i < isolation_list->GetSize(); ++i) {
- std::string isolation_string;
- if (!isolation_list->GetString(i, &isolation_string)) {
- *error = ErrorUtils::FormatErrorMessageUTF16(
- extension_manifest_errors::kInvalidIsolationValue,
- base::UintToString(i));
- return false;
- }
-
- // Check for isolated storage.
- if (isolation_string == extension_manifest_values::kIsolatedStorage) {
- has_isolated_storage = true;
- } else {
- DLOG(WARNING) << "Did not recognize isolation type: " << isolation_string;
- }
- }
-
- if (has_isolated_storage)
- extension->SetManifestData(keys::kIsolation, new AppIsolationInfo(true));
-
- return true;
-}
-
-bool AppIsolationHandler::AlwaysParseForType(Manifest::Type type) const {
- return type == Manifest::TYPE_PLATFORM_APP;
-}
-
-const std::vector<std::string> AppIsolationHandler::Keys() const {
- return SingleKey(keys::kIsolation);
-}
-
-} // namespace extensions
diff --git a/chrome/common/extensions/manifest_handlers/app_isolation_info.h b/chrome/common/extensions/manifest_handlers/app_isolation_info.h
deleted file mode 100644
index 7ceb94e..0000000
--- a/chrome/common/extensions/manifest_handlers/app_isolation_info.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_APP_ISOLATION_INFO_H_
-#define CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_APP_ISOLATION_INFO_H_
-
-#include <string>
-#include <vector>
-
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/manifest.h"
-#include "chrome/common/extensions/manifest_handler.h"
-
-namespace extensions {
-
-struct AppIsolationInfo : public Extension::ManifestData {
- explicit AppIsolationInfo(bool isolated_storage);
- virtual ~AppIsolationInfo();
-
- static bool HasIsolatedStorage(const Extension* extension);
-
- // Whether this extension requests isolated storage.
- bool has_isolated_storage;
-};
-
-// Parses the "isolation" manifest key.
-class AppIsolationHandler : public ManifestHandler {
- public:
- AppIsolationHandler();
- virtual ~AppIsolationHandler();
-
- virtual bool Parse(Extension* extension, string16* error) OVERRIDE;
- virtual bool AlwaysParseForType(Manifest::Type type) const OVERRIDE;
-
- private:
- virtual const std::vector<std::string> Keys() const OVERRIDE;
-
- DISALLOW_COPY_AND_ASSIGN(AppIsolationHandler);
-};
-
-} // namespace extensions
-
-#endif // CHROME_COMMON_EXTENSIONS_MANIFEST_HANDLERS_APP_ISOLATION_INFO_H_
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_isolatedapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_isolatedapp_unittest.cc
index 80bd8bb..6181ad0 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_isolatedapp_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_isolatedapp_unittest.cc
@@ -8,31 +8,18 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
-#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace errors = extension_manifest_errors;
-namespace extensions {
-
-class IsolatedAppsManifestTest : public ExtensionManifestTest {
- protected:
- virtual void SetUp() OVERRIDE {
- testing::Test::SetUp();
- (new AppIsolationHandler)->Register();
- }
-};
-
-TEST_F(IsolatedAppsManifestTest, IsolatedApps) {
+TEST_F(ExtensionManifestTest, IsolatedApps) {
// Requires --enable-experimental-extension-apis
LoadAndExpectError("isolated_app_valid.json",
errors::kExperimentalFlagRequired);
CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kEnableExperimentalExtensionApis);
- scoped_refptr<Extension> extension2(
+ scoped_refptr<extensions::Extension> extension2(
LoadAndExpectSuccess("isolated_app_valid.json"));
- EXPECT_TRUE(AppIsolationInfo::HasIsolatedStorage(extension2));
+ EXPECT_TRUE(extension2->is_storage_isolated());
}
-
-} // namespace extensions
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
index 1fdab49..7dbb9d0 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_platformapp_unittest.cc
@@ -10,7 +10,6 @@
#include "chrome/common/extensions/csp_handler.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
#include "chrome/common/extensions/incognito_handler.h"
-#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -19,20 +18,17 @@ namespace errors = extension_manifest_errors;
namespace extensions {
class PlatformAppsManifestTest : public ExtensionManifestTest {
- protected:
virtual void SetUp() OVERRIDE {
- testing::Test::SetUp();
(new BackgroundManifestHandler)->Register();
(new CSPHandler(true))->Register(); // platform app.
- (new IncognitoHandler)->Register();
- (new AppIsolationHandler)->Register();
+ (new IncognitoHandler())->Register();
}
};
TEST_F(PlatformAppsManifestTest, PlatformApps) {
- scoped_refptr<Extension> extension =
+ scoped_refptr<extensions::Extension> extension =
LoadAndExpectSuccess("init_valid_platform_app.json");
- EXPECT_TRUE(AppIsolationInfo::HasIsolatedStorage(extension));
+ EXPECT_TRUE(extension->is_storage_isolated());
EXPECT_TRUE(IncognitoInfo::IsSplitMode(extension));
extension =
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 2bfee18..27fd285 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -28,7 +28,6 @@
#include "chrome/common/extensions/extension_set.h"
#include "chrome/common/extensions/incognito_handler.h"
#include "chrome/common/extensions/manifest_handler.h"
-#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
#include "chrome/common/extensions/manifest_handlers/sandboxed_page_info.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/extensions/web_accessible_resources_handler.h"
@@ -141,7 +140,6 @@ const char kAdViewTagName[] = "ADVIEW";
// Explicitly register all extension ManifestHandlers needed to parse
// fields used in the renderer.
void RegisterExtensionManifestHandlers() {
- (new extensions::AppIsolationHandler)->Register();
(new extensions::BackgroundManifestHandler)->Register();
(new extensions::CSPHandler(false))->Register(); // not platform app.
(new extensions::CSPHandler(true))->Register(); // platform app.