summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-18 19:24:57 +0000
committermpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-18 19:24:57 +0000
commit9288808841602769a316568cb6d14ed6b6d988dc (patch)
treed77d11fcbd565e5a47eb259692d7fa531a944866 /chrome/browser
parent3bb720fd99938e6cbe30c83f7549e51c9065b38b (diff)
downloadchromium_src-9288808841602769a316568cb6d14ed6b6d988dc.zip
chromium_src-9288808841602769a316568cb6d14ed6b6d988dc.tar.gz
chromium_src-9288808841602769a316568cb6d14ed6b6d988dc.tar.bz2
Move the rest of the Extension data into either StaticData or RuntimeData
subclasses. The ultimate goal is to move StaticData back up to the top level, so that Extension itself will be a thread-safe immutable object. I plan on making Extension refcounted, and const everywhere that it doesn't need to be initialized. RuntimeData will be the only thing mutable, and then only on the UI thread. BUG=56550 TEST=extensions still work Review URL: http://codereview.chromium.org/3757001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62957 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/crx_installer.cc5
-rw-r--r--chrome/browser/extensions/extension_creator.cc1
-rw-r--r--chrome/browser/extensions/extension_updater_unittest.cc22
-rw-r--r--chrome/browser/extensions/extensions_service.cc8
-rw-r--r--chrome/browser/extensions/test_extension_prefs.cc7
-rw-r--r--chrome/browser/extensions/test_extension_prefs.h5
-rw-r--r--chrome/browser/sync/glue/extension_util_unittest.cc4
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc2
8 files changed, 28 insertions, 26 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc
index abb2259..6f34b3c 100644
--- a/chrome/browser/extensions/crx_installer.cc
+++ b/chrome/browser/extensions/crx_installer.cc
@@ -351,10 +351,9 @@ void CrxInstaller::CompleteInstall() {
// TODO(aa): All paths to resources inside extensions should be created
// lazily and based on the Extension's root path at that moment.
std::string error;
- extension_.reset(extension_file_util::LoadExtension(version_dir, true,
- &error));
+ extension_.reset(extension_file_util::LoadExtension(
+ version_dir, install_source_, true, &error));
DCHECK(error.empty());
- extension_->set_location(install_source_);
ReportSuccessFromFileThread();
}
diff --git a/chrome/browser/extensions/extension_creator.cc b/chrome/browser/extensions/extension_creator.cc
index b38618d..86c78fe 100644
--- a/chrome/browser/extensions/extension_creator.cc
+++ b/chrome/browser/extensions/extension_creator.cc
@@ -58,6 +58,7 @@ bool ExtensionCreator::InitializeInput(
// useful validation of the structure.
scoped_ptr<Extension> extension(
extension_file_util::LoadExtension(extension_dir,
+ Extension::INTERNAL,
false, // key not required
&error_message_));
if (!extension.get())
diff --git a/chrome/browser/extensions/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc
index 25d40c4..7989e7a 100644
--- a/chrome/browser/extensions/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/extension_updater_unittest.cc
@@ -84,7 +84,8 @@ class MockService : public ExtensionUpdateService {
// version are all based on their index. If |update_url| is non-null, it
// will be used as the update_url for each extension.
void CreateTestExtensions(int count, ExtensionList *list,
- const std::string* update_url) {
+ const std::string* update_url,
+ Extension::Location location) {
for (int i = 1; i <= count; i++) {
DictionaryValue manifest;
manifest.SetString(extension_manifest_keys::kVersion,
@@ -93,7 +94,7 @@ class MockService : public ExtensionUpdateService {
base::StringPrintf("Extension %d", i));
if (update_url)
manifest.SetString(extension_manifest_keys::kUpdateURL, *update_url);
- Extension* e = prefs_.AddExtensionWithManifest(manifest);
+ Extension* e = prefs_.AddExtensionWithManifest(manifest, location);
ASSERT_TRUE(e != NULL);
list->push_back(e);
}
@@ -294,7 +295,8 @@ class ExtensionUpdaterTest : public testing::Test {
CreateTestPendingExtensions(1, GURL(update_url), &pending_extensions);
service.set_pending_extensions(pending_extensions);
} else {
- service.CreateTestExtensions(1, &extensions, &update_url);
+ service.CreateTestExtensions(1, &extensions, &update_url,
+ Extension::INTERNAL);
service.set_extensions(extensions);
}
@@ -405,7 +407,7 @@ class ExtensionUpdaterTest : public testing::Test {
// Create a set of test extensions
ServiceForManifestTests service;
ExtensionList tmp;
- service.CreateTestExtensions(3, &tmp, NULL);
+ service.CreateTestExtensions(3, &tmp, NULL, Extension::INTERNAL);
service.set_extensions(tmp);
MessageLoop message_loop;
@@ -724,8 +726,10 @@ class ExtensionUpdaterTest : public testing::Test {
ExtensionList tmp;
GURL url1("http://clients2.google.com/service/update2/crx");
GURL url2("http://www.somewebsite.com");
- service.CreateTestExtensions(1, &tmp, &url1.possibly_invalid_spec());
- service.CreateTestExtensions(1, &tmp, &url2.possibly_invalid_spec());
+ service.CreateTestExtensions(1, &tmp, &url1.possibly_invalid_spec(),
+ Extension::INTERNAL);
+ service.CreateTestExtensions(1, &tmp, &url2.possibly_invalid_spec(),
+ Extension::INTERNAL);
EXPECT_EQ(2u, tmp.size());
service.set_extensions(tmp);
@@ -800,7 +804,8 @@ class ExtensionUpdaterTest : public testing::Test {
GURL update_url("http://www.google.com/manifest");
ExtensionList tmp;
- service.CreateTestExtensions(1, &tmp, &update_url.spec());
+ service.CreateTestExtensions(1, &tmp, &update_url.spec(),
+ Extension::INTERNAL);
service.set_extensions(tmp);
ManifestFetchData fetch_data(update_url);
@@ -885,9 +890,8 @@ TEST(ExtensionUpdaterTest, TestManifestFetchesBuilderAddExtension) {
// Non-internal non-external extensions should be rejected.
{
ExtensionList extensions;
- service.CreateTestExtensions(1, &extensions, NULL);
+ service.CreateTestExtensions(1, &extensions, NULL, Extension::INVALID);
ASSERT_FALSE(extensions.empty());
- extensions[0]->set_location(Extension::INVALID);
builder.AddExtension(*extensions[0]);
EXPECT_TRUE(builder.GetFetches().empty());
STLDeleteElements(&extensions);
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index acff4a6..af187b15 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -310,6 +310,7 @@ void ExtensionsServiceBackend::LoadSingleExtension(
std::string error;
Extension* extension = extension_file_util::LoadExtension(
extension_path,
+ Extension::LOAD,
false, // Don't require id
&error);
@@ -318,8 +319,6 @@ void ExtensionsServiceBackend::LoadSingleExtension(
return;
}
- extension->set_location(Extension::LOAD);
-
// Report this as an installed extension so that it gets remembered in the
// prefs.
BrowserThread::PostTask(
@@ -461,7 +460,7 @@ void ExtensionsServiceBackend::ReloadExtensionManifests(
// We need to reload original manifest in order to localize properly.
std::string error;
scoped_ptr<Extension> extension(extension_file_util::LoadExtension(
- info->extension_path, false, &error));
+ info->extension_path, info->extension_location, false, &error));
if (extension.get())
extensions_to_reload->at(i)->extension_manifest.reset(
@@ -1080,6 +1079,7 @@ void ExtensionsService::LoadInstalledExtension(const ExtensionInfo& info,
} else if (info.extension_manifest.get()) {
scoped_ptr<Extension> tmp(new Extension(info.extension_path));
bool require_key = info.extension_location != Extension::LOAD;
+ tmp->set_location(info.extension_location);
if (tmp->InitFromValue(*info.extension_manifest, require_key, &error))
extension = tmp.release();
} else {
@@ -1094,8 +1094,6 @@ void ExtensionsService::LoadInstalledExtension(const ExtensionInfo& info,
return;
}
- extension->set_location(info.extension_location);
-
if (write_to_prefs)
extension_prefs_->UpdateManifest(extension);
diff --git a/chrome/browser/extensions/test_extension_prefs.cc b/chrome/browser/extensions/test_extension_prefs.cc
index 8a5107d..a32f847 100644
--- a/chrome/browser/extensions/test_extension_prefs.cc
+++ b/chrome/browser/extensions/test_extension_prefs.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/extensions/test_extension_prefs.h"
-
#include "base/file_util.h"
#include "base/message_loop.h"
#include "base/scoped_ptr.h"
@@ -50,18 +49,18 @@ Extension* TestExtensionPrefs::AddExtension(std::string name) {
DictionaryValue dictionary;
dictionary.SetString(extension_manifest_keys::kName, name);
dictionary.SetString(extension_manifest_keys::kVersion, "0.1");
- return AddExtensionWithManifest(dictionary);
+ return AddExtensionWithManifest(dictionary, Extension::INTERNAL);
}
Extension* TestExtensionPrefs::AddExtensionWithManifest(
- const DictionaryValue& manifest) {
+ const DictionaryValue& manifest, Extension::Location location) {
std::string name;
EXPECT_TRUE(manifest.GetString(extension_manifest_keys::kName, &name));
FilePath path = extensions_dir_.AppendASCII(name);
Extension* extension = new Extension(path);
std::string errors;
+ extension->set_location(location);
EXPECT_TRUE(extension->InitFromValue(manifest, false, &errors));
- extension->set_location(Extension::INTERNAL);
EXPECT_TRUE(Extension::IdIsValid(extension->id()));
const bool kInitialIncognitoEnabled = false;
prefs_->OnExtensionInstalled(extension, Extension::ENABLED,
diff --git a/chrome/browser/extensions/test_extension_prefs.h b/chrome/browser/extensions/test_extension_prefs.h
index b071281..1523bee 100644
--- a/chrome/browser/extensions/test_extension_prefs.h
+++ b/chrome/browser/extensions/test_extension_prefs.h
@@ -10,9 +10,9 @@
#include "base/scoped_ptr.h"
#include "base/scoped_temp_dir.h"
+#include "chrome/common/extensions/extension.h"
class DictionaryValue;
-class Extension;
class ExtensionPrefs;
class PrefService;
@@ -37,7 +37,8 @@ class TestExtensionPrefs {
Extension* AddExtension(std::string name);
// Similar to AddExtension, but takes a dictionary with manifest values.
- Extension* AddExtensionWithManifest(const DictionaryValue& manifest);
+ Extension* AddExtensionWithManifest(const DictionaryValue& manifest,
+ Extension::Location location);
// Similar to AddExtension, this adds a new test Extension. This is useful for
// cases when you don't need the Extension object, but just the id it was
diff --git a/chrome/browser/sync/glue/extension_util_unittest.cc b/chrome/browser/sync/glue/extension_util_unittest.cc
index 1396b2e..56cf24e 100644
--- a/chrome/browser/sync/glue/extension_util_unittest.cc
+++ b/chrome/browser/sync/glue/extension_util_unittest.cc
@@ -74,9 +74,9 @@ void MakeExtension(bool is_theme, const GURL& update_url,
return;
}
#endif
+ extension->set_location(location);
EXPECT_TRUE(extension->InitFromValue(source, false, &error));
EXPECT_EQ("", error);
- extension->set_location(location);
}
TEST_F(ExtensionUtilTest, GetExtensionType) {
@@ -459,9 +459,9 @@ void MakeSyncableExtension(const std::string& version_string,
source.SetString(extension_manifest_keys::kUpdateURL, update_url_spec);
source.SetString(extension_manifest_keys::kName, name);
std::string error;
+ extension->set_location(Extension::INTERNAL);
EXPECT_TRUE(extension->InitFromValue(source, false, &error));
EXPECT_EQ("", error);
- extension->set_location(Extension::INTERNAL);
}
TEST_F(ExtensionUtilTest, GetExtensionSpecificsHelper) {
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index c85d80f..976509f 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -1512,7 +1512,7 @@ TEST_F(TabStripModelTest, Apps) {
FilePath path(FILE_PATH_LITERAL("/foo"));
#endif
Extension extension_app(path);
- extension_app.launch_web_url_ = "http://www.google.com";
+ extension_app.mutable_static_data_->launch_web_url = "http://www.google.com";
TabContents* contents1 = CreateTabContents();
contents1->SetExtensionApp(&extension_app);
TabContents* contents2 = CreateTabContents();