Make the "id" key for extension manifests optional in
--load-extension mode. This makes this mode more convenient, and
should lead to less copy-and-paste of extension IDs.

Also, remove the "format_version" key. This is basically
duplicated in the code that checks the version number of the crx
file format. And if we ever really need a format version for the
manifest, we can always add it later.

Review URL: http://codereview.chromium.org/56044

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12837 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index 4d4b4f7c..abdaef88 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -319,3 +319,33 @@
   EXPECT_EQ(1u, GetErrors().size());
   ASSERT_EQ(1u, frontend->extensions()->size());
 }
+
+TEST_F(ExtensionsServiceTest, GenerateID) {
+  FilePath extensions_path;
+  ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path));
+  extensions_path = extensions_path.AppendASCII("extensions");
+
+  scoped_refptr<ExtensionsServiceBackend> backend(
+      new ExtensionsServiceBackend(extensions_path));
+  scoped_refptr<ExtensionsServiceTestFrontend> frontend(
+      new ExtensionsServiceTestFrontend);
+
+  FilePath no_id_ext = extensions_path.AppendASCII("no_id");
+  backend->LoadSingleExtension(no_id_ext,
+      scoped_refptr<ExtensionsServiceFrontendInterface>(frontend.get()));
+  frontend->GetMessageLoop()->RunAllPending();
+  EXPECT_EQ(0u, GetErrors().size());
+  ASSERT_EQ(1u, frontend->extensions()->size());
+  std::string id1 = frontend->extensions()->at(0)->id();
+  ASSERT_EQ("0000000000000000000000000000000000000000", id1);
+  ASSERT_EQ("chrome-extension://0000000000000000000000000000000000000000/",
+            frontend->extensions()->at(0)->url().spec());
+
+  backend->LoadSingleExtension(no_id_ext,
+      scoped_refptr<ExtensionsServiceFrontendInterface>(frontend.get()));
+  frontend->GetMessageLoop()->RunAllPending();
+  std::string id2 = frontend->extensions()->at(1)->id();
+  ASSERT_EQ("0000000000000000000000000000000000000001", id2);
+  ASSERT_EQ("chrome-extension://0000000000000000000000000000000000000001/",
+            frontend->extensions()->at(1)->url().spec());
+}