summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-26 22:38:31 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-26 22:38:31 +0000
commit1bf73cc395040e15045358e1ce2884399eda6c73 (patch)
tree3e3048c7f4de6cc483b1f5482e9c50a5b81824c6 /chrome
parent1977348dd202ea5bc716f44be23972520c434ed9 (diff)
downloadchromium_src-1bf73cc395040e15045358e1ce2884399eda6c73.zip
chromium_src-1bf73cc395040e15045358e1ce2884399eda6c73.tar.gz
chromium_src-1bf73cc395040e15045358e1ce2884399eda6c73.tar.bz2
Mark some externally installed extensions as 'bookmark apps'
BUG=101605 TEST=When clearing user data, make sure none of the default apps leave behind any local storage Review URL: http://codereview.chromium.org/8396047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107453 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/crx_installer.cc4
-rw-r--r--chrome/browser/extensions/crx_installer.h7
-rw-r--r--chrome/browser/extensions/extension_service.cc4
-rw-r--r--chrome/browser/extensions/extension_service.h3
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc57
-rw-r--r--chrome/browser/extensions/external_extension_provider_impl.cc26
-rw-r--r--chrome/browser/extensions/external_extension_provider_impl.h7
-rw-r--r--chrome/browser/extensions/external_extension_provider_interface.h3
-rw-r--r--chrome/browser/extensions/external_policy_extension_loader_unittest.cc6
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker.cc6
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker.h7
-rw-r--r--chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc3
12 files changed, 102 insertions, 31 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index 614757f..514ebe2 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -129,7 +129,8 @@ CrxInstaller::CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak,
client_(client),
apps_require_extension_mime_type_(false),
allow_silent_install_(false),
- install_cause_(extension_misc::INSTALL_CAUSE_UNSET) {
+ install_cause_(extension_misc::INSTALL_CAUSE_UNSET),
+ creation_flags_(Extension::NO_FLAGS) {
}
CrxInstaller::~CrxInstaller() {
@@ -164,6 +165,7 @@ void CrxInstaller::InstallCrx(const FilePath& source_file) {
new SandboxedExtensionUnpacker(
source_file,
g_browser_process->resource_dispatcher_host(),
+ creation_flags_,
this));
if (!BrowserThread::PostTask(
diff --git a/chrome/browser/extensions/crx_installer.h b/chrome/browser/extensions/crx_installer.h
index 995e850..e83342d 100644
--- a/chrome/browser/extensions/crx_installer.h
+++ b/chrome/browser/extensions/crx_installer.h
@@ -113,6 +113,9 @@ class CrxInstaller
virtual void InstallUIProceed() OVERRIDE;
virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
+ int creation_flags() const { return creation_flags_; }
+ void set_creation_flags(int val) { creation_flags_ = val; }
+
const GURL& download_url() const { return download_url_; }
void set_download_url(const GURL& val) { download_url_ = val; }
@@ -312,6 +315,10 @@ class CrxInstaller
// on failure rates, broken down by the cause of the install.
extension_misc::CrxInstallCause install_cause_;
+ // Creation flags to use for the extension. These flags will be used
+ // when calling Extenion::Create() by the crx installer.
+ int creation_flags_;
+
DISALLOW_COPY_AND_ASSIGN(CrxInstaller);
};
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 5466f84..858d09f 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -2751,7 +2751,8 @@ void ExtensionService::OnExternalExtensionFileFound(
const std::string& id,
const Version* version,
const FilePath& path,
- Extension::Location location) {
+ Extension::Location location,
+ int creation_flags) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CHECK(Extension::IdIsValid(id));
if (extension_prefs_->IsExternalExtensionUninstalled(id))
@@ -2786,6 +2787,7 @@ void ExtensionService::OnExternalExtensionFileFound(
installer->set_expected_id(id);
installer->set_expected_version(*version);
installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE);
+ installer->set_creation_flags(creation_flags);
installer->InstallCrx(path);
}
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 0fa7cc6d..7f3fa88 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -510,7 +510,8 @@ class ExtensionService
virtual void OnExternalExtensionFileFound(const std::string& id,
const Version* version,
const FilePath& path,
- Extension::Location location)
+ Extension::Location location,
+ int creation_flags)
OVERRIDE;
virtual void OnExternalExtensionUpdateUrlFound(const std::string& id,
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index c7a2830..b2da4aa 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -147,7 +147,8 @@ class MockExtensionProvider : public ExternalExtensionProviderInterface {
version.reset(Version::GetVersionFromString(i->second.first));
visitor_->OnExternalExtensionFileFound(
- i->first, version.get(), i->second.second, location_);
+ i->first, version.get(), i->second.second, location_,
+ Extension::NO_FLAGS);
}
visitor_->OnExternalProviderReady(this);
}
@@ -217,7 +218,8 @@ class MockProviderVisitor
this,
new ExternalTestingExtensionLoader(json_data, fake_base_path_),
Extension::EXTERNAL_PREF,
- Extension::EXTERNAL_PREF_DOWNLOAD));
+ Extension::EXTERNAL_PREF_DOWNLOAD,
+ Extension::NO_FLAGS));
// We also parse the file into a dictionary to compare what we get back
// from the provider.
@@ -244,7 +246,10 @@ class MockProviderVisitor
virtual void OnExternalExtensionFileFound(const std::string& id,
const Version* version,
const FilePath& path,
- Extension::Location unused) {
+ Extension::Location unused,
+ int creation_flags) {
+ EXPECT_EQ(Extension::NO_FLAGS, creation_flags);
+
++ids_found_;
DictionaryValue* pref;
// This tests is to make sure that the provider only notifies us of the
@@ -1199,6 +1204,28 @@ TEST_F(ExtensionServiceTest, InstallExtension) {
// TODO(erikkay): add tests for upgrade cases.
}
+// Tests that flags passed to OnExternalExtensionFileFound() make it to the
+// extension object.
+TEST_F(ExtensionServiceTest, InstallingExternalExtensionWithFlags) {
+ InitializeEmptyExtensionService();
+
+ FilePath path = data_dir_.AppendASCII("good.crx");
+ set_extensions_enabled(true);
+
+ scoped_ptr<Version> version;
+ version.reset(Version::GetVersionFromString("1.0.0.0"));
+ // Install an external extension.
+ service_->OnExternalExtensionFileFound(good_crx, version.get(),
+ path, Extension::EXTERNAL_PREF,
+ Extension::FROM_BOOKMARK);
+ loop_.RunAllPending();
+
+ const Extension* extension = service_->GetExtensionById(good_crx, false);
+ ASSERT_TRUE(extension);
+ ASSERT_EQ(Extension::FROM_BOOKMARK,
+ Extension::FROM_BOOKMARK & extension->creation_flags());
+}
+
// Test the handling of Extension::EXTERNAL_EXTENSION_UNINSTALLED
TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) {
InitializeEmptyExtensionService();
@@ -1210,7 +1237,8 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) {
version.reset(Version::GetVersionFromString("1.0.0.0"));
// Install an external extension.
service_->OnExternalExtensionFileFound(good_crx, version.get(),
- path, Extension::EXTERNAL_PREF);
+ path, Extension::EXTERNAL_PREF,
+ Extension::NO_FLAGS);
loop_.RunAllPending();
ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
@@ -1221,7 +1249,8 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) {
// Try to re-install it externally. This should fail because of the killbit.
service_->OnExternalExtensionFileFound(good_crx, version.get(),
- path, Extension::EXTERNAL_PREF);
+ path, Extension::EXTERNAL_PREF,
+ Extension::NO_FLAGS);
loop_.RunAllPending();
ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
ValidateIntegerPref(good_crx, "location",
@@ -1231,7 +1260,8 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) {
// Repeat the same thing with a newer version of the extension.
path = data_dir_.AppendASCII("good2.crx");
service_->OnExternalExtensionFileFound(good_crx, version.get(),
- path, Extension::EXTERNAL_PREF);
+ path, Extension::EXTERNAL_PREF,
+ Extension::NO_FLAGS);
loop_.RunAllPending();
ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
ValidateIntegerPref(good_crx, "location",
@@ -1291,14 +1321,16 @@ TEST_F(ExtensionServiceTest, FailOnWrongId) {
// Install an external extension with an ID from the external
// source that is not equal to the ID in the extension manifest.
service_->OnExternalExtensionFileFound(
- wrong_id, version.get(), path, Extension::EXTERNAL_PREF);
+ wrong_id, version.get(), path, Extension::EXTERNAL_PREF,
+ Extension::NO_FLAGS);
loop_.RunAllPending();
ASSERT_FALSE(service_->GetExtensionById(good_crx, false));
// Try again with the right ID. Expect success.
service_->OnExternalExtensionFileFound(
- correct_id, version.get(), path, Extension::EXTERNAL_PREF);
+ correct_id, version.get(), path, Extension::EXTERNAL_PREF,
+ Extension::NO_FLAGS);
loop_.RunAllPending();
ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
}
@@ -1314,7 +1346,8 @@ TEST_F(ExtensionServiceTest, FailOnWrongVersion) {
scoped_ptr<Version> wrong_version;
wrong_version.reset(Version::GetVersionFromString("1.2.3.4"));
service_->OnExternalExtensionFileFound(
- good_crx, wrong_version.get(), path, Extension::EXTERNAL_PREF);
+ good_crx, wrong_version.get(), path, Extension::EXTERNAL_PREF,
+ Extension::NO_FLAGS);
loop_.RunAllPending();
ASSERT_FALSE(service_->GetExtensionById(good_crx, false));
@@ -1323,7 +1356,8 @@ TEST_F(ExtensionServiceTest, FailOnWrongVersion) {
scoped_ptr<Version> correct_version;
correct_version.reset(Version::GetVersionFromString("1.0.0.0"));
service_->OnExternalExtensionFileFound(
- good_crx, correct_version.get(), path, Extension::EXTERNAL_PREF);
+ good_crx, correct_version.get(), path, Extension::EXTERNAL_PREF,
+ Extension::NO_FLAGS);
loop_.RunAllPending();
ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
}
@@ -4082,7 +4116,8 @@ class ExtensionSourcePriorityTest : public ExtensionServiceTest {
version.reset(Version::GetVersionFromString("1.0.0.0"));
service_->OnExternalExtensionFileFound(
- crx_id_, version.get(), crx_path_, Extension::EXTERNAL_PREF);
+ crx_id_, version.get(), crx_path_, Extension::EXTERNAL_PREF,
+ Extension::NO_FLAGS);
}
// Fake a request from sync to install an extension.
diff --git a/chrome/browser/extensions/external_extension_provider_impl.cc b/chrome/browser/extensions/external_extension_provider_impl.cc
index a16b68d..afe652f 100644
--- a/chrome/browser/extensions/external_extension_provider_impl.cc
+++ b/chrome/browser/extensions/external_extension_provider_impl.cc
@@ -46,13 +46,15 @@ ExternalExtensionProviderImpl::ExternalExtensionProviderImpl(
VisitorInterface* service,
ExternalExtensionLoader* loader,
Extension::Location crx_location,
- Extension::Location download_location)
+ Extension::Location download_location,
+ int creation_flags)
: crx_location_(crx_location),
download_location_(download_location),
service_(service),
prefs_(NULL),
ready_(false),
- loader_(loader) {
+ loader_(loader),
+ creation_flags_(creation_flags) {
loader_->Init(this);
}
@@ -192,7 +194,7 @@ void ExternalExtensionProviderImpl::SetPrefs(DictionaryValue* prefs) {
continue;
}
service_->OnExternalExtensionFileFound(extension_id, version.get(), path,
- crx_location_);
+ crx_location_, creation_flags_);
} else { // if (has_external_update_url)
CHECK(has_external_update_url); // Checking of keys above ensures this.
if (download_location_ == Extension::INVALID) {
@@ -296,7 +298,8 @@ void ExternalExtensionProviderImpl::CreateExternalProviders(
new ExternalPrefExtensionLoader(
chrome::DIR_EXTERNAL_EXTENSIONS, options),
Extension::EXTERNAL_PREF,
- Extension::EXTERNAL_PREF_DOWNLOAD)));
+ Extension::EXTERNAL_PREF_DOWNLOAD,
+ Extension::NO_FLAGS)));
#if defined(OS_MACOSX)
// Support old path to external extensions file as we migrate to the
@@ -309,7 +312,8 @@ void ExternalExtensionProviderImpl::CreateExternalProviders(
chrome::DIR_DEPRECATED_EXTERNAL_EXTENSIONS,
ExternalPrefExtensionLoader::NONE),
Extension::EXTERNAL_PREF,
- Extension::EXTERNAL_PREF_DOWNLOAD)));
+ Extension::EXTERNAL_PREF_DOWNLOAD,
+ Extension::NO_FLAGS)));
#endif
#if defined(OS_CHROMEOS)
@@ -322,7 +326,8 @@ void ExternalExtensionProviderImpl::CreateExternalProviders(
chrome::DIR_USER_EXTERNAL_EXTENSIONS,
ExternalPrefExtensionLoader::NONE),
Extension::EXTERNAL_PREF,
- Extension::EXTERNAL_PREF_DOWNLOAD)));
+ Extension::EXTERNAL_PREF_DOWNLOAD,
+ Extension::NO_FLAGS)));
#endif
#if defined(OS_WIN)
provider_list->push_back(
@@ -331,7 +336,8 @@ void ExternalExtensionProviderImpl::CreateExternalProviders(
service,
new ExternalRegistryExtensionLoader,
Extension::EXTERNAL_REGISTRY,
- Extension::INVALID)));
+ Extension::INVALID,
+ Extension::NO_FLAGS)));
#endif
provider_list->push_back(
linked_ptr<ExternalExtensionProviderInterface>(
@@ -339,7 +345,8 @@ void ExternalExtensionProviderImpl::CreateExternalProviders(
service,
new ExternalPolicyExtensionLoader(profile),
Extension::INVALID,
- Extension::EXTERNAL_POLICY_DOWNLOAD)));
+ Extension::EXTERNAL_POLICY_DOWNLOAD,
+ Extension::NO_FLAGS)));
#if !defined(OS_CHROMEOS)
if (default_apps::ShouldInstallInProfile(profile)) {
@@ -350,7 +357,8 @@ void ExternalExtensionProviderImpl::CreateExternalProviders(
new ExternalPrefExtensionLoader(
chrome::DIR_DEFAULT_APPS, options),
Extension::EXTERNAL_PREF,
- Extension::INVALID)));
+ Extension::INVALID,
+ Extension::FROM_BOOKMARK)));
}
#endif
}
diff --git a/chrome/browser/extensions/external_extension_provider_impl.h b/chrome/browser/extensions/external_extension_provider_impl.h
index 65b6afc..343c82e 100644
--- a/chrome/browser/extensions/external_extension_provider_impl.h
+++ b/chrome/browser/extensions/external_extension_provider_impl.h
@@ -38,7 +38,8 @@ class ExternalExtensionProviderImpl
VisitorInterface* service,
ExternalExtensionLoader* loader,
Extension::Location crx_location,
- Extension::Location download_location);
+ Extension::Location download_location,
+ int creation_flags);
virtual ~ExternalExtensionProviderImpl();
@@ -93,6 +94,10 @@ class ExternalExtensionProviderImpl
// via |SetPrefs|.
scoped_refptr<ExternalExtensionLoader> loader_;
+ // Creation flags to use for the extension. These flags will be used
+ // when calling Extenion::Create() by the crx installer.
+ int creation_flags_;
+
DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl);
};
diff --git a/chrome/browser/extensions/external_extension_provider_interface.h b/chrome/browser/extensions/external_extension_provider_interface.h
index f01408e..16344d2 100644
--- a/chrome/browser/extensions/external_extension_provider_interface.h
+++ b/chrome/browser/extensions/external_extension_provider_interface.h
@@ -29,7 +29,8 @@ class ExternalExtensionProviderInterface {
const std::string& id,
const Version* version,
const FilePath& path,
- Extension::Location location) = 0;
+ Extension::Location location,
+ int creation_flags) = 0;
virtual void OnExternalExtensionUpdateUrlFound(
const std::string& id,
diff --git a/chrome/browser/extensions/external_policy_extension_loader_unittest.cc b/chrome/browser/extensions/external_policy_extension_loader_unittest.cc
index 72d4991..d259711 100644
--- a/chrome/browser/extensions/external_policy_extension_loader_unittest.cc
+++ b/chrome/browser/extensions/external_policy_extension_loader_unittest.cc
@@ -53,7 +53,8 @@ class MockExternalPolicyExtensionProviderVisitor
this,
new ExternalPolicyExtensionLoader(profile_.get()),
Extension::INVALID,
- Extension::EXTERNAL_POLICY_DOWNLOAD));
+ Extension::EXTERNAL_POLICY_DOWNLOAD,
+ Extension::NO_FLAGS));
// Extensions will be removed from this list as they visited,
// so it should be emptied by the end.
@@ -65,7 +66,8 @@ class MockExternalPolicyExtensionProviderVisitor
virtual void OnExternalExtensionFileFound(const std::string& id,
const Version* version,
const FilePath& path,
- Extension::Location unused) {
+ Extension::Location unused,
+ int unused2) {
ADD_FAILURE() << "There should be no external extensions from files.";
}
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
index 3570837..ba128a6 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc
@@ -112,10 +112,12 @@ void RecordSuccessfulUnpackTimeHistograms(
SandboxedExtensionUnpacker::SandboxedExtensionUnpacker(
const FilePath& crx_path,
ResourceDispatcherHost* rdh,
+ int creation_flags,
SandboxedExtensionUnpackerClient* client)
: crx_path_(crx_path),
thread_identifier_(BrowserThread::ID_COUNT),
- rdh_(rdh), client_(client), got_response_(false) {
+ rdh_(rdh), client_(client), got_response_(false),
+ creation_flags_(creation_flags) {
}
bool SandboxedExtensionUnpacker::CreateTempDirectory() {
@@ -296,7 +298,7 @@ void SandboxedExtensionUnpacker::OnUnpackExtensionSucceeded(
extension_root_,
Extension::INTERNAL,
*final_manifest,
- Extension::REQUIRE_KEY,
+ Extension::REQUIRE_KEY | creation_flags_,
&error);
if (!extension_.get()) {
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.h b/chrome/browser/extensions/sandboxed_extension_unpacker.h
index 6204876..f8230bc 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker.h
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker.h
@@ -101,7 +101,8 @@ class SandboxedExtensionUnpacker : public UtilityProcessHost::Client {
// sandboxed subprocess. Otherwise, it is done in-process.
SandboxedExtensionUnpacker(const FilePath& crx_path,
ResourceDispatcherHost* rdh,
- SandboxedExtensionUnpackerClient* cilent);
+ int creation_flags,
+ SandboxedExtensionUnpackerClient* client);
// Start unpacking the extension. The client is called with the results.
void Start();
@@ -240,6 +241,10 @@ class SandboxedExtensionUnpacker : public UtilityProcessHost::Client {
// Time at which unpacking started. Used to compute the time unpacking takes.
base::TimeTicks unpack_start_time_;
+
+ // Creation flags to use for the extension. These flags will be used
+ // when calling Extenion::Create() by the crx installer.
+ int creation_flags_;
};
#endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_EXTENSION_UNPACKER_H_
diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
index f37d06b..7dffefa 100644
--- a/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
+++ b/chrome/browser/extensions/sandboxed_extension_unpacker_unittest.cc
@@ -96,7 +96,8 @@ class SandboxedExtensionUnpackerTest : public testing::Test {
ASSERT_TRUE(file_util::CreateDirectory(temp_path_));
sandboxed_unpacker_ =
- new SandboxedExtensionUnpacker(crx_path, NULL, client_);
+ new SandboxedExtensionUnpacker(crx_path, NULL, Extension::NO_FLAGS,
+ client_);
// Hack since SandboxedExtensionUnpacker gets its background thread id from
// the Start call, but we don't call it here.