summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/app_shim/DEPS1
-rw-r--r--apps/app_shim/extension_app_shim_handler_mac.cc3
-rw-r--r--chrome/browser/DEPS1
-rw-r--r--chrome/browser/apps/ephemeral_app_throttle.cc3
-rw-r--r--chrome/browser/apps/install_chrome_app.cc4
-rw-r--r--chrome/browser/chromeos/app_mode/startup_app_launcher.cc3
-rw-r--r--chrome/browser/extensions/active_script_controller.cc3
-rw-r--r--chrome/browser/extensions/active_script_controller_unittest.cc4
-rw-r--r--chrome/browser/extensions/all_urls_apitest.cc6
-rw-r--r--chrome/browser/extensions/api/identity/identity_apitest.cc6
-rw-r--r--chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc7
-rw-r--r--chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc6
-rw-r--r--chrome/browser/extensions/api/webstore_private/webstore_private_api.cc5
-rw-r--r--chrome/browser/extensions/chrome_app_sorting_unittest.cc3
-rw-r--r--chrome/browser/extensions/component_loader.cc4
-rw-r--r--chrome/browser/extensions/error_console/error_console.cc11
-rw-r--r--chrome/browser/extensions/error_console/error_console_unittest.cc30
-rw-r--r--chrome/browser/extensions/extension_creator.cc4
-rw-r--r--chrome/browser/extensions/extension_function_test_utils.cc4
-rw-r--r--chrome/browser/extensions/extension_garbage_collector.cc3
-rw-r--r--chrome/browser/extensions/extension_icon_manager_unittest.cc4
-rw-r--r--chrome/browser/extensions/extension_install_ui_browsertest.cc4
-rw-r--r--chrome/browser/extensions/extension_service.cc5
-rw-r--r--chrome/browser/extensions/extension_service_unittest.cc3
-rw-r--r--chrome/browser/extensions/extension_sync_data.cc5
-rw-r--r--chrome/browser/extensions/extension_toolbar_model_unittest.cc4
-rw-r--r--chrome/browser/extensions/external_provider_impl.cc3
-rw-r--r--chrome/browser/extensions/external_registry_loader_win.cc4
-rw-r--r--chrome/browser/extensions/policy_handlers.cc6
-rw-r--r--chrome/browser/extensions/sandboxed_unpacker.cc4
-rw-r--r--chrome/browser/extensions/shared_module_service_unittest.cc51
-rw-r--r--chrome/browser/extensions/startup_helper.cc5
-rw-r--r--chrome/browser/extensions/test_extension_prefs.cc3
-rw-r--r--chrome/browser/extensions/unpacked_installer.cc4
-rw-r--r--chrome/browser/extensions/updater/extension_updater_unittest.cc15
-rw-r--r--chrome/browser/extensions/updater/local_extension_cache.cc4
-rw-r--r--chrome/browser/extensions/webstore_installer.cc3
-rw-r--r--chrome/browser/extensions/webstore_installer_unittest.cc4
-rw-r--r--chrome/browser/extensions/webstore_standalone_installer.cc3
-rw-r--r--chrome/browser/guest_view/extension_options/extension_options_guest.cc5
-rw-r--r--chrome/browser/media_galleries/media_galleries_preferences.cc6
-rw-r--r--chrome/browser/media_galleries/media_galleries_test_util.cc6
-rw-r--r--chrome/browser/profile_resetter/brandcoded_default_settings.cc4
-rw-r--r--chrome/browser/sync/test/integration/sync_app_helper.cc11
-rw-r--r--chrome/browser/sync/test/integration/sync_extension_helper.cc18
-rw-r--r--chrome/browser/sync/test/integration/themes_helper.cc5
-rw-r--r--chrome/browser/themes/browser_theme_pack.cc9
-rw-r--r--chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc6
-rw-r--r--chrome/browser/web_applications/web_app_mac.mm3
-rw-r--r--chrome/common/DEPS1
-rw-r--r--chrome/common/extensions/extension_unittest.cc23
-rw-r--r--chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc3
-rw-r--r--chrome/common/pepper_permission_util_unittest.cc13
-rw-r--r--chrome/renderer/DEPS1
-rw-r--r--chrome/renderer/extensions/webstore_bindings.cc3
-rw-r--r--chrome/renderer/searchbox/searchbox_extension.cc4
-rw-r--r--components/BUILD.gn1
-rw-r--r--components/component_updater/component_updater_utils.cc4
-rw-r--r--components/components_tests.gyp4
-rw-r--r--components/crx_file.gypi2
-rw-r--r--components/crx_file/BUILD.gn13
-rw-r--r--components/crx_file/DEPS3
-rw-r--r--components/crx_file/id_util.cc (renamed from extensions/common/id_util.cc)28
-rw-r--r--components/crx_file/id_util.h (renamed from extensions/common/id_util.h)16
-rw-r--r--components/crx_file/id_util_unittest.cc44
-rw-r--r--extensions/BUILD.gn1
-rw-r--r--extensions/browser/api/api_resource_manager_unittest.cc1
-rw-r--r--extensions/browser/api/storage/storage_api_unittest.cc1
-rw-r--r--extensions/browser/error_map_unittest.cc10
-rw-r--r--extensions/browser/extension_message_filter.cc5
-rw-r--r--extensions/browser/extension_prefs.cc37
-rw-r--r--extensions/browser/external_provider_interface.h3
-rw-r--r--extensions/browser/file_reader_unittest.cc6
-rw-r--r--extensions/browser/verified_contents.cc3
-rw-r--r--extensions/common/BUILD.gn3
-rw-r--r--extensions/common/extension.cc24
-rw-r--r--extensions/common/extension.h3
-rw-r--r--extensions/common/extension_resource_unittest.cc8
-rw-r--r--extensions/common/id_util_unittest.cc44
-rw-r--r--extensions/common/manifest_handlers/externally_connectable.cc3
-rw-r--r--extensions/common/manifest_handlers/shared_module_info.cc9
-rw-r--r--extensions/common/permissions/permissions_data_unittest.cc6
-rw-r--r--extensions/extensions.gyp3
-rw-r--r--extensions/renderer/user_script_set_manager.cc3
84 files changed, 356 insertions, 298 deletions
diff --git a/apps/app_shim/DEPS b/apps/app_shim/DEPS
index e836a97..230115e 100644
--- a/apps/app_shim/DEPS
+++ b/apps/app_shim/DEPS
@@ -13,5 +13,6 @@ include_rules = [
"+chrome/common/chrome_paths.h",
"+chrome/common/extensions/extension_constants.h",
"+chrome/common/mac/app_mode_common.h",
+ "+components/crx_file",
"+grit/generated_resources.h",
]
diff --git a/apps/app_shim/extension_app_shim_handler_mac.cc b/apps/app_shim/extension_app_shim_handler_mac.cc
index 2fa33a1..f15ad4e 100644
--- a/apps/app_shim/extension_app_shim_handler_mac.cc
+++ b/apps/app_shim/extension_app_shim_handler_mac.cc
@@ -21,6 +21,7 @@
#include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
#include "chrome/browser/web_applications/web_app_mac.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
@@ -313,7 +314,7 @@ void ExtensionAppShimHandler::OnShimLaunch(
AppShimLaunchType launch_type,
const std::vector<base::FilePath>& files) {
const std::string& app_id = host->GetAppId();
- DCHECK(extensions::Extension::IdIsValid(app_id));
+ DCHECK(crx_file::id_util::IdIsValid(app_id));
const base::FilePath& profile_path = host->GetProfilePath();
DCHECK(!profile_path.empty());
diff --git a/chrome/browser/DEPS b/chrome/browser/DEPS
index c3a17d6..1aa16d9 100644
--- a/chrome/browser/DEPS
+++ b/chrome/browser/DEPS
@@ -22,6 +22,7 @@ include_rules = [
"+components/component_updater",
"+components/content_settings",
"+components/copresence",
+ "+components/crx_file",
"+components/data_reduction_proxy",
"+components/dom_distiller",
"+components/domain_reliability",
diff --git a/chrome/browser/apps/ephemeral_app_throttle.cc b/chrome/browser/apps/ephemeral_app_throttle.cc
index d4b0407..504e1b0 100644
--- a/chrome/browser/apps/ephemeral_app_throttle.cc
+++ b/chrome/browser/apps/ephemeral_app_throttle.cc
@@ -11,6 +11,7 @@
#include "chrome/browser/profiles/profile_io_data.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "components/crx_file/id_util.h"
#include "components/navigation_interception/intercept_navigation_resource_throttle.h"
#include "components/navigation_interception/navigation_params.h"
#include "content/public/browser/browser_thread.h"
@@ -91,7 +92,7 @@ EphemeralAppThrottle::MaybeCreateThrottleForLaunch(
return NULL;
std::string app_id(request->url().ExtractFileName());
- if (!Extension::IdIsValid(app_id))
+ if (!crx_file::id_util::IdIsValid(app_id))
return NULL;
return new navigation_interception::InterceptNavigationResourceThrottle(
diff --git a/chrome/browser/apps/install_chrome_app.cc b/chrome/browser/apps/install_chrome_app.cc
index e433991..525f31e 100644
--- a/chrome/browser/apps/install_chrome_app.cc
+++ b/chrome/browser/apps/install_chrome_app.cc
@@ -15,8 +15,8 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/extensions/webstore_install_result.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_registry.h"
-#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
using extensions::ExtensionRegistry;
@@ -74,7 +74,7 @@ void WebstoreInstallWithPromptAppsOnly::OnManifestParsed() {
namespace install_chrome_app {
void InstallChromeApp(const std::string& app_id) {
- if (!extensions::Extension::IdIsValid(app_id))
+ if (!crx_file::id_util::IdIsValid(app_id))
return;
// At the moment InstallChromeApp() is called immediately after handling
diff --git a/chrome/browser/chromeos/app_mode/startup_app_launcher.cc b/chrome/browser/chromeos/app_mode/startup_app_launcher.cc
index 5e7d1bf..8dfd0dd 100644
--- a/chrome/browser/chromeos/app_mode/startup_app_launcher.cc
+++ b/chrome/browser/chromeos/app_mode/startup_app_launcher.cc
@@ -27,6 +27,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/manifest_url_handler.h"
+#include "components/crx_file/id_util.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/user_manager/user_manager.h"
@@ -76,7 +77,7 @@ StartupAppLauncher::StartupAppLauncher(Profile* profile,
ready_to_launch_(false),
wait_for_crx_update_(false) {
DCHECK(profile_);
- DCHECK(Extension::IdIsValid(app_id_));
+ DCHECK(crx_file::id_util::IdIsValid(app_id_));
KioskAppManager::Get()->AddObserver(this);
}
diff --git a/chrome/browser/extensions/active_script_controller.cc b/chrome/browser/extensions/active_script_controller.cc
index d822907..6920b88 100644
--- a/chrome/browser/extensions/active_script_controller.cc
+++ b/chrome/browser/extensions/active_script_controller.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/session_tab_helper.h"
#include "chrome/common/extensions/api/extension_action/action_info.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_view_host.h"
@@ -269,7 +270,7 @@ void ActiveScriptController::OnRequestScriptInjectionPermission(
const std::string& extension_id,
UserScript::InjectionType script_type,
int64 request_id) {
- if (!Extension::IdIsValid(extension_id)) {
+ if (!crx_file::id_util::IdIsValid(extension_id)) {
NOTREACHED() << "'" << extension_id << "' is not a valid id.";
return;
}
diff --git a/chrome/browser/extensions/active_script_controller_unittest.cc b/chrome/browser/extensions/active_script_controller_unittest.cc
index 4ee5a54..f816f6d 100644
--- a/chrome/browser/extensions/active_script_controller_unittest.cc
+++ b/chrome/browser/extensions/active_script_controller_unittest.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
@@ -19,7 +20,6 @@
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/feature_switch.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest.h"
#include "extensions/common/user_script.h"
#include "extensions/common/value_builder.h"
@@ -95,7 +95,7 @@ ActiveScriptControllerUnitTest::~ActiveScriptControllerUnitTest() {
}
const Extension* ActiveScriptControllerUnitTest::AddExtension() {
- const std::string kId = id_util::GenerateId("all_hosts_extension");
+ const std::string kId = crx_file::id_util::GenerateId("all_hosts_extension");
extension_ = ExtensionBuilder()
.SetManifest(
DictionaryBuilder()
diff --git a/chrome/browser/extensions/all_urls_apitest.cc b/chrome/browser/extensions/all_urls_apitest.cc
index 8b59028..b83a7f6 100644
--- a/chrome/browser/extensions/all_urls_apitest.cc
+++ b/chrome/browser/extensions/all_urls_apitest.cc
@@ -10,10 +10,10 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/test_switches.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/extensions_client.h"
-#include "extensions/common/id_util.h"
const std::string kAllUrlsTarget =
"files/extensions/api_test/all_urls/index.html";
@@ -41,8 +41,8 @@ IN_PROC_BROWSER_TEST_F(AllUrlsApiTest, MAYBE_WhitelistedExtension) {
// Then add the two extensions to the whitelist.
extensions::ExtensionsClient::ScriptingWhitelist whitelist;
- whitelist.push_back(extensions::id_util::GenerateIdForPath(extension_dir1));
- whitelist.push_back(extensions::id_util::GenerateIdForPath(extension_dir2));
+ whitelist.push_back(crx_file::id_util::GenerateIdForPath(extension_dir1));
+ whitelist.push_back(crx_file::id_util::GenerateIdForPath(extension_dir2));
extensions::ExtensionsClient::Get()->SetScriptingWhitelist(whitelist);
// Then load extensions.
diff --git a/chrome/browser/extensions/api/identity/identity_apitest.cc b/chrome/browser/extensions/api/identity/identity_apitest.cc
index ac2a9cf..337fb2a 100644
--- a/chrome/browser/extensions/api/identity/identity_apitest.cc
+++ b/chrome/browser/extensions/api/identity/identity_apitest.cc
@@ -33,6 +33,7 @@
#include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/test_switches.h"
+#include "components/crx_file/id_util.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "components/signin/core/common/signin_pref_names.h"
@@ -40,7 +41,6 @@
#include "content/public/browser/notification_source.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/guest_view/guest_view_base.h"
-#include "extensions/common/id_util.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "google_apis/gaia/oauth2_mint_token_flow.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
@@ -1607,7 +1607,7 @@ class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest {
}
void SetCachedToken(IdentityTokenCacheValue& token_data) {
- ExtensionTokenKey key(extensions::id_util::GenerateId(kExtensionId),
+ ExtensionTokenKey key(crx_file::id_util::GenerateId(kExtensionId),
"test@example.com",
std::set<std::string>());
id_api()->SetCachedToken(key, token_data);
@@ -1615,7 +1615,7 @@ class RemoveCachedAuthTokenFunctionTest : public ExtensionBrowserTest {
const IdentityTokenCacheValue& GetCachedToken() {
return id_api()->GetCachedToken(
- ExtensionTokenKey(extensions::id_util::GenerateId(kExtensionId),
+ ExtensionTokenKey(crx_file::id_util::GenerateId(kExtensionId),
"test@example.com",
std::set<std::string>()));
}
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc
index b642967..6f091b5 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler.cc
@@ -10,6 +10,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler_delegate.h"
+#include "components/crx_file/id_util.h"
#include "components/invalidation/invalidation_service.h"
#include "components/invalidation/object_id_invalidation_map.h"
#include "extensions/common/extension.h"
@@ -60,7 +61,7 @@ bool ObjectIdToExtensionAndSubchannel(const invalidation::ObjectId& object_id,
DLOG(WARNING) << "Invalid format type from object name " << name;
return false;
}
- if (!Extension::IdIsValid(components[1])) {
+ if (!crx_file::id_util::IdIsValid(components[1])) {
DLOG(WARNING) << "Invalid extension ID from object name " << name;
return false;
}
@@ -103,7 +104,7 @@ void PushMessagingInvalidationHandler::SuppressInitialInvalidationsForExtension(
void PushMessagingInvalidationHandler::RegisterExtension(
const std::string& extension_id) {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
registered_extensions_.insert(extension_id);
UpdateRegistrations();
}
@@ -111,7 +112,7 @@ void PushMessagingInvalidationHandler::RegisterExtension(
void PushMessagingInvalidationHandler::UnregisterExtension(
const std::string& extension_id) {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
registered_extensions_.erase(extension_id);
UpdateRegistrations();
}
diff --git a/chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc b/chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc
index 322ae82..9b41995 100644
--- a/chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc
+++ b/chrome/browser/extensions/api/signed_in_devices/id_mapping_helper.cc
@@ -12,7 +12,7 @@
#include "chrome/browser/extensions/api/signed_in_devices/signed_in_devices_api.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/glue/device_info.h"
-#include "extensions/common/extension.h"
+#include "components/crx_file/id_util.h"
using base::DictionaryValue;
using base::Value;
@@ -88,8 +88,8 @@ scoped_ptr<DeviceInfo> GetDeviceInfoForClientId(
const std::string& client_id,
const std::string& extension_id,
Profile* profile) {
- DCHECK(Extension::IdIsValid(extension_id)) << extension_id
- << " is not valid";
+ DCHECK(crx_file::id_util::IdIsValid(extension_id)) << extension_id
+ << " is not valid";
ScopedVector<DeviceInfo> devices = GetAllSignedInDevices(extension_id,
profile);
for (ScopedVector<DeviceInfo>::iterator it = devices.begin();
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
index addd6ca..66915fe 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -36,6 +36,7 @@
#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
+#include "components/crx_file/id_util.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "content/public/browser/gpu_data_manager.h"
@@ -237,7 +238,7 @@ bool WebstorePrivateBeginInstallWithManifest3Function::RunAsync() {
params_ = BeginInstallWithManifest3::Params::Create(*args_);
EXTENSION_FUNCTION_VALIDATE(params_);
- if (!extensions::Extension::IdIsValid(params_->details.id)) {
+ if (!crx_file::id_util::IdIsValid(params_->details.id)) {
SetResultCode(INVALID_ID);
error_ = kInvalidIdError;
return false;
@@ -508,7 +509,7 @@ bool WebstorePrivateCompleteInstallFunction::RunAsync() {
scoped_ptr<CompleteInstall::Params> params(
CompleteInstall::Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
- if (!extensions::Extension::IdIsValid(params->expected_id)) {
+ if (!crx_file::id_util::IdIsValid(params->expected_id)) {
error_ = kInvalidIdError;
return false;
}
diff --git a/chrome/browser/extensions/chrome_app_sorting_unittest.cc b/chrome/browser/extensions/chrome_app_sorting_unittest.cc
index 87f72f1..148e4f1 100644
--- a/chrome/browser/extensions/chrome_app_sorting_unittest.cc
+++ b/chrome/browser/extensions/chrome_app_sorting_unittest.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/extensions/./extension_prefs_unittest.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "components/crx_file/id_util.h"
#include "extensions/common/manifest_constants.h"
#include "sync/api/string_ordinal.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -813,7 +814,7 @@ class ChromeAppSortingDefaultOrdinalsBase : public ChromeAppSortingTest {
prefs_.temp_dir().AppendASCII(name), Manifest::EXTERNAL_PREF,
simple_dict, Extension::NO_FLAGS, &errors);
EXPECT_TRUE(app.get()) << errors;
- EXPECT_TRUE(Extension::IdIsValid(app->id()));
+ EXPECT_TRUE(crx_file::id_util::IdIsValid(app->id()));
return app;
}
diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc
index ac35c2b6..6af2018 100644
--- a/chrome/browser/extensions/component_loader.cc
+++ b/chrome/browser/extensions/component_loader.cc
@@ -17,12 +17,12 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/plugin_service.h"
#include "extensions/common/extension.h"
#include "extensions/common/file_util.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest_constants.h"
#include "grit/browser_resources.h"
#include "grit/generated_resources.h"
@@ -66,7 +66,7 @@ std::string GenerateId(const base::DictionaryValue* manifest,
std::string id_input;
CHECK(manifest->GetString(manifest_keys::kPublicKey, &raw_key));
CHECK(Extension::ParsePEMKeyBytes(raw_key, &id_input));
- std::string id = id_util::GenerateId(id_input);
+ std::string id = crx_file::id_util::GenerateId(id_input);
return id;
}
diff --git a/chrome/browser/extensions/error_console/error_console.cc b/chrome/browser/extensions/error_console/error_console.cc
index 35913dc..4c866f2 100644
--- a/chrome/browser/extensions/error_console/error_console.cc
+++ b/chrome/browser/extensions/error_console/error_console.cc
@@ -17,6 +17,7 @@
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/features/feature_channel.h"
#include "chrome/common/pref_names.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
@@ -77,7 +78,7 @@ void ErrorConsole::SetReportingForExtension(const std::string& extension_id,
ExtensionError::Type type,
bool enabled) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!enabled_ || !Extension::IdIsValid(extension_id))
+ if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id))
return;
int mask = default_mask_;
@@ -98,7 +99,7 @@ void ErrorConsole::SetReportingForExtension(const std::string& extension_id,
void ErrorConsole::SetReportingAllForExtension(
const std::string& extension_id, bool enabled) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!enabled_ || !Extension::IdIsValid(extension_id))
+ if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id))
return;
int mask = 0;
@@ -113,7 +114,7 @@ void ErrorConsole::SetReportingAllForExtension(
bool ErrorConsole::IsReportingEnabledForExtension(
const std::string& extension_id) const {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!enabled_ || !Extension::IdIsValid(extension_id))
+ if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id))
return false;
return GetMaskForExtension(extension_id) != 0;
@@ -122,7 +123,7 @@ bool ErrorConsole::IsReportingEnabledForExtension(
void ErrorConsole::UseDefaultReportingForExtension(
const std::string& extension_id) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!enabled_ || !Extension::IdIsValid(extension_id))
+ if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id))
return;
prefs_->UpdateExtensionPref(extension_id, kStoreExtensionErrorsPref, NULL);
@@ -130,7 +131,7 @@ void ErrorConsole::UseDefaultReportingForExtension(
void ErrorConsole::ReportError(scoped_ptr<ExtensionError> error) {
DCHECK(thread_checker_.CalledOnValidThread());
- if (!enabled_ || !Extension::IdIsValid(error->extension_id()))
+ if (!enabled_ || !crx_file::id_util::IdIsValid(error->extension_id()))
return;
int mask = GetMaskForExtension(error->extension_id());
diff --git a/chrome/browser/extensions/error_console/error_console_unittest.cc b/chrome/browser/extensions/error_console/error_console_unittest.cc
index baf522b..d330cbf 100644
--- a/chrome/browser/extensions/error_console/error_console_unittest.cc
+++ b/chrome/browser/extensions/error_console/error_console_unittest.cc
@@ -12,13 +12,13 @@
#include "chrome/common/extensions/features/feature_channel.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_error.h"
#include "extensions/browser/extension_error_test_util.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/feature_switch.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/value_builder.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -128,7 +128,7 @@ TEST_F(ErrorConsoleUnitTest, EnableAndDisableErrorConsole) {
// is tested more thoroughly in extensions/browser/error_map_unittest.cc
TEST_F(ErrorConsoleUnitTest, ReportErrors) {
const size_t kNumTotalErrors = 6;
- const std::string kId = id_util::GenerateId("id");
+ const std::string kId = crx_file::id_util::GenerateId("id");
error_console_->set_default_reporting_for_test(ExtensionError::MANIFEST_ERROR,
true);
ASSERT_EQ(0u, error_console_->GetErrorsForExtension(kId).size());
@@ -149,7 +149,7 @@ TEST_F(ErrorConsoleUnitTest, DontStoreErrorsWithoutEnablingType) {
error_console_->set_default_reporting_for_test(ExtensionError::MANIFEST_ERROR,
true);
- const std::string kId = id_util::GenerateId("id");
+ const std::string kId = crx_file::id_util::GenerateId("id");
// Try to report a runtime error - it should be ignored.
error_console_->ReportError(CreateNewRuntimeError(kId, "a"));
@@ -176,7 +176,7 @@ TEST_F(ErrorConsoleUnitTest, DontStoreErrorsWithoutEnablingType) {
// All other extensions should still use the default mask, and ignore runtime
// errors but report manifest errors.
- const std::string kId2 = id_util::GenerateId("id2");
+ const std::string kId2 = crx_file::id_util::GenerateId("id2");
error_console_->ReportError(CreateNewRuntimeError(kId2, "f"));
ASSERT_EQ(0u, error_console_->GetErrorsForExtension(kId2).size());
error_console_->ReportError(CreateNewManifestError(kId2, "g"));
@@ -197,21 +197,23 @@ TEST_F(ErrorConsoleUnitTest, TestDefaultStoringPrefs) {
// For this, we need actual extensions.
scoped_refptr<const Extension> unpacked_extension =
ExtensionBuilder()
- .SetManifest(DictionaryBuilder().Set("name", "unpacked")
- .Set("version", "0.0.1")
- .Set("manifest_version", 2)
- .Build())
+ .SetManifest(DictionaryBuilder()
+ .Set("name", "unpacked")
+ .Set("version", "0.0.1")
+ .Set("manifest_version", 2)
+ .Build())
.SetLocation(Manifest::UNPACKED)
- .SetID(id_util::GenerateId("unpacked"))
+ .SetID(crx_file::id_util::GenerateId("unpacked"))
.Build();
scoped_refptr<const Extension> packed_extension =
ExtensionBuilder()
- .SetManifest(DictionaryBuilder().Set("name", "packed")
- .Set("version", "0.0.1")
- .Set("manifest_version", 2)
- .Build())
+ .SetManifest(DictionaryBuilder()
+ .Set("name", "packed")
+ .Set("version", "0.0.1")
+ .Set("manifest_version", 2)
+ .Build())
.SetLocation(Manifest::INTERNAL)
- .SetID(id_util::GenerateId("packed"))
+ .SetID(crx_file::id_util::GenerateId("packed"))
.Build();
ExtensionRegistry* registry = ExtensionRegistry::Get(profile_.get());
diff --git a/chrome/browser/extensions/extension_creator.cc b/chrome/browser/extensions/extension_creator.cc
index f6cc4bd..631dd53 100644
--- a/chrome/browser/extensions/extension_creator.cc
+++ b/chrome/browser/extensions/extension_creator.cc
@@ -15,11 +15,11 @@
#include "base/strings/string_util.h"
#include "chrome/browser/extensions/extension_creator_filter.h"
#include "components/crx_file/crx_file.h"
+#include "components/crx_file/id_util.h"
#include "crypto/rsa_private_key.h"
#include "crypto/signature_creator.h"
#include "extensions/common/extension.h"
#include "extensions/common/file_util.h"
-#include "extensions/common/id_util.h"
#include "grit/generated_resources.h"
#include "third_party/zlib/google/zip.h"
#include "ui/base/l10n/l10n_util.h"
@@ -99,7 +99,7 @@ bool ExtensionCreator::ValidateManifest(const base::FilePath& extension_dir,
public_key.insert(public_key.begin(),
public_key_bytes.begin(), public_key_bytes.end());
- std::string extension_id = id_util::GenerateId(public_key);
+ std::string extension_id = crx_file::id_util::GenerateId(public_key);
// Load the extension once. We don't really need it, but this does a lot of
// useful validation of the structure.
diff --git a/chrome/browser/extensions/extension_function_test_utils.cc b/chrome/browser/extensions/extension_function_test_utils.cc
index 4cf8a32..03b4d7f 100644
--- a/chrome/browser/extensions/extension_function_test_utils.cc
+++ b/chrome/browser/extensions/extension_function_test_utils.cc
@@ -13,11 +13,11 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/api_test_utils.h"
#include "extensions/browser/extension_function.h"
#include "extensions/browser/extension_function_dispatcher.h"
#include "extensions/common/extension.h"
-#include "extensions/common/id_util.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::WebContents;
@@ -136,7 +136,7 @@ scoped_refptr<Extension> CreateExtension(
const base::FilePath test_extension_path;
std::string id;
if (!id_input.empty())
- id = extensions::id_util::GenerateId(id_input);
+ id = crx_file::id_util::GenerateId(id_input);
scoped_refptr<Extension> extension(Extension::Create(
test_extension_path,
location,
diff --git a/chrome/browser/extensions/extension_garbage_collector.cc b/chrome/browser/extensions/extension_garbage_collector.cc
index 7701c3c..4d6cb7f 100644
--- a/chrome/browser/extensions/extension_garbage_collector.cc
+++ b/chrome/browser/extensions/extension_garbage_collector.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/extensions/install_tracker.h"
#include "chrome/browser/extensions/pending_extension_manager.h"
#include "chrome/common/extensions/manifest_handlers/app_isolation_info.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
@@ -57,7 +58,7 @@ void CheckExtensionDirectory(const base::FilePath& path,
std::string extension_id;
if (base::IsStringASCII(basename.value())) {
extension_id = base::UTF16ToASCII(basename.LossyDisplayName());
- if (!Extension::IdIsValid(extension_id))
+ if (!crx_file::id_util::IdIsValid(extension_id))
extension_id.clear();
}
diff --git a/chrome/browser/extensions/extension_icon_manager_unittest.cc b/chrome/browser/extensions/extension_icon_manager_unittest.cc
index 3a678095..8dcb5ca 100644
--- a/chrome/browser/extensions/extension_icon_manager_unittest.cc
+++ b/chrome/browser/extensions/extension_icon_manager_unittest.cc
@@ -9,9 +9,9 @@
#include "chrome/browser/extensions/extension_icon_manager.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/crx_file/id_util.h"
#include "content/public/test/test_browser_thread.h"
#include "extensions/common/extension.h"
-#include "extensions/common/id_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/skia_util.h"
@@ -93,7 +93,7 @@ class TestIconManager : public ExtensionIconManager {
// Returns the default icon that ExtensionIconManager gives when an extension
// doesn't have an icon.
SkBitmap GetDefaultIcon() {
- std::string dummy_id = extensions::id_util::GenerateId("whatever");
+ std::string dummy_id = crx_file::id_util::GenerateId("whatever");
ExtensionIconManager manager;
return manager.GetIcon(dummy_id);
}
diff --git a/chrome/browser/extensions/extension_install_ui_browsertest.cc b/chrome/browser/extensions/extension_install_ui_browsertest.cc
index ba9fca2..46629f7 100644
--- a/chrome/browser/extensions/extension_install_ui_browsertest.cc
+++ b/chrome/browser/extensions/extension_install_ui_browsertest.cc
@@ -21,13 +21,13 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/test_switches.h"
#include "chrome/test/base/ui_test_utils.h"
+#include "components/crx_file/id_util.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "components/infobars/core/infobar.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/app_sorting.h"
#include "extensions/browser/extension_prefs.h"
-#include "extensions/common/id_util.h"
using content::WebContents;
using extensions::AppSorting;
@@ -224,7 +224,7 @@ IN_PROC_BROWSER_TEST_F(NewTabUISortingBrowserTest,
ExtensionService* service = extensions::ExtensionSystem::Get(
browser()->profile())->extension_service();
base::FilePath app_dir = test_data_dir_.AppendASCII("app");
- const std::string app_id = extensions::id_util::GenerateIdForPath(app_dir);
+ const std::string app_id = crx_file::id_util::GenerateIdForPath(app_dir);
const extensions::Extension* webstore_extension =
service->GetInstalledExtension(extension_misc::kWebStoreAppId);
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 5ea0e30..895b532 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -56,6 +56,7 @@
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
+#include "components/crx_file/id_util.h"
#include "components/signin/core/browser/signin_manager.h"
#include "components/startup_metric_utils/startup_metric_utils.h"
#include "content/public/browser/devtools_agent_host.h"
@@ -189,7 +190,7 @@ bool ExtensionService::OnExternalExtensionUpdateUrlFound(
int creation_flags,
bool mark_acknowledged) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- CHECK(Extension::IdIsValid(id));
+ CHECK(crx_file::id_util::IdIsValid(id));
if (Manifest::IsExternalLocation(location)) {
// All extensions that are not user specific can be cached.
@@ -1952,7 +1953,7 @@ bool ExtensionService::OnExternalExtensionFileFound(
int creation_flags,
bool mark_acknowledged) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- CHECK(Extension::IdIsValid(id));
+ CHECK(crx_file::id_util::IdIsValid(id));
if (extension_prefs_->IsExternalExtensionUninstalled(id))
return false;
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index 20b589f..cd2db75 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -73,6 +73,7 @@
#include "chrome/common/url_constants.h"
#include "chrome/test/base/scoped_browser_locale.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/crx_file/id_util.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/dom_storage_context.h"
#include "content/public/browser/gpu_data_manager.h"
@@ -4576,7 +4577,7 @@ TEST_F(ExtensionServiceTest, GenerateID) {
base::RunLoop().RunUntilIdle();
EXPECT_EQ(0u, GetErrors().size());
ASSERT_EQ(1u, loaded_.size());
- ASSERT_TRUE(Extension::IdIsValid(loaded_[0]->id()));
+ ASSERT_TRUE(crx_file::id_util::IdIsValid(loaded_[0]->id()));
EXPECT_EQ(loaded_[0]->location(), Manifest::UNPACKED);
ValidatePrefKeyCount(1);
diff --git a/chrome/browser/extensions/extension_sync_data.cc b/chrome/browser/extensions/extension_sync_data.cc
index b401870..7778df5 100644
--- a/chrome/browser/extensions/extension_sync_data.cc
+++ b/chrome/browser/extensions/extension_sync_data.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/extensions/app_sync_data.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/common/extensions/manifest_url_handler.h"
+#include "components/crx_file/id_util.h"
#include "extensions/common/extension.h"
#include "sync/api/sync_data.h"
#include "sync/protocol/extension_specifics.pb.h"
@@ -74,7 +75,7 @@ syncer::SyncChange ExtensionSyncData::GetSyncChange(
void ExtensionSyncData::PopulateExtensionSpecifics(
sync_pb::ExtensionSpecifics* specifics) const {
- DCHECK(Extension::IdIsValid(id_));
+ DCHECK(crx_file::id_util::IdIsValid(id_));
specifics->set_id(id_);
specifics->set_update_url(update_url_.spec());
specifics->set_version(version_.GetString());
@@ -87,7 +88,7 @@ void ExtensionSyncData::PopulateExtensionSpecifics(
void ExtensionSyncData::PopulateFromExtensionSpecifics(
const sync_pb::ExtensionSpecifics& specifics) {
- if (!Extension::IdIsValid(specifics.id())) {
+ if (!crx_file::id_util::IdIsValid(specifics.id())) {
LOG(FATAL) << "Attempt to sync bad ExtensionSpecifics.";
}
diff --git a/chrome/browser/extensions/extension_toolbar_model_unittest.cc b/chrome/browser/extensions/extension_toolbar_model_unittest.cc
index 0331bae..3399625 100644
--- a/chrome/browser/extensions/extension_toolbar_model_unittest.cc
+++ b/chrome/browser/extensions/extension_toolbar_model_unittest.cc
@@ -11,13 +11,13 @@
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/extension_action/action_info.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/feature_switch.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/value_builder.h"
@@ -39,7 +39,7 @@ scoped_refptr<const Extension> GetActionExtension(const std::string& name,
manifest.Set(action_key, DictionaryBuilder().Pass());
return ExtensionBuilder().SetManifest(manifest.Pass())
- .SetID(id_util::GenerateId(name))
+ .SetID(crx_file::id_util::GenerateId(name))
.Build();
}
diff --git a/chrome/browser/extensions/external_provider_impl.cc b/chrome/browser/extensions/external_provider_impl.cc
index 13914f4..d4ab6c9 100644
--- a/chrome/browser/extensions/external_provider_impl.cc
+++ b/chrome/browser/extensions/external_provider_impl.cc
@@ -26,6 +26,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/external_provider_interface.h"
@@ -114,7 +115,7 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
const std::string& extension_id = i.key();
const base::DictionaryValue* extension = NULL;
- if (!Extension::IdIsValid(extension_id)) {
+ if (!crx_file::id_util::IdIsValid(extension_id)) {
LOG(WARNING) << "Malformed extension dictionary: key "
<< extension_id.c_str() << " is not a valid id.";
continue;
diff --git a/chrome/browser/extensions/external_registry_loader_win.cc b/chrome/browser/extensions/external_registry_loader_win.cc
index 6de5441..d471a60 100644
--- a/chrome/browser/extensions/external_registry_loader_win.cc
+++ b/chrome/browser/extensions/external_registry_loader_win.cc
@@ -17,8 +17,8 @@
#include "base/version.h"
#include "base/win/registry.h"
#include "chrome/browser/extensions/external_provider_impl.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
-#include "extensions/common/extension.h"
using content::BrowserThread;
@@ -97,7 +97,7 @@ void ExternalRegistryLoader::LoadOnFileThread() {
std::string id = base::UTF16ToASCII(*it);
base::StringToLowerASCII(&id);
- if (!Extension::IdIsValid(id)) {
+ if (!crx_file::id_util::IdIsValid(id)) {
LOG(ERROR) << "Invalid id value " << id
<< " for key " << key_path << ".";
continue;
diff --git a/chrome/browser/extensions/policy_handlers.cc b/chrome/browser/extensions/policy_handlers.cc
index 3508fae..e47b29f 100644
--- a/chrome/browser/extensions/policy_handlers.cc
+++ b/chrome/browser/extensions/policy_handlers.cc
@@ -8,6 +8,7 @@
#include "base/prefs/pref_value_map.h"
#include "chrome/browser/extensions/external_policy_loader.h"
#include "chrome/common/pref_names.h"
+#include "components/crx_file/id_util.h"
#include "components/policy/core/browser/policy_error_map.h"
#include "components/policy/core/common/policy_map.h"
#include "extensions/browser/pref_names.h"
@@ -79,8 +80,7 @@ bool ExtensionListPolicyHandler::CheckAndGetList(
ValueTypeToString(base::Value::TYPE_STRING));
continue;
}
- if (!(allow_wildcards_ && id == "*") &&
- !extensions::Extension::IdIsValid(id)) {
+ if (!(allow_wildcards_ && id == "*") && !crx_file::id_util::IdIsValid(id)) {
errors->AddError(policy_name(),
entry - list_value->begin(),
IDS_POLICY_VALUE_FORMAT_ERROR);
@@ -166,7 +166,7 @@ bool ExtensionInstallForcelistPolicyHandler::ParseList(
std::string extension_id = entry_string.substr(0, pos);
std::string update_url = entry_string.substr(pos+1);
- if (!extensions::Extension::IdIsValid(extension_id) ||
+ if (!crx_file::id_util::IdIsValid(extension_id) ||
!GURL(update_url).is_valid()) {
if (errors) {
errors->AddError(policy_name(),
diff --git a/chrome/browser/extensions/sandboxed_unpacker.cc b/chrome/browser/extensions/sandboxed_unpacker.cc
index bfdc115..05fef3b 100644
--- a/chrome/browser/extensions/sandboxed_unpacker.cc
+++ b/chrome/browser/extensions/sandboxed_unpacker.cc
@@ -28,6 +28,7 @@
#include "chrome/common/extensions/extension_file_util.h"
#include "components/crx_file/constants.h"
#include "components/crx_file/crx_file.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/utility_process_host.h"
#include "content/public/common/common_param_traits.h"
@@ -36,7 +37,6 @@
#include "extensions/common/extension.h"
#include "extensions/common/extension_l10n_util.h"
#include "extensions/common/file_util.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/icons_handler.h"
#include "grit/generated_resources.h"
@@ -579,7 +579,7 @@ bool SandboxedUnpacker::ValidateSignature() {
std::string(reinterpret_cast<char*>(&key.front()), key.size());
base::Base64Encode(public_key, &public_key_);
- extension_id_ = id_util::GenerateId(public_key);
+ extension_id_ = crx_file::id_util::GenerateId(public_key);
return true;
}
diff --git a/chrome/browser/extensions/shared_module_service_unittest.cc b/chrome/browser/extensions/shared_module_service_unittest.cc
index 5f223fb..9f399984 100644
--- a/chrome/browser/extensions/shared_module_service_unittest.cc
+++ b/chrome/browser/extensions/shared_module_service_unittest.cc
@@ -11,11 +11,11 @@
#include "chrome/browser/extensions/pending_extension_manager.h"
#include "chrome/browser/extensions/shared_module_service.h"
#include "chrome/common/extensions/features/feature_channel.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/install_flag.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/extension_builder.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/value_builder.h"
#include "sync/api/string_ordinal.h"
@@ -101,8 +101,8 @@ testing::AssertionResult SharedModuleServiceUnitTest::InstallExtension(
TEST_F(SharedModuleServiceUnitTest, AddDependentSharedModules) {
// Create an extension that has a dependency.
- std::string import_id = id_util::GenerateId("id");
- std::string extension_id = id_util::GenerateId("extension_id");
+ std::string import_id = crx_file::id_util::GenerateId("id");
+ std::string extension_id = crx_file::id_util::GenerateId("extension_id");
scoped_refptr<Extension> extension =
CreateExtensionImportingModule(import_id, extension_id, "1.0");
@@ -129,14 +129,15 @@ TEST_F(SharedModuleServiceUnitTest, PruneSharedModulesOnUninstall) {
DictionaryBuilder().Set("resources",
ListBuilder().Append("foo.js"))).Build();
scoped_refptr<Extension> shared_module =
- ExtensionBuilder().SetManifest(manifest.Pass())
- .AddFlags(Extension::FROM_WEBSTORE)
- .SetID(id_util::GenerateId("shared_module"))
- .Build();
+ ExtensionBuilder()
+ .SetManifest(manifest.Pass())
+ .AddFlags(Extension::FROM_WEBSTORE)
+ .SetID(crx_file::id_util::GenerateId("shared_module"))
+ .Build();
EXPECT_TRUE(InstallExtension(shared_module, false));
- std::string extension_id = id_util::GenerateId("extension_id");
+ std::string extension_id = crx_file::id_util::GenerateId("extension_id");
// Create and install an extension that imports our new module.
scoped_refptr<Extension> importing_extension =
CreateExtensionImportingModule(shared_module->id(), extension_id, "1.0");
@@ -168,10 +169,11 @@ TEST_F(SharedModuleServiceUnitTest, PruneSharedModulesOnUpdate) {
DictionaryBuilder().Set("resources",
ListBuilder().Append("foo.js"))).Build();
scoped_refptr<Extension> shared_module_1 =
- ExtensionBuilder().SetManifest(manifest_1.Pass())
- .AddFlags(Extension::FROM_WEBSTORE)
- .SetID(id_util::GenerateId("shared_module_1"))
- .Build();
+ ExtensionBuilder()
+ .SetManifest(manifest_1.Pass())
+ .AddFlags(Extension::FROM_WEBSTORE)
+ .SetID(crx_file::id_util::GenerateId("shared_module_1"))
+ .Build();
EXPECT_TRUE(InstallExtension(shared_module_1, false));
scoped_ptr<base::DictionaryValue> manifest_2 =
@@ -183,13 +185,14 @@ TEST_F(SharedModuleServiceUnitTest, PruneSharedModulesOnUpdate) {
DictionaryBuilder().Set("resources",
ListBuilder().Append("foo.js"))).Build();
scoped_refptr<Extension> shared_module_2 =
- ExtensionBuilder().SetManifest(manifest_2.Pass())
- .AddFlags(Extension::FROM_WEBSTORE)
- .SetID(id_util::GenerateId("shared_module_2"))
- .Build();
+ ExtensionBuilder()
+ .SetManifest(manifest_2.Pass())
+ .AddFlags(Extension::FROM_WEBSTORE)
+ .SetID(crx_file::id_util::GenerateId("shared_module_2"))
+ .Build();
EXPECT_TRUE(InstallExtension(shared_module_2, false));
- std::string extension_id = id_util::GenerateId("extension_id");
+ std::string extension_id = crx_file::id_util::GenerateId("extension_id");
// Create and install an extension v1.0 that imports our new module 1.
scoped_refptr<Extension> importing_extension_1 =
@@ -229,8 +232,9 @@ TEST_F(SharedModuleServiceUnitTest, PruneSharedModulesOnUpdate) {
}
TEST_F(SharedModuleServiceUnitTest, WhitelistedImports) {
- std::string whitelisted_id = id_util::GenerateId("whitelisted");
- std::string nonwhitelisted_id = id_util::GenerateId("nonwhitelisted");
+ std::string whitelisted_id = crx_file::id_util::GenerateId("whitelisted");
+ std::string nonwhitelisted_id =
+ crx_file::id_util::GenerateId("nonwhitelisted");
// Create a module which exports to a restricted whitelist.
scoped_ptr<base::DictionaryValue> manifest =
DictionaryBuilder()
@@ -244,10 +248,11 @@ TEST_F(SharedModuleServiceUnitTest, WhitelistedImports) {
.Set("resources",
ListBuilder().Append("*"))).Build();
scoped_refptr<Extension> shared_module =
- ExtensionBuilder().SetManifest(manifest.Pass())
- .AddFlags(Extension::FROM_WEBSTORE)
- .SetID(id_util::GenerateId("shared_module"))
- .Build();
+ ExtensionBuilder()
+ .SetManifest(manifest.Pass())
+ .AddFlags(Extension::FROM_WEBSTORE)
+ .SetID(crx_file::id_util::GenerateId("shared_module"))
+ .Build();
EXPECT_TRUE(InstallExtension(shared_module, false));
diff --git a/chrome/browser/extensions/startup_helper.cc b/chrome/browser/extensions/startup_helper.cc
index a662982..f9f1228 100644
--- a/chrome/browser/extensions/startup_helper.cc
+++ b/chrome/browser/extensions/startup_helper.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/chrome_extensions_client.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "extensions/common/extension.h"
@@ -313,7 +314,7 @@ void DeleteHelperAndRunCallback(AppInstallHelper* helper,
bool StartupHelper::InstallFromWebstore(const CommandLine& cmd_line,
Profile* profile) {
std::string id = cmd_line.GetSwitchValueASCII(switches::kInstallFromWebstore);
- if (!Extension::IdIsValid(id)) {
+ if (!crx_file::id_util::IdIsValid(id)) {
LOG(ERROR) << "Invalid id for " << switches::kInstallFromWebstore
<< " : '" << id << "'";
return false;
@@ -334,7 +335,7 @@ void StartupHelper::LimitedInstallFromWebstore(
Profile* profile,
base::Callback<void()> done_callback) {
std::string id = WebStoreIdFromLimitedInstallCmdLine(cmd_line);
- if (!Extension::IdIsValid(id)) {
+ if (!crx_file::id_util::IdIsValid(id)) {
LOG(ERROR) << "Invalid index for " << switches::kLimitedInstallFromWebstore;
done_callback.Run();
return;
diff --git a/chrome/browser/extensions/test_extension_prefs.cc b/chrome/browser/extensions/test_extension_prefs.cc
index 1810418f..4c420cc 100644
--- a/chrome/browser/extensions/test_extension_prefs.cc
+++ b/chrome/browser/extensions/test_extension_prefs.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/prefs/pref_service_mock_factory.h"
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/common/chrome_constants.h"
+#include "components/crx_file/id_util.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_pref_store.h"
@@ -161,7 +162,7 @@ scoped_refptr<Extension> TestExtensionPrefs::AddExtensionWithManifestAndFlags(
if (!extension.get())
return NULL;
- EXPECT_TRUE(Extension::IdIsValid(extension->id()));
+ EXPECT_TRUE(crx_file::id_util::IdIsValid(extension->id()));
prefs_->OnExtensionInstalled(extension.get(),
Extension::ENABLED,
syncer::StringOrdinal::CreateInitialOrdinal(),
diff --git a/chrome/browser/extensions/unpacked_installer.cc b/chrome/browser/extensions/unpacked_installer.cc
index 6d4946c..ab5359d 100644
--- a/chrome/browser/extensions/unpacked_installer.cc
+++ b/chrome/browser/extensions/unpacked_installer.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/extensions/permissions_updater.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/plugins/plugins_handler.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
@@ -23,7 +24,6 @@
#include "extensions/common/extension.h"
#include "extensions/common/extension_l10n_util.h"
#include "extensions/common/file_util.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest.h"
#include "sync/api/string_ordinal.h"
@@ -210,7 +210,7 @@ void UnpackedInstaller::OnInstallChecksComplete(int failed_checks) {
}
int UnpackedInstaller::GetFlags() {
- std::string id = id_util::GenerateIdForPath(extension_path_);
+ std::string id = crx_file::id_util::GenerateIdForPath(extension_path_);
bool allow_file_access =
Manifest::ShouldAlwaysAllowFileAccess(Manifest::UNPACKED);
ExtensionPrefs* prefs = ExtensionPrefs::Get(service_weak_->profile());
diff --git a/chrome/browser/extensions/updater/extension_updater_unittest.cc b/chrome/browser/extensions/updater/extension_updater_unittest.cc
index b6ebb83..4a7375f 100644
--- a/chrome/browser/extensions/updater/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/updater/extension_updater_unittest.cc
@@ -39,6 +39,7 @@
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_profile.h"
+#include "components/crx_file/id_util.h"
#include "components/omaha_query_params/omaha_query_params.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_observer.h"
@@ -51,7 +52,6 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest_constants.h"
#include "google_apis/gaia/fake_identity_provider.h"
#include "google_apis/gaia/fake_oauth2_token_service.h"
@@ -410,7 +410,8 @@ void SetupPendingExtensionManagerForTest(
const bool kInstallSilently = true;
const bool kMarkAcknowledged = false;
const bool kRemoteInstall = false;
- std::string id = id_util::GenerateId(base::StringPrintf("extension%i", i));
+ std::string id =
+ crx_file::id_util::GenerateId(base::StringPrintf("extension%i", i));
pending_extension_manager->AddForTesting(
PendingExtensionInfo(id,
@@ -802,8 +803,8 @@ class ExtensionUpdaterTest : public testing::Test {
// Create two updates - expect that DetermineUpdates will return the first
// one (v1.0 installed, v1.1 available) but not the second one (both
// installed and available at v2.0).
- const std::string id1 = id_util::GenerateId("1");
- const std::string id2 = id_util::GenerateId("2");
+ const std::string id1 = crx_file::id_util::GenerateId("1");
+ const std::string id2 = crx_file::id_util::GenerateId("2");
fetch_data.AddExtension(
id1, "1.0.0.0", &kNeverPingedData, kEmptyUpdateUrlData, std::string());
AddParseResult(id1, "1.1", "http://localhost/e1_1.1.crx", &updates);
@@ -1954,7 +1955,7 @@ TEST_F(ExtensionUpdaterTest, TestManifestFetchesBuilderAddExtension) {
// First, verify that adding valid extensions does invoke the callbacks on
// the delegate.
- std::string id = id_util::GenerateId("foo");
+ std::string id = crx_file::id_util::GenerateId("foo");
EXPECT_CALL(delegate, GetPingDataForExtension(id, _)).WillOnce(Return(false));
EXPECT_TRUE(
downloader->AddPendingExtension(id, GURL("http://example.com/update"),
@@ -1964,7 +1965,7 @@ TEST_F(ExtensionUpdaterTest, TestManifestFetchesBuilderAddExtension) {
EXPECT_EQ(1u, ManifestFetchersCount(downloader.get()));
// Extensions with invalid update URLs should be rejected.
- id = id_util::GenerateId("foo2");
+ id = crx_file::id_util::GenerateId("foo2");
EXPECT_FALSE(
downloader->AddPendingExtension(id, GURL("http:google.com:foo"), 0));
downloader->StartAllPending(NULL);
@@ -1985,7 +1986,7 @@ TEST_F(ExtensionUpdaterTest, TestManifestFetchesBuilderAddExtension) {
// Extensions with empty update URLs should have a default one
// filled in.
- id = id_util::GenerateId("foo3");
+ id = crx_file::id_util::GenerateId("foo3");
EXPECT_CALL(delegate, GetPingDataForExtension(id, _)).WillOnce(Return(false));
EXPECT_TRUE(downloader->AddPendingExtension(id, GURL(), 0));
downloader->StartAllPending(NULL);
diff --git a/chrome/browser/extensions/updater/local_extension_cache.cc b/chrome/browser/extensions/updater/local_extension_cache.cc
index 34ef19c..5c81e55 100644
--- a/chrome/browser/extensions/updater/local_extension_cache.cc
+++ b/chrome/browser/extensions/updater/local_extension_cache.cc
@@ -11,8 +11,8 @@
#include "base/strings/string_util.h"
#include "base/sys_info.h"
#include "base/version.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
-#include "extensions/common/extension.h"
namespace extensions {
namespace {
@@ -306,7 +306,7 @@ void LocalExtensionCache::BackendCheckCacheContentsInternal(
// Enforce a lower-case id.
id = base::StringToLowerASCII(id);
- if (!extensions::Extension::IdIsValid(id)) {
+ if (!crx_file::id_util::IdIsValid(id)) {
LOG(ERROR) << "Bad extension id in cache: " << id;
id.clear();
}
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
index 6bfa00f..412be96 100644
--- a/chrome/browser/extensions/webstore_installer.cc
+++ b/chrome/browser/extensions/webstore_installer.cc
@@ -35,6 +35,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "components/crx_file/id_util.h"
#include "components/omaha_query_params/omaha_query_params.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_manager.h"
@@ -300,7 +301,7 @@ void WebstoreInstaller::Start() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
AddRef(); // Balanced in ReportSuccess and ReportFailure.
- if (!Extension::IdIsValid(id_)) {
+ if (!crx_file::id_util::IdIsValid(id_)) {
ReportFailure(kInvalidIdError, FAILURE_REASON_OTHER);
return;
}
diff --git a/chrome/browser/extensions/webstore_installer_unittest.cc b/chrome/browser/extensions/webstore_installer_unittest.cc
index fbc48cb..a686689 100644
--- a/chrome/browser/extensions/webstore_installer_unittest.cc
+++ b/chrome/browser/extensions/webstore_installer_unittest.cc
@@ -7,8 +7,8 @@
#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/webstore_installer.h"
#include "chrome/browser/omaha_query_params/chrome_omaha_query_params_delegate.h"
+#include "components/crx_file/id_util.h"
#include "components/omaha_query_params/omaha_query_params.h"
-#include "extensions/common/id_util.h"
#include "net/base/escape.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -23,7 +23,7 @@ bool Contains(const std::string& source, const std::string& target) {
}
TEST(WebstoreInstallerTest, PlatformParams) {
- std::string id = extensions::id_util::GenerateId("some random string");
+ std::string id = crx_file::id_util::GenerateId("some random string");
std::string source = "inline";
GURL url = WebstoreInstaller::GetWebstoreInstallURL(id,
WebstoreInstaller::INSTALL_SOURCE_INLINE);
diff --git a/chrome/browser/extensions/webstore_standalone_installer.cc b/chrome/browser/extensions/webstore_standalone_installer.cc
index 859cf48..dc9ea0e 100644
--- a/chrome/browser/extensions/webstore_standalone_installer.cc
+++ b/chrome/browser/extensions/webstore_standalone_installer.cc
@@ -14,6 +14,7 @@
#include "chrome/browser/extensions/install_tracker.h"
#include "chrome/browser/extensions/webstore_data_fetcher.h"
#include "chrome/browser/profiles/profile.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
@@ -55,7 +56,7 @@ void WebstoreStandaloneInstaller::BeginInstall() {
// AbortInstall, which both release this ref.
AddRef();
- if (!Extension::IdIsValid(id_)) {
+ if (!crx_file::id_util::IdIsValid(id_)) {
CompleteInstall(webstore_install::INVALID_ID, kInvalidWebstoreItemId);
return;
}
diff --git a/chrome/browser/guest_view/extension_options/extension_options_guest.cc b/chrome/browser/guest_view/extension_options/extension_options_guest.cc
index f7ca290..43553ac 100644
--- a/chrome/browser/guest_view/extension_options/extension_options_guest.cc
+++ b/chrome/browser/guest_view/extension_options/extension_options_guest.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/extension_options_internal.h"
#include "chrome/common/extensions/manifest_url_handler.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
@@ -59,12 +60,12 @@ void ExtensionOptionsGuest::CreateWebContents(
std::string extension_id;
create_params.GetString(extensionoptions::kExtensionId, &extension_id);
- if (!extensions::Extension::IdIsValid(extension_id)) {
+ if (!crx_file::id_util::IdIsValid(extension_id)) {
callback.Run(NULL);
return;
}
- if (extensions::Extension::IdIsValid(embedder_extension_id) &&
+ if (crx_file::id_util::IdIsValid(embedder_extension_id) &&
extension_id != embedder_extension_id) {
// Extensions cannot embed other extensions' options pages.
callback.Run(NULL);
diff --git a/chrome/browser/media_galleries/media_galleries_preferences.cc b/chrome/browser/media_galleries/media_galleries_preferences.cc
index 32eaa29..8b48c51 100644
--- a/chrome/browser/media_galleries/media_galleries_preferences.cc
+++ b/chrome/browser/media_galleries/media_galleries_preferences.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
+#include "components/crx_file/id_util.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/storage_monitor/media_storage_util.h"
#include "components/storage_monitor/storage_monitor.h"
@@ -33,7 +34,6 @@
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/pref_names.h"
-#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/permissions/api_permission.h"
#include "extensions/common/permissions/media_galleries_permission.h"
@@ -1198,7 +1198,7 @@ bool MediaGalleriesPreferences::NonAutoGalleryHasPermission(
for (base::DictionaryValue::Iterator iter(*extensions); !iter.IsAtEnd();
iter.Advance()) {
- if (!extensions::Extension::IdIsValid(iter.key())) {
+ if (!crx_file::id_util::IdIsValid(iter.key())) {
NOTREACHED();
continue;
}
@@ -1439,7 +1439,7 @@ void MediaGalleriesPreferences::RemoveGalleryPermissionsFromPrefs(
for (base::DictionaryValue::Iterator iter(*extensions); !iter.IsAtEnd();
iter.Advance()) {
- if (!extensions::Extension::IdIsValid(iter.key())) {
+ if (!crx_file::id_util::IdIsValid(iter.key())) {
NOTREACHED();
continue;
}
diff --git a/chrome/browser/media_galleries/media_galleries_test_util.cc b/chrome/browser/media_galleries/media_galleries_test_util.cc
index 45206a8..f62dcd8 100644
--- a/chrome/browser/media_galleries/media_galleries_test_util.cc
+++ b/chrome/browser/media_galleries/media_galleries_test_util.cc
@@ -18,9 +18,9 @@
#include "chrome/browser/media_galleries/fileapi/picasa_finder.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_paths.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
-#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -69,8 +69,8 @@ scoped_refptr<extensions::Extension> AddMediaGalleriesApp(
*manifest.get(),
extensions::Extension::NO_FLAGS, &errors);
EXPECT_TRUE(extension.get() != NULL) << errors;
- EXPECT_TRUE(extensions::Extension::IdIsValid(extension->id()));
- if (!extension.get() || !extensions::Extension::IdIsValid(extension->id()))
+ EXPECT_TRUE(crx_file::id_util::IdIsValid(extension->id()));
+ if (!extension.get() || !crx_file::id_util::IdIsValid(extension->id()))
return NULL;
extension_prefs->OnExtensionInstalled(
diff --git a/chrome/browser/profile_resetter/brandcoded_default_settings.cc b/chrome/browser/profile_resetter/brandcoded_default_settings.cc
index 748992a..7d7f2cc 100644
--- a/chrome/browser/profile_resetter/brandcoded_default_settings.cc
+++ b/chrome/browser/profile_resetter/brandcoded_default_settings.cc
@@ -8,8 +8,8 @@
#include "base/logging.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/master_preferences_constants.h"
+#include "components/crx_file/id_util.h"
#include "components/search_engines/search_engines_pref_names.h"
-#include "extensions/common/extension.h"
BrandcodedDefaultSettings::BrandcodedDefaultSettings() {
}
@@ -71,7 +71,7 @@ bool BrandcodedDefaultSettings::GetExtensions(
&extensions)) {
for (base::DictionaryValue::Iterator extension_id(*extensions);
!extension_id.IsAtEnd(); extension_id.Advance()) {
- if (extensions::Extension::IdIsValid(extension_id.key()))
+ if (crx_file::id_util::IdIsValid(extension_id.key()))
extension_ids->push_back(extension_id.key());
}
return true;
diff --git a/chrome/browser/sync/test/integration/sync_app_helper.cc b/chrome/browser/sync/test/integration/sync_app_helper.cc
index 94d55bf..f0bbe6b 100644
--- a/chrome/browser/sync/test/integration/sync_app_helper.cc
+++ b/chrome/browser/sync/test/integration/sync_app_helper.cc
@@ -13,13 +13,12 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
#include "chrome/common/extensions/sync_helper.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/app_sorting.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
-#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
-#include "extensions/common/id_util.h"
using extensions::ExtensionPrefs;
@@ -174,7 +173,7 @@ syncer::StringOrdinal SyncAppHelper::GetPageOrdinalForApp(
Profile* profile,
const std::string& name) {
return ExtensionPrefs::Get(profile)->app_sorting()->GetPageOrdinal(
- extensions::id_util::GenerateId(name));
+ crx_file::id_util::GenerateId(name));
}
void SyncAppHelper::SetPageOrdinalForApp(
@@ -182,14 +181,14 @@ void SyncAppHelper::SetPageOrdinalForApp(
const std::string& name,
const syncer::StringOrdinal& page_ordinal) {
ExtensionPrefs::Get(profile)->app_sorting()->SetPageOrdinal(
- extensions::id_util::GenerateId(name), page_ordinal);
+ crx_file::id_util::GenerateId(name), page_ordinal);
}
syncer::StringOrdinal SyncAppHelper::GetAppLaunchOrdinalForApp(
Profile* profile,
const std::string& name) {
return ExtensionPrefs::Get(profile)->app_sorting()->GetAppLaunchOrdinal(
- extensions::id_util::GenerateId(name));
+ crx_file::id_util::GenerateId(name));
}
void SyncAppHelper::SetAppLaunchOrdinalForApp(
@@ -197,7 +196,7 @@ void SyncAppHelper::SetAppLaunchOrdinalForApp(
const std::string& name,
const syncer::StringOrdinal& app_launch_ordinal) {
ExtensionPrefs::Get(profile)->app_sorting()->SetAppLaunchOrdinal(
- extensions::id_util::GenerateId(name), app_launch_ordinal);
+ crx_file::id_util::GenerateId(name), app_launch_ordinal);
}
void SyncAppHelper::FixNTPOrdinalCollisions(Profile* profile) {
diff --git a/chrome/browser/sync/test/integration/sync_extension_helper.cc b/chrome/browser/sync/test/integration/sync_extension_helper.cc
index eb0b9d5..a751763 100644
--- a/chrome/browser/sync/test/integration/sync_extension_helper.cc
+++ b/chrome/browser/sync/test/integration/sync_extension_helper.cc
@@ -15,13 +15,13 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
#include "chrome/browser/sync/test/integration/sync_test.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/install_flag.h"
#include "extensions/browser/uninstall_reason.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest_constants.h"
#include "sync/api/string_ordinal.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -83,7 +83,7 @@ void SyncExtensionHelper::UninstallExtension(
Profile* profile, const std::string& name) {
ExtensionService::UninstallExtensionHelper(
extensions::ExtensionSystem::Get(profile)->extension_service(),
- extensions::id_util::GenerateId(name),
+ crx_file::id_util::GenerateId(name),
extensions::UNINSTALL_REASON_SYNC);
}
@@ -106,14 +106,14 @@ void SyncExtensionHelper::EnableExtension(Profile* profile,
const std::string& name) {
extensions::ExtensionSystem::Get(profile)
->extension_service()
- ->EnableExtension(extensions::id_util::GenerateId(name));
+ ->EnableExtension(crx_file::id_util::GenerateId(name));
}
void SyncExtensionHelper::DisableExtension(Profile* profile,
const std::string& name) {
extensions::ExtensionSystem::Get(profile)
->extension_service()
- ->DisableExtension(extensions::id_util::GenerateId(name),
+ ->DisableExtension(crx_file::id_util::GenerateId(name),
Extension::DISABLE_USER_ACTION);
}
@@ -121,25 +121,25 @@ bool SyncExtensionHelper::IsExtensionEnabled(
Profile* profile, const std::string& name) const {
return extensions::ExtensionSystem::Get(profile)
->extension_service()
- ->IsExtensionEnabled(extensions::id_util::GenerateId(name));
+ ->IsExtensionEnabled(crx_file::id_util::GenerateId(name));
}
void SyncExtensionHelper::IncognitoEnableExtension(
Profile* profile, const std::string& name) {
extensions::util::SetIsIncognitoEnabled(
- extensions::id_util::GenerateId(name), profile, true);
+ crx_file::id_util::GenerateId(name), profile, true);
}
void SyncExtensionHelper::IncognitoDisableExtension(
Profile* profile, const std::string& name) {
extensions::util::SetIsIncognitoEnabled(
- extensions::id_util::GenerateId(name), profile, false);
+ crx_file::id_util::GenerateId(name), profile, false);
}
bool SyncExtensionHelper::IsIncognitoEnabled(
Profile* profile, const std::string& name) const {
return extensions::util::IsIncognitoEnabled(
- extensions::id_util::GenerateId(name), profile);
+ crx_file::id_util::GenerateId(name), profile);
}
@@ -384,7 +384,7 @@ scoped_refptr<Extension> SyncExtensionHelper::GetExtension(
ADD_FAILURE();
return NULL;
}
- const std::string& expected_id = extensions::id_util::GenerateId(name);
+ const std::string& expected_id = crx_file::id_util::GenerateId(name);
if (extension->id() != expected_id) {
EXPECT_EQ(expected_id, extension->id());
return NULL;
diff --git a/chrome/browser/sync/test/integration/themes_helper.cc b/chrome/browser/sync/test/integration/themes_helper.cc
index 7f6c980..79a948c 100644
--- a/chrome/browser/sync/test/integration/themes_helper.cc
+++ b/chrome/browser/sync/test/integration/themes_helper.cc
@@ -14,11 +14,10 @@
#include "chrome/browser/sync/test/integration/sync_extension_helper.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_source.h"
-#include "extensions/common/extension.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest.h"
using sync_datatype_helper::test;
@@ -39,7 +38,7 @@ ThemeService* GetThemeService(Profile* profile) {
namespace themes_helper {
std::string GetCustomTheme(int index) {
- return extensions::id_util::GenerateId(MakeName(index));
+ return crx_file::id_util::GenerateId(MakeName(index));
}
std::string GetThemeID(Profile* profile) {
diff --git a/chrome/browser/themes/browser_theme_pack.cc b/chrome/browser/themes/browser_theme_pack.cc
index d67b152..2c95302 100644
--- a/chrome/browser/themes/browser_theme_pack.cc
+++ b/chrome/browser/themes/browser_theme_pack.cc
@@ -18,8 +18,8 @@
#include "base/values.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/common/extensions/manifest_handlers/theme_handler.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
-#include "extensions/common/id_util.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/base/resource/data_pack.h"
@@ -724,9 +724,8 @@ scoped_refptr<BrowserThemePack> BrowserThemePack::BuildFromDataPack(
}
// TODO(erg): Check endianess once DataPack works on the other endian.
std::string theme_id(reinterpret_cast<char*>(pack->header_->theme_id),
- extensions::id_util::kIdSize);
- std::string truncated_id =
- expected_id.substr(0, extensions::id_util::kIdSize);
+ crx_file::id_util::kIdSize);
+ std::string truncated_id = expected_id.substr(0, crx_file::id_util::kIdSize);
if (theme_id != truncated_id) {
DLOG(ERROR) << "Wrong id: " << theme_id << " vs " << expected_id;
return NULL;
@@ -953,7 +952,7 @@ void BrowserThemePack::BuildHeader(const Extension* extension) {
header_->little_endian = 1;
const std::string& id = extension->id();
- memcpy(header_->theme_id, id.c_str(), extensions::id_util::kIdSize);
+ memcpy(header_->theme_id, id.c_str(), crx_file::id_util::kIdSize);
}
void BrowserThemePack::BuildTintsFromJSON(
diff --git a/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc b/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
index 2a611c1..fb18d83 100644
--- a/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
+++ b/chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.cc
@@ -19,10 +19,10 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/settings/cros_settings_names.h"
+#include "components/crx_file/id_util.h"
#include "components/user_manager/user_manager.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"
-#include "extensions/common/extension.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -57,7 +57,7 @@ void PopulateAppDict(const KioskAppManager::App& app_data,
// Returns false if an app id could not be derived out of the input.
bool ExtractsAppIdFromInput(const std::string& input,
std::string* app_id) {
- if (extensions::Extension::IdIsValid(input)) {
+ if (crx_file::id_util::IdIsValid(input)) {
*app_id = input;
return true;
}
@@ -82,7 +82,7 @@ bool ExtractsAppIdFromInput(const std::string& input,
return false;
const std::string candidate_id = path.substr(last_slash + 1);
- if (!extensions::Extension::IdIsValid(candidate_id))
+ if (!crx_file::id_util::IdIsValid(candidate_id))
return false;
*app_id = candidate_id;
diff --git a/chrome/browser/web_applications/web_app_mac.mm b/chrome/browser/web_applications/web_app_mac.mm
index a0a3ba0..a49e357 100644
--- a/chrome/browser/web_applications/web_app_mac.mm
+++ b/chrome/browser/web_applications/web_app_mac.mm
@@ -38,6 +38,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
#import "chrome/common/mac/app_mode_common.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
@@ -447,7 +448,7 @@ bool IsShimForProfile(const base::FilePath& base_name,
std::string app_id = base_name.RemoveExtension().value();
// Strip (profile_base_name + " ") from the start.
app_id = app_id.substr(profile_base_name.size() + 1);
- return extensions::Extension::IdIsValid(app_id);
+ return crx_file::id_util::IdIsValid(app_id);
}
std::vector<base::FilePath> GetAllAppBundlesInPath(
diff --git a/chrome/common/DEPS b/chrome/common/DEPS
index 2e5d242..b74d811 100644
--- a/chrome/common/DEPS
+++ b/chrome/common/DEPS
@@ -8,6 +8,7 @@ include_rules = [
"+components/bookmarks/common",
"+components/cloud_devices/common",
"+components/content_settings/core/common",
+ "+components/crx_file",
"+components/data_reduction_proxy/common",
"+components/dom_distiller/core",
"+components/metrics/client_info.h",
diff --git a/chrome/common/extensions/extension_unittest.cc b/chrome/common/extensions/extension_unittest.cc
index 04aea3b..3e16817 100644
--- a/chrome/common/extensions/extension_unittest.cc
+++ b/chrome/common/extensions/extension_unittest.cc
@@ -12,6 +12,7 @@
#include "chrome/common/extensions/extension_test_util.h"
#include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h"
#include "chrome/common/url_constants.h"
+#include "components/crx_file/id_util.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_resource.h"
#include "extensions/common/file_util.h"
@@ -184,15 +185,19 @@ TEST(ExtensionTest, GetAbsolutePathNoError) {
TEST(ExtensionTest, IdIsValid) {
- EXPECT_TRUE(Extension::IdIsValid("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
- EXPECT_TRUE(Extension::IdIsValid("pppppppppppppppppppppppppppppppp"));
- EXPECT_TRUE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmnop"));
- EXPECT_TRUE(Extension::IdIsValid("ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"));
- EXPECT_FALSE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmno"));
- EXPECT_FALSE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmnopa"));
- EXPECT_FALSE(Extension::IdIsValid("0123456789abcdef0123456789abcdef"));
- EXPECT_FALSE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmnoq"));
- EXPECT_FALSE(Extension::IdIsValid("abcdefghijklmnopabcdefghijklmno0"));
+ EXPECT_TRUE(crx_file::id_util::IdIsValid("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
+ EXPECT_TRUE(crx_file::id_util::IdIsValid("pppppppppppppppppppppppppppppppp"));
+ EXPECT_TRUE(crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmnop"));
+ EXPECT_TRUE(crx_file::id_util::IdIsValid("ABCDEFGHIJKLMNOPABCDEFGHIJKLMNOP"));
+ EXPECT_FALSE(crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmno"));
+ EXPECT_FALSE(
+ crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmnopa"));
+ EXPECT_FALSE(
+ crx_file::id_util::IdIsValid("0123456789abcdef0123456789abcdef"));
+ EXPECT_FALSE(
+ crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmnoq"));
+ EXPECT_FALSE(
+ crx_file::id_util::IdIsValid("abcdefghijklmnopabcdefghijklmno0"));
}
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc
index c82a41e..085c1a8 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_initvalue_unittest.cc
@@ -8,6 +8,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "chrome/common/extensions/manifest_url_handler.h"
+#include "components/crx_file/id_util.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -85,7 +86,7 @@ TEST_F(InitValueManifestTest, InitFromValueValid) {
PathService::Get(chrome::DIR_TEST_DATA, &path);
path = path.AppendASCII("extensions");
- EXPECT_TRUE(Extension::IdIsValid(extension->id()));
+ EXPECT_TRUE(crx_file::id_util::IdIsValid(extension->id()));
EXPECT_EQ("1.0.0.0", extension->VersionString());
EXPECT_EQ("my extension", extension->name());
EXPECT_EQ(extension->name(), extension->short_name());
diff --git a/chrome/common/pepper_permission_util_unittest.cc b/chrome/common/pepper_permission_util_unittest.cc
index 32b3b05..b31297d 100644
--- a/chrome/common/pepper_permission_util_unittest.cc
+++ b/chrome/common/pepper_permission_util_unittest.cc
@@ -8,9 +8,9 @@
#include <string>
#include "chrome/common/extensions/features/feature_channel.h"
+#include "components/crx_file/id_util.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_set.h"
-#include "extensions/common/id_util.h"
#include "testing/gtest/include/gtest/gtest.h"
using chrome::IsExtensionOrSharedModuleWhitelisted;
@@ -45,7 +45,8 @@ scoped_refptr<Extension> CreateExtensionImportingModule(
TEST(PepperPermissionUtilTest, ExtensionWhitelisting) {
ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_UNKNOWN);
ExtensionSet extensions;
- std::string whitelisted_id = id_util::GenerateId("whitelisted_extension");
+ std::string whitelisted_id =
+ crx_file::id_util::GenerateId("whitelisted_extension");
scoped_ptr<base::DictionaryValue> manifest =
DictionaryBuilder()
.Set("name", "Whitelisted Extension")
@@ -62,8 +63,8 @@ TEST(PepperPermissionUtilTest, ExtensionWhitelisting) {
std::string("/manifest.nmf");
std::string bad_scheme_url =
std::string("http://") + whitelisted_id + std::string("/manifest.nmf");
- std::string bad_host_url =
- std::string("chrome-extension://") + id_util::GenerateId("bad_host");
+ std::string bad_host_url = std::string("chrome-extension://") +
+ crx_file::id_util::GenerateId("bad_host");
std::string("/manifest.nmf");
EXPECT_FALSE(
@@ -80,8 +81,8 @@ TEST(PepperPermissionUtilTest, ExtensionWhitelisting) {
TEST(PepperPermissionUtilTest, SharedModuleWhitelisting) {
ScopedCurrentChannel current_channel(chrome::VersionInfo::CHANNEL_UNKNOWN);
ExtensionSet extensions;
- std::string whitelisted_id = id_util::GenerateId("extension_id");
- std::string bad_id = id_util::GenerateId("bad_id");
+ std::string whitelisted_id = crx_file::id_util::GenerateId("extension_id");
+ std::string bad_id = crx_file::id_util::GenerateId("bad_id");
scoped_ptr<base::DictionaryValue> shared_module_manifest =
DictionaryBuilder()
diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS
index dce37d2..7a140d3 100644
--- a/chrome/renderer/DEPS
+++ b/chrome/renderer/DEPS
@@ -6,6 +6,7 @@ include_rules = [
"+components/autofill/core/common",
"+components/cdm/renderer",
"+components/content_settings/core/common",
+ "+components/crx_file",
"+components/data_reduction_proxy/common",
"+components/dom_distiller/core",
"+components/nacl/common",
diff --git a/chrome/renderer/extensions/webstore_bindings.cc b/chrome/renderer/extensions/webstore_bindings.cc
index 2c2f06a..3a82d15 100644
--- a/chrome/renderer/extensions/webstore_bindings.cc
+++ b/chrome/renderer/extensions/webstore_bindings.cc
@@ -8,6 +8,7 @@
#include "chrome/common/extensions/api/webstore/webstore_api_constants.h"
#include "chrome/common/extensions/chrome_extension_messages.h"
#include "chrome/common/extensions/extension_constants.h"
+#include "components/crx_file/id_util.h"
#include "content/public/renderer/render_view.h"
#include "extensions/common/extension.h"
#include "extensions/renderer/script_context.h"
@@ -165,7 +166,7 @@ bool WebstoreBindings::GetWebstoreItemIdFromFrame(
std::string candidate_webstore_item_id = webstore_url.path().substr(
webstore_base_url.path().length());
- if (!extensions::Extension::IdIsValid(candidate_webstore_item_id)) {
+ if (!crx_file::id_util::IdIsValid(candidate_webstore_item_id)) {
*error = kInvalidWebstoreItemUrlError;
return false;
}
diff --git a/chrome/renderer/searchbox/searchbox_extension.cc b/chrome/renderer/searchbox/searchbox_extension.cc
index a9030b88..0af04e7 100644
--- a/chrome/renderer/searchbox/searchbox_extension.cc
+++ b/chrome/renderer/searchbox/searchbox_extension.cc
@@ -15,8 +15,8 @@
#include "chrome/common/url_constants.h"
#include "chrome/grit/renderer_resources.h"
#include "chrome/renderer/searchbox/searchbox.h"
+#include "components/crx_file/id_util.h"
#include "content/public/renderer/render_view.h"
-#include "extensions/common/extension.h"
#include "third_party/WebKit/public/platform/WebURLRequest.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
@@ -849,7 +849,7 @@ void SearchBoxExtensionWrapper::GetThemeBackgroundInfo(
// theme.
// This is the CSS "background-image" format.
// Value is only valid if there's a custom theme background image.
- if (extensions::Extension::IdIsValid(theme_info.theme_id)) {
+ if (crx_file::id_util::IdIsValid(theme_info.theme_id)) {
info->Set(v8::String::NewFromUtf8(isolate, "imageUrl"),
UTF8ToV8String(isolate,
base::StringPrintf(kCSSBackgroundImageFormat,
diff --git a/components/BUILD.gn b/components/BUILD.gn
index 57c403a..45d2db6 100644
--- a/components/BUILD.gn
+++ b/components/BUILD.gn
@@ -191,6 +191,7 @@ test("components_unittests") {
"//components/bookmarks/browser:unit_tests",
"//components/captive_portal:unit_tests",
"//components/cloud_devices/common:unit_tests",
+ "//components/crx_file:unit_tests",
"//components/data_reduction_proxy/browser:unit_tests",
"//components/data_reduction_proxy/common:unit_tests",
"//components/dom_distiller/core:unit_tests",
diff --git a/components/component_updater/component_updater_utils.cc b/components/component_updater/component_updater_utils.cc
index 116a8d0..9ef561e 100644
--- a/components/component_updater/component_updater_utils.cc
+++ b/components/component_updater/component_updater_utils.cc
@@ -17,6 +17,7 @@
#include "base/win/windows_version.h"
#include "components/component_updater/component_updater_configurator.h"
#include "components/component_updater/crx_update_item.h"
+#include "components/crx_file/id_util.h"
#include "components/omaha_query_params/omaha_query_params.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_fetcher.h"
@@ -181,8 +182,7 @@ std::string HexStringToID(const std::string& hexstr) {
}
}
- // TODO(tommycli): Add back the DCHECK validating the generated id. This
- // requires moving the extension id_util functions into components/crx_file.
+ DCHECK(crx_file::id_util::IdIsValid(id));
return id;
}
diff --git a/components/components_tests.gyp b/components/components_tests.gyp
index b0ad4bf..ca6cb2f 100644
--- a/components/components_tests.gyp
+++ b/components/components_tests.gyp
@@ -76,6 +76,7 @@
'captive_portal/captive_portal_detector_unittest.cc',
'cloud_devices/common/cloud_devices_urls_unittest.cc',
'cloud_devices/common/printer_description_unittest.cc',
+ 'crx_file/id_util_unittest.cc',
'data_reduction_proxy/browser/data_reduction_proxy_auth_request_handler_unittest.cc',
'data_reduction_proxy/browser/data_reduction_proxy_config_service_unittest.cc',
'data_reduction_proxy/browser/data_reduction_proxy_metrics_unittest.cc',
@@ -277,6 +278,9 @@
# Dependencies of cloud_devices
'components.gyp:cloud_devices_common',
+ # Dependencies of crx_file
+ 'components.gyp:crx_file',
+
# Dependencies of data_reduction_proxy
'components.gyp:data_reduction_proxy_browser',
'components.gyp:data_reduction_proxy_common',
diff --git a/components/crx_file.gypi b/components/crx_file.gypi
index 2f36f6e..036550d 100644
--- a/components/crx_file.gypi
+++ b/components/crx_file.gypi
@@ -17,6 +17,8 @@
'crx_file/constants.h',
'crx_file/crx_file.cc',
'crx_file/crx_file.h',
+ 'crx_file/id_util.cc',
+ 'crx_file/id_util.h',
],
},
],
diff --git a/components/crx_file/BUILD.gn b/components/crx_file/BUILD.gn
index e8d4798..db28483 100644
--- a/components/crx_file/BUILD.gn
+++ b/components/crx_file/BUILD.gn
@@ -7,9 +7,22 @@ source_set("crx_file") {
"constants.h",
"crx_file.cc",
"crx_file.h",
+ "id_util.cc",
+ "id_util.h",
]
deps = [
"//base",
]
}
+
+source_set("unit_tests") {
+ sources = [
+ "id_util_unittest.cc",
+ ]
+
+ deps = [
+ ":crx_file",
+ "//testing/gtest",
+ ]
+}
diff --git a/components/crx_file/DEPS b/components/crx_file/DEPS
new file mode 100644
index 0000000..4ef4138
--- /dev/null
+++ b/components/crx_file/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+crypto",
+]
diff --git a/extensions/common/id_util.cc b/components/crx_file/id_util.cc
index c59351c..ef271ad 100644
--- a/extensions/common/id_util.cc
+++ b/components/crx_file/id_util.cc
@@ -1,8 +1,8 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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 "extensions/common/id_util.h"
+#include "components/crx_file/id_util.h"
#include "base/files/file_path.h"
#include "base/strings/string_number_conversions.h"
@@ -18,9 +18,8 @@ namespace {
static void ConvertHexadecimalToIDAlphabet(std::string* id) {
for (size_t i = 0; i < id->size(); ++i) {
int val;
- if (base::HexStringToInt(base::StringPiece(id->begin() + i,
- id->begin() + i + 1),
- &val)) {
+ if (base::HexStringToInt(
+ base::StringPiece(id->begin() + i, id->begin() + i + 1), &val)) {
(*id)[i] = val + 'a';
} else {
(*id)[i] = 'a';
@@ -30,7 +29,7 @@ static void ConvertHexadecimalToIDAlphabet(std::string* id) {
} // namespace
-namespace extensions {
+namespace crx_file {
namespace id_util {
// First 16 bytes of SHA256 hashed public key.
@@ -70,5 +69,20 @@ base::FilePath MaybeNormalizePath(const base::FilePath& path) {
#endif
}
+bool IdIsValid(const std::string& id) {
+ // Verify that the id is legal.
+ if (id.size() != (crx_file::id_util::kIdSize * 2))
+ return false;
+
+ // We only support lowercase IDs, because IDs can be used as URL components
+ // (where GURL will lowercase it).
+ std::string temp = base::StringToLowerASCII(id);
+ for (size_t i = 0; i < temp.size(); i++)
+ if (temp[i] < 'a' || temp[i] > 'p')
+ return false;
+
+ return true;
+}
+
} // namespace id_util
-} // namespace extensions
+} // namespace crx_file
diff --git a/extensions/common/id_util.h b/components/crx_file/id_util.h
index 74e690d..4463ff1 100644
--- a/extensions/common/id_util.h
+++ b/components/crx_file/id_util.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Copyright 2014 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 EXTENSIONS_COMMON_ID_UTIL_H_
-#define EXTENSIONS_COMMON_ID_UTIL_H_
+#ifndef COMPONENTS_CRX_FILE_ID_UTIL_H_
+#define COMPONENTS_CRX_FILE_ID_UTIL_H_
#include <string>
@@ -11,7 +11,7 @@ namespace base {
class FilePath;
}
-namespace extensions {
+namespace crx_file {
namespace id_util {
// The number of bytes in a legal id.
@@ -29,7 +29,11 @@ std::string GenerateIdForPath(const base::FilePath& path);
// sure the drive letter is uppercase.
base::FilePath MaybeNormalizePath(const base::FilePath& path);
+// Checks if |id| is a valid extension-id. Extension-ids are used for anything
+// that comes in a CRX file, including apps, extensions, and components.
+bool IdIsValid(const std::string& id);
+
} // namespace id_util
-} // namespace extensions
+} // namespace crx_file
-#endif // EXTENSIONS_COMMON_ID_UTIL_H_
+#endif // COMPONENTS_CRX_FILE_ID_UTIL_H_
diff --git a/components/crx_file/id_util_unittest.cc b/components/crx_file/id_util_unittest.cc
new file mode 100644
index 0000000..fd7f620
--- /dev/null
+++ b/components/crx_file/id_util_unittest.cc
@@ -0,0 +1,44 @@
+// Copyright 2014 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 "components/crx_file/id_util.h"
+
+#include "base/basictypes.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace crx_file {
+namespace id_util {
+
+TEST(IDUtilTest, GenerateID) {
+ const uint8 public_key_info[] = {
+ 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
+ 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81,
+ 0x89, 0x02, 0x81, 0x81, 0x00, 0xb8, 0x7f, 0x2b, 0x20, 0xdc, 0x7c, 0x9b,
+ 0x0c, 0xdc, 0x51, 0x61, 0x99, 0x0d, 0x36, 0x0f, 0xd4, 0x66, 0x88, 0x08,
+ 0x55, 0x84, 0xd5, 0x3a, 0xbf, 0x2b, 0xa4, 0x64, 0x85, 0x7b, 0x0c, 0x04,
+ 0x13, 0x3f, 0x8d, 0xf4, 0xbc, 0x38, 0x0d, 0x49, 0xfe, 0x6b, 0xc4, 0x5a,
+ 0xb0, 0x40, 0x53, 0x3a, 0xd7, 0x66, 0x09, 0x0f, 0x9e, 0x36, 0x74, 0x30,
+ 0xda, 0x8a, 0x31, 0x4f, 0x1f, 0x14, 0x50, 0xd7, 0xc7, 0x20, 0x94, 0x17,
+ 0xde, 0x4e, 0xb9, 0x57, 0x5e, 0x7e, 0x0a, 0xe5, 0xb2, 0x65, 0x7a, 0x89,
+ 0x4e, 0xb6, 0x47, 0xff, 0x1c, 0xbd, 0xb7, 0x38, 0x13, 0xaf, 0x47, 0x85,
+ 0x84, 0x32, 0x33, 0xf3, 0x17, 0x49, 0xbf, 0xe9, 0x96, 0xd0, 0xd6, 0x14,
+ 0x6f, 0x13, 0x8d, 0xc5, 0xfc, 0x2c, 0x72, 0xba, 0xac, 0xea, 0x7e, 0x18,
+ 0x53, 0x56, 0xa6, 0x83, 0xa2, 0xce, 0x93, 0x93, 0xe7, 0x1f, 0x0f, 0xe6,
+ 0x0f, 0x02, 0x03, 0x01, 0x00, 0x01};
+ std::string extension_id =
+ GenerateId(std::string(reinterpret_cast<const char*>(&public_key_info[0]),
+ arraysize(public_key_info)));
+ EXPECT_EQ("melddjfinppjdikinhbgehiennejpfhp", extension_id);
+
+ EXPECT_EQ("jpignaibiiemhngfjkcpokkamffknabf", GenerateId("test"));
+
+ EXPECT_EQ("ncocknphbhhlhkikpnnlmbcnbgdempcd", GenerateId("_"));
+
+ EXPECT_EQ(
+ "jimneklojkjdibfkgiiophfhjhbdgcfi",
+ GenerateId("this_string_is_longer_than_a_single_sha256_hash_digest"));
+}
+
+} // namespace id_util
+} // namespace crx_file
diff --git a/extensions/BUILD.gn b/extensions/BUILD.gn
index fc4892c..569a930 100644
--- a/extensions/BUILD.gn
+++ b/extensions/BUILD.gn
@@ -142,7 +142,6 @@ test("unittests") {
"common/api/sockets/sockets_manifest_permission_unittest.cc",
"common/csp_validator_unittest.cc",
"common/event_filter_unittest.cc",
- "common/id_util_unittest.cc",
"common/one_shot_event_unittest.cc",
"common/permissions/manifest_permission_set_unittest.cc",
"common/user_script_unittest.cc",
diff --git a/extensions/browser/api/api_resource_manager_unittest.cc b/extensions/browser/api/api_resource_manager_unittest.cc
index 6747b8e..8eff4cf 100644
--- a/extensions/browser/api/api_resource_manager_unittest.cc
+++ b/extensions/browser/api/api_resource_manager_unittest.cc
@@ -10,7 +10,6 @@
#include "extensions/browser/api/api_resource_manager.h"
#include "extensions/browser/extensions_test.h"
#include "extensions/common/extension.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
diff --git a/extensions/browser/api/storage/storage_api_unittest.cc b/extensions/browser/api/storage/storage_api_unittest.cc
index a108b5d..e9f4121 100644
--- a/extensions/browser/api/storage/storage_api_unittest.cc
+++ b/extensions/browser/api/storage/storage_api_unittest.cc
@@ -18,7 +18,6 @@
#include "extensions/browser/extension_system.h"
#include "extensions/browser/value_store/leveldb_value_store.h"
#include "extensions/browser/value_store/value_store.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest.h"
#include "extensions/common/test_util.h"
#include "third_party/leveldatabase/src/include/leveldb/db.h"
diff --git a/extensions/browser/error_map_unittest.cc b/extensions/browser/error_map_unittest.cc
index 8330c6a..32bb8cf 100644
--- a/extensions/browser/error_map_unittest.cc
+++ b/extensions/browser/error_map_unittest.cc
@@ -7,10 +7,10 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
+#include "components/crx_file/id_util.h"
#include "extensions/browser/extension_error.h"
#include "extensions/browser/extension_error_test_util.h"
#include "extensions/common/constants.h"
-#include "extensions/common/id_util.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
@@ -37,7 +37,7 @@ TEST_F(ErrorMapUnitTest, AddAndRemoveErrors) {
const size_t kNumTotalErrors = 6;
const size_t kNumNonIncognitoErrors = 3;
- const std::string kId = id_util::GenerateId("id");
+ const std::string kId = crx_file::id_util::GenerateId("id");
// Populate with both incognito and non-incognito errors (evenly distributed).
for (size_t i = 0; i < kNumTotalErrors; ++i) {
ASSERT_TRUE(errors_.AddError(
@@ -59,7 +59,7 @@ TEST_F(ErrorMapUnitTest, AddAndRemoveErrors) {
ASSERT_FALSE(list[i]->from_incognito());
// Add another error for a different extension id.
- const std::string kSecondId = id_util::GenerateId("id2");
+ const std::string kSecondId = crx_file::id_util::GenerateId("id2");
ASSERT_TRUE(errors_.AddError(CreateNewRuntimeError(kSecondId, "foo")));
// There should be two entries now, one for each id, and there should be one
@@ -89,7 +89,7 @@ TEST_F(ErrorMapUnitTest, ExcessiveErrorsGetCropped) {
// This constant matches one of the same name in error_console.cc.
const size_t kMaxErrorsPerExtension = 100;
const size_t kNumExtraErrors = 5;
- const std::string kId = id_util::GenerateId("id");
+ const std::string kId = crx_file::id_util::GenerateId("id");
// Add new errors, with each error's message set to its number.
for (size_t i = 0; i < kMaxErrorsPerExtension + kNumExtraErrors; ++i) {
@@ -116,7 +116,7 @@ TEST_F(ErrorMapUnitTest, ExcessiveErrorsGetCropped) {
TEST_F(ErrorMapUnitTest, DuplicateErrorsAreReplaced) {
ASSERT_EQ(0u, errors_.size());
- const std::string kId = id_util::GenerateId("id");
+ const std::string kId = crx_file::id_util::GenerateId("id");
const size_t kNumErrors = 3u;
// Report three errors.
diff --git a/extensions/browser/extension_message_filter.cc b/extensions/browser/extension_message_filter.cc
index c9c6c9b..7ae576f 100644
--- a/extensions/browser/extension_message_filter.cc
+++ b/extensions/browser/extension_message_filter.cc
@@ -4,6 +4,7 @@
#include "extensions/browser/extension_message_filter.h"
+#include "components/crx_file/id_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/resource_dispatcher_host.h"
@@ -105,7 +106,7 @@ void ExtensionMessageFilter::OnExtensionAddListener(
if (!router)
return;
- if (Extension::IdIsValid(extension_id)) {
+ if (crx_file::id_util::IdIsValid(extension_id)) {
router->AddEventListener(event_name, process, extension_id);
} else if (listener_url.is_valid()) {
router->AddEventListenerForURL(event_name, process, listener_url);
@@ -126,7 +127,7 @@ void ExtensionMessageFilter::OnExtensionRemoveListener(
if (!router)
return;
- if (Extension::IdIsValid(extension_id)) {
+ if (crx_file::id_util::IdIsValid(extension_id)) {
router->RemoveEventListener(event_name, process, extension_id);
} else if (listener_url.is_valid()) {
router->RemoveEventListenerForURL(event_name, process, listener_url);
diff --git a/extensions/browser/extension_prefs.cc b/extensions/browser/extension_prefs.cc
index d7774c5..aa7fd59 100644
--- a/extensions/browser/extension_prefs.cc
+++ b/extensions/browser/extension_prefs.cc
@@ -12,6 +12,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/value_conversions.h"
+#include "components/crx_file/id_util.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "extensions/browser/admin_policy.h"
#include "extensions/browser/app_sorting.h"
@@ -287,7 +288,7 @@ ExtensionPrefs::ScopedUpdate<T, type_enum_value>::ScopedUpdate(
: update_(prefs->pref_service(), pref_names::kExtensions),
extension_id_(extension_id),
key_(key) {
- DCHECK(Extension::IdIsValid(extension_id_));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id_));
}
template <typename T, base::Value::Type type_enum_value>
@@ -456,7 +457,7 @@ const base::DictionaryValue* ExtensionPrefs::GetExtensionPref(
void ExtensionPrefs::UpdateExtensionPref(const std::string& extension_id,
const std::string& key,
base::Value* data_value) {
- if (!Extension::IdIsValid(extension_id)) {
+ if (!crx_file::id_util::IdIsValid(extension_id)) {
NOTREACHED() << "Invalid extension_id " << extension_id;
return;
}
@@ -683,7 +684,7 @@ bool ExtensionPrefs::IsExternalExtensionAcknowledged(
void ExtensionPrefs::AcknowledgeExternalExtension(
const std::string& extension_id) {
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
UpdateExtensionPref(extension_id, kPrefExternalAcknowledged,
new base::FundamentalValue(true));
UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL);
@@ -696,7 +697,7 @@ bool ExtensionPrefs::IsBlacklistedExtensionAcknowledged(
void ExtensionPrefs::AcknowledgeBlacklistedExtension(
const std::string& extension_id) {
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
UpdateExtensionPref(extension_id, kPrefBlacklistAcknowledged,
new base::FundamentalValue(true));
UpdateExtensionPref(extension_id, kPrefAcknowledgePromptCount, NULL);
@@ -709,7 +710,7 @@ bool ExtensionPrefs::IsExternalInstallFirstRun(
void ExtensionPrefs::SetExternalInstallFirstRun(
const std::string& extension_id) {
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
UpdateExtensionPref(extension_id, kPrefExternalInstallFirstRun,
new base::FundamentalValue(true));
}
@@ -953,13 +954,13 @@ base::Time ReadTime(const base::DictionaryValue* dictionary, const char* key) {
} // namespace
base::Time ExtensionPrefs::LastPingDay(const std::string& extension_id) const {
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
return ReadTime(GetExtensionPref(extension_id), kLastPingDay);
}
void ExtensionPrefs::SetLastPingDay(const std::string& extension_id,
const base::Time& time) {
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
ScopedExtensionPrefUpdate update(prefs_, extension_id);
SaveTime(update.Get(), kLastPingDay, time);
}
@@ -975,13 +976,13 @@ void ExtensionPrefs::SetBlacklistLastPingDay(const base::Time& time) {
}
base::Time ExtensionPrefs::LastActivePingDay(const std::string& extension_id) {
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
return ReadTime(GetExtensionPref(extension_id), kLastActivePingDay);
}
void ExtensionPrefs::SetLastActivePingDay(const std::string& extension_id,
const base::Time& time) {
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
ScopedExtensionPrefUpdate update(prefs_, extension_id);
SaveTime(update.Get(), kLastActivePingDay, time);
}
@@ -1080,14 +1081,14 @@ void ExtensionPrefs::MigrateDisableReasons(
PermissionSet* ExtensionPrefs::GetGrantedPermissions(
const std::string& extension_id) {
- CHECK(Extension::IdIsValid(extension_id));
+ CHECK(crx_file::id_util::IdIsValid(extension_id));
return ReadPrefAsPermissionSet(extension_id, kPrefGrantedPermissions);
}
void ExtensionPrefs::AddGrantedPermissions(
const std::string& extension_id,
const PermissionSet* permissions) {
- CHECK(Extension::IdIsValid(extension_id));
+ CHECK(crx_file::id_util::IdIsValid(extension_id));
scoped_refptr<PermissionSet> granted_permissions(
GetGrantedPermissions(extension_id));
@@ -1105,7 +1106,7 @@ void ExtensionPrefs::AddGrantedPermissions(
void ExtensionPrefs::RemoveGrantedPermissions(
const std::string& extension_id,
const PermissionSet* permissions) {
- CHECK(Extension::IdIsValid(extension_id));
+ CHECK(crx_file::id_util::IdIsValid(extension_id));
scoped_refptr<PermissionSet> granted_permissions(
GetGrantedPermissions(extension_id));
@@ -1122,7 +1123,7 @@ void ExtensionPrefs::RemoveGrantedPermissions(
PermissionSet* ExtensionPrefs::GetActivePermissions(
const std::string& extension_id) {
- CHECK(Extension::IdIsValid(extension_id));
+ CHECK(crx_file::id_util::IdIsValid(extension_id));
return ReadPrefAsPermissionSet(extension_id, kPrefActivePermissions);
}
@@ -1401,7 +1402,7 @@ ExtensionPrefs::GetInstalledExtensionsInfo() const {
prefs_->GetDictionary(pref_names::kExtensions);
for (base::DictionaryValue::Iterator extension_id(*extensions);
!extension_id.IsAtEnd(); extension_id.Advance()) {
- if (!Extension::IdIsValid(extension_id.key()))
+ if (!crx_file::id_util::IdIsValid(extension_id.key()))
continue;
scoped_ptr<ExtensionInfo> info =
@@ -1422,7 +1423,7 @@ ExtensionPrefs::GetUninstalledExtensionsInfo() const {
for (base::DictionaryValue::Iterator extension_id(*extensions);
!extension_id.IsAtEnd(); extension_id.Advance()) {
const base::DictionaryValue* ext = NULL;
- if (!Extension::IdIsValid(extension_id.key()) ||
+ if (!crx_file::id_util::IdIsValid(extension_id.key()) ||
!IsExternalExtensionUninstalled(extension_id.key()) ||
!extension_id.value().GetAsDictionary(&ext))
continue;
@@ -1478,7 +1479,7 @@ bool ExtensionPrefs::RemoveDelayedInstallInfo(
bool ExtensionPrefs::FinishDelayedInstallInfo(
const std::string& extension_id) {
- CHECK(Extension::IdIsValid(extension_id));
+ CHECK(crx_file::id_util::IdIsValid(extension_id));
ScopedExtensionPrefUpdate update(prefs_, extension_id);
base::DictionaryValue* extension_dict = update.Get();
base::DictionaryValue* pending_install_dict = NULL;
@@ -1561,7 +1562,7 @@ scoped_ptr<ExtensionPrefs::ExtensionsInfo> ExtensionPrefs::
prefs_->GetDictionary(pref_names::kExtensions);
for (base::DictionaryValue::Iterator extension_id(*extensions);
!extension_id.IsAtEnd(); extension_id.Advance()) {
- if (!Extension::IdIsValid(extension_id.key()))
+ if (!crx_file::id_util::IdIsValid(extension_id.key()))
continue;
scoped_ptr<ExtensionInfo> info = GetDelayedInstallInfo(extension_id.key());
@@ -1712,7 +1713,7 @@ base::Time ExtensionPrefs::GetLastLaunchTime(
void ExtensionPrefs::SetLastLaunchTime(const std::string& extension_id,
const base::Time& time) {
- DCHECK(Extension::IdIsValid(extension_id));
+ DCHECK(crx_file::id_util::IdIsValid(extension_id));
ScopedExtensionPrefUpdate update(prefs_, extension_id);
SaveTime(update.Get(), kPrefLastLaunchTime, time);
}
diff --git a/extensions/browser/external_provider_interface.h b/extensions/browser/external_provider_interface.h
index dd80e31..d14fc7c 100644
--- a/extensions/browser/external_provider_interface.h
+++ b/extensions/browser/external_provider_interface.h
@@ -27,7 +27,8 @@ class ExternalProviderInterface {
// caller what extensions are registered, and which |id|, |version| and |path|
// they have. See also VisitRegisteredExtension below. Ownership of |version|
// is not transferred to the visitor. Callers of the methods below must
- // ensure that |id| is a valid extension id (use Extension::IdIsValid(id)).
+ // ensure that |id| is a valid extension id (use
+ // crx_file::id_util::IdIsValid(id)).
class VisitorInterface {
public:
// Return true if the extension install will proceed. Install will not
diff --git a/extensions/browser/file_reader_unittest.cc b/extensions/browser/file_reader_unittest.cc
index 120ad66..491d594 100644
--- a/extensions/browser/file_reader_unittest.cc
+++ b/extensions/browser/file_reader_unittest.cc
@@ -8,11 +8,11 @@
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
+#include "components/crx_file/id_util.h"
#include "content/public/test/test_browser_thread.h"
#include "extensions/browser/file_reader.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/extension_resource.h"
-#include "extensions/common/id_util.h"
#include "testing/gtest/include/gtest/gtest.h"
using content::BrowserThread;
@@ -55,7 +55,7 @@ class Receiver {
void RunBasicTest(const char* filename) {
base::FilePath path;
PathService::Get(DIR_TEST_DATA, &path);
- std::string extension_id = id_util::GenerateId("test");
+ std::string extension_id = crx_file::id_util::GenerateId("test");
ExtensionResource resource(
extension_id, path, base::FilePath().AppendASCII(filename));
path = path.AppendASCII(filename);
@@ -86,7 +86,7 @@ TEST_F(FileReaderTest, BiggerFile) {
TEST_F(FileReaderTest, NonExistantFile) {
base::FilePath path;
PathService::Get(DIR_TEST_DATA, &path);
- std::string extension_id = id_util::GenerateId("test");
+ std::string extension_id = crx_file::id_util::GenerateId("test");
ExtensionResource resource(extension_id, path, base::FilePath(
FILE_PATH_LITERAL("file_that_does_not_exist")));
path = path.AppendASCII("file_that_does_not_exist");
diff --git a/extensions/browser/verified_contents.cc b/extensions/browser/verified_contents.cc
index f4272b7..b92e72d 100644
--- a/extensions/browser/verified_contents.cc
+++ b/extensions/browser/verified_contents.cc
@@ -9,6 +9,7 @@
#include "base/json/json_reader.h"
#include "base/strings/string_util.h"
#include "base/values.h"
+#include "components/crx_file/id_util.h"
#include "crypto/signature_verifier.h"
#include "extensions/common/extension.h"
@@ -131,7 +132,7 @@ bool VerifiedContents::InitFrom(const base::FilePath& path,
std::string item_id;
if (!dictionary->GetString(kItemIdKey, &item_id) ||
- !Extension::IdIsValid(item_id))
+ !crx_file::id_util::IdIsValid(item_id))
return false;
extension_id_ = item_id;
diff --git a/extensions/common/BUILD.gn b/extensions/common/BUILD.gn
index 204d9db..5ce44df 100644
--- a/extensions/common/BUILD.gn
+++ b/extensions/common/BUILD.gn
@@ -78,8 +78,6 @@ source_set("common") {
"features/simple_feature_filter.h",
"file_util.cc",
"file_util.h",
- "id_util.cc",
- "id_util.h",
"install_warning.cc",
"install_warning.h",
"manifest.cc",
@@ -184,6 +182,7 @@ source_set("common") {
# api resources compiled into the chrome resource bundle.
# http://crbug.com/162530
"//chrome:resources",
+ "//components/crx_file",
"//components/url_matcher",
"//content/public/common",
"//crypto",
diff --git a/extensions/common/extension.cc b/extensions/common/extension.cc
index c9562af..d8e798e 100644
--- a/extensions/common/extension.cc
+++ b/extensions/common/extension.cc
@@ -20,10 +20,10 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "base/version.h"
+#include "components/crx_file/id_util.h"
#include "content/public/common/url_constants.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handler.h"
@@ -133,22 +133,6 @@ scoped_refptr<Extension> Extension::Create(const base::FilePath& path,
return extension;
}
-// static
-bool Extension::IdIsValid(const std::string& id) {
- // Verify that the id is legal.
- if (id.size() != (id_util::kIdSize * 2))
- return false;
-
- // We only support lowercase IDs, because IDs can be used as URL components
- // (where GURL will lowercase it).
- std::string temp = base::StringToLowerASCII(id);
- for (size_t i = 0; i < temp.size(); i++)
- if (temp[i] < 'a' || temp[i] > 'p')
- return false;
-
- return true;
-}
-
Manifest::Type Extension::GetType() const {
return converted_from_user_script() ?
Manifest::TYPE_USER_SCRIPT : manifest_->type();
@@ -470,7 +454,7 @@ bool Extension::InitExtensionID(extensions::Manifest* manifest,
*error = base::ASCIIToUTF16(errors::kInvalidKey);
return false;
}
- std::string extension_id = id_util::GenerateId(public_key_bytes);
+ std::string extension_id = crx_file::id_util::GenerateId(public_key_bytes);
manifest->set_extension_id(extension_id);
return true;
}
@@ -482,7 +466,7 @@ bool Extension::InitExtensionID(extensions::Manifest* manifest,
// If there is a path, we generate the ID from it. This is useful for
// development mode, because it keeps the ID stable across restarts and
// reloading the extension.
- std::string extension_id = id_util::GenerateIdForPath(path);
+ std::string extension_id = crx_file::id_util::GenerateIdForPath(path);
if (extension_id.empty()) {
NOTREACHED() << "Could not create ID from path.";
return false;
@@ -503,7 +487,7 @@ Extension::Extension(const base::FilePath& path,
wants_file_access_(false),
creation_flags_(0) {
DCHECK(path.empty() || path.IsAbsolute());
- path_ = id_util::MaybeNormalizePath(path);
+ path_ = crx_file::id_util::MaybeNormalizePath(path);
}
Extension::~Extension() {
diff --git a/extensions/common/extension.h b/extensions/common/extension.h
index de0e2f5..668f52f 100644
--- a/extensions/common/extension.h
+++ b/extensions/common/extension.h
@@ -202,9 +202,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> {
// The mimetype used for extensions.
static const char kMimeType[];
- // Checks to see if the extension has a valid ID.
- static bool IdIsValid(const std::string& id);
-
// See Type definition in Manifest.
Manifest::Type GetType() const;
diff --git a/extensions/common/extension_resource_unittest.cc b/extensions/common/extension_resource_unittest.cc
index eb16e5b..17495e3 100644
--- a/extensions/common/extension_resource_unittest.cc
+++ b/extensions/common/extension_resource_unittest.cc
@@ -7,10 +7,10 @@
#include "base/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/path_service.h"
+#include "components/crx_file/id_util.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/extension_resource.h"
-#include "extensions/common/id_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
@@ -36,7 +36,7 @@ TEST(ExtensionResourceTest, CreateWithMissingResourceOnDisk) {
ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &root_path));
base::FilePath relative_path;
relative_path = relative_path.AppendASCII("cira.js");
- std::string extension_id = id_util::GenerateId("test");
+ std::string extension_id = crx_file::id_util::GenerateId("test");
ExtensionResource resource(extension_id, root_path, relative_path);
// The path doesn't exist on disk, we will be returned an empty path.
@@ -57,7 +57,7 @@ TEST(ExtensionResourceTest, ResourcesOutsideOfPath) {
base::FilePath outer_file = temp.path().AppendASCII("outer");
ASSERT_TRUE(base::WriteFile(outer_file, "X", 1));
ASSERT_TRUE(base::WriteFile(inner_file, "X", 1));
- std::string extension_id = id_util::GenerateId("test");
+ std::string extension_id = crx_file::id_util::GenerateId("test");
#if defined(OS_POSIX)
base::FilePath symlink_file = inner_dir.AppendASCII("symlink");
@@ -143,7 +143,7 @@ TEST(ExtensionResourceTest, CreateWithAllResourcesOnDisk) {
}
base::FilePath path;
- std::string extension_id = id_util::GenerateId("test");
+ std::string extension_id = crx_file::id_util::GenerateId("test");
ExtensionResource resource(extension_id, temp.path(),
base::FilePath().AppendASCII(filename));
base::FilePath resolved_path = resource.GetFilePath();
diff --git a/extensions/common/id_util_unittest.cc b/extensions/common/id_util_unittest.cc
deleted file mode 100644
index f43d206..0000000
--- a/extensions/common/id_util_unittest.cc
+++ /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.
-
-#include "base/basictypes.h"
-#include "extensions/common/id_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace extensions {
-namespace id_util {
-
-TEST(IDUtilTest, GenerateID) {
- const uint8 public_key_info[] = {
- 0x30, 0x81, 0x9f, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
- 0x0d, 0x01, 0x01, 0x01, 0x05, 0x00, 0x03, 0x81, 0x8d, 0x00, 0x30, 0x81,
- 0x89, 0x02, 0x81, 0x81, 0x00, 0xb8, 0x7f, 0x2b, 0x20, 0xdc, 0x7c, 0x9b,
- 0x0c, 0xdc, 0x51, 0x61, 0x99, 0x0d, 0x36, 0x0f, 0xd4, 0x66, 0x88, 0x08,
- 0x55, 0x84, 0xd5, 0x3a, 0xbf, 0x2b, 0xa4, 0x64, 0x85, 0x7b, 0x0c, 0x04,
- 0x13, 0x3f, 0x8d, 0xf4, 0xbc, 0x38, 0x0d, 0x49, 0xfe, 0x6b, 0xc4, 0x5a,
- 0xb0, 0x40, 0x53, 0x3a, 0xd7, 0x66, 0x09, 0x0f, 0x9e, 0x36, 0x74, 0x30,
- 0xda, 0x8a, 0x31, 0x4f, 0x1f, 0x14, 0x50, 0xd7, 0xc7, 0x20, 0x94, 0x17,
- 0xde, 0x4e, 0xb9, 0x57, 0x5e, 0x7e, 0x0a, 0xe5, 0xb2, 0x65, 0x7a, 0x89,
- 0x4e, 0xb6, 0x47, 0xff, 0x1c, 0xbd, 0xb7, 0x38, 0x13, 0xaf, 0x47, 0x85,
- 0x84, 0x32, 0x33, 0xf3, 0x17, 0x49, 0xbf, 0xe9, 0x96, 0xd0, 0xd6, 0x14,
- 0x6f, 0x13, 0x8d, 0xc5, 0xfc, 0x2c, 0x72, 0xba, 0xac, 0xea, 0x7e, 0x18,
- 0x53, 0x56, 0xa6, 0x83, 0xa2, 0xce, 0x93, 0x93, 0xe7, 0x1f, 0x0f, 0xe6,
- 0x0f, 0x02, 0x03, 0x01, 0x00, 0x01
- };
- std::string extension_id = GenerateId(
- std::string(reinterpret_cast<const char*>(&public_key_info[0]),
- arraysize(public_key_info)));
- EXPECT_EQ("melddjfinppjdikinhbgehiennejpfhp", extension_id);
-
- EXPECT_EQ("jpignaibiiemhngfjkcpokkamffknabf", GenerateId("test"));
-
- EXPECT_EQ("ncocknphbhhlhkikpnnlmbcnbgdempcd", GenerateId("_"));
-
- EXPECT_EQ("jimneklojkjdibfkgiiophfhjhbdgcfi",
- GenerateId(
- "this_string_is_longer_than_a_single_sha256_hash_digest"));
-}
-
-} // namespace id_util
-} // namespace extensions
diff --git a/extensions/common/manifest_handlers/externally_connectable.cc b/extensions/common/manifest_handlers/externally_connectable.cc
index 8fba3db..0a06c01 100644
--- a/extensions/common/manifest_handlers/externally_connectable.cc
+++ b/extensions/common/manifest_handlers/externally_connectable.cc
@@ -8,6 +8,7 @@
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
+#include "components/crx_file/id_util.h"
#include "extensions/common/api/extensions_manifest_types.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_constants.h"
@@ -172,7 +173,7 @@ scoped_ptr<ExternallyConnectableInfo> ExternallyConnectableInfo::FromValue(
++it) {
if (*it == kAllIds) {
all_ids = true;
- } else if (Extension::IdIsValid(*it)) {
+ } else if (crx_file::id_util::IdIsValid(*it)) {
ids.push_back(*it);
} else {
*error =
diff --git a/extensions/common/manifest_handlers/shared_module_info.cc b/extensions/common/manifest_handlers/shared_module_info.cc
index 38eef6e..2f712fd 100644
--- a/extensions/common/manifest_handlers/shared_module_info.cc
+++ b/extensions/common/manifest_handlers/shared_module_info.cc
@@ -10,6 +10,7 @@
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/version.h"
+#include "components/crx_file/id_util.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/manifest_constants.h"
@@ -52,7 +53,7 @@ void SharedModuleInfo::ParseImportedPath(const std::string& path,
std::vector<std::string> tokens;
Tokenize(path, std::string("/"), &tokens);
if (tokens.size() > 2 && tokens[0] == kModulesDir &&
- Extension::IdIsValid(tokens[1])) {
+ crx_file::id_util::IdIsValid(tokens[1])) {
*import_id = tokens[1];
*import_relative_path = tokens[2];
for (size_t i = 3; i < tokens.size(); ++i)
@@ -65,7 +66,7 @@ bool SharedModuleInfo::IsImportedPath(const std::string& path) {
std::vector<std::string> tokens;
Tokenize(path, std::string("/"), &tokens);
if (tokens.size() > 2 && tokens[0] == kModulesDir &&
- Extension::IdIsValid(tokens[1])) {
+ crx_file::id_util::IdIsValid(tokens[1])) {
return true;
}
return false;
@@ -154,7 +155,7 @@ bool SharedModuleInfo::Parse(const Extension* extension,
for (size_t i = 0; i < whitelist->GetSize(); ++i) {
std::string extension_id;
if (!whitelist->GetString(i, &extension_id) ||
- !Extension::IdIsValid(extension_id)) {
+ !crx_file::id_util::IdIsValid(extension_id)) {
*error = ErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidExportWhitelistString, base::IntToString(i));
return false;
@@ -195,7 +196,7 @@ bool SharedModuleInfo::Parse(const Extension* extension,
std::string extension_id;
imports_.push_back(ImportInfo());
if (!import_entry->GetString(keys::kId, &extension_id) ||
- !Extension::IdIsValid(extension_id)) {
+ !crx_file::id_util::IdIsValid(extension_id)) {
*error = ErrorUtils::FormatErrorMessageUTF16(
errors::kInvalidImportId, base::IntToString(i));
return false;
diff --git a/extensions/common/permissions/permissions_data_unittest.cc b/extensions/common/permissions/permissions_data_unittest.cc
index 70435b0..295f8d5 100644
--- a/extensions/common/permissions/permissions_data_unittest.cc
+++ b/extensions/common/permissions/permissions_data_unittest.cc
@@ -11,11 +11,11 @@
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/extensions/extension_test_util.h"
#include "chrome/common/extensions/features/feature_channel.h"
+#include "components/crx_file/id_util.h"
#include "content/public/common/socket_permission_request.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
-#include "extensions/common/id_util.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/permissions/api_permission.h"
@@ -358,8 +358,8 @@ class ExtensionScriptAndCaptureVisibleTest : public testing::Test {
file_url("file:///foo/bar"),
favicon_url("chrome://favicon/http://www.google.com"),
extension_url("chrome-extension://" +
- id_util::GenerateIdForPath(
- base::FilePath(FILE_PATH_LITERAL("foo")))),
+ crx_file::id_util::GenerateIdForPath(
+ base::FilePath(FILE_PATH_LITERAL("foo")))),
settings_url("chrome://settings"),
about_url("about:flags") {
urls_.insert(http_url);
diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp
index 858b46e..ed6757d 100644
--- a/extensions/extensions.gyp
+++ b/extensions/extensions.gyp
@@ -107,8 +107,6 @@
'common/features/simple_feature_filter.h',
'common/file_util.cc',
'common/file_util.h',
- 'common/id_util.cc',
- 'common/id_util.h',
'common/install_warning.cc',
'common/install_warning.h',
'common/manifest.cc',
@@ -900,7 +898,6 @@
'common/api/sockets/sockets_manifest_permission_unittest.cc',
'common/csp_validator_unittest.cc',
'common/event_filter_unittest.cc',
- 'common/id_util_unittest.cc',
'common/one_shot_event_unittest.cc',
'common/permissions/manifest_permission_set_unittest.cc',
'common/user_script_unittest.cc',
diff --git a/extensions/renderer/user_script_set_manager.cc b/extensions/renderer/user_script_set_manager.cc
index 6aa22d9..6f46792 100644
--- a/extensions/renderer/user_script_set_manager.cc
+++ b/extensions/renderer/user_script_set_manager.cc
@@ -4,6 +4,7 @@
#include "extensions/renderer/user_script_set_manager.h"
+#include "components/crx_file/id_util.h"
#include "content/public/renderer/render_thread.h"
#include "extensions/common/extension_messages.h"
#include "extensions/renderer/dispatcher.h"
@@ -83,7 +84,7 @@ void UserScriptSetManager::OnUpdateUserScripts(
for (std::set<std::string>::const_iterator iter = changed_extensions.begin();
iter != changed_extensions.end();
++iter) {
- if (!Extension::IdIsValid(*iter)) {
+ if (!crx_file::id_util::IdIsValid(*iter)) {
NOTREACHED() << "Invalid extension id: " << *iter;
return;
}