| Index: chrome/browser/extensions/external_registry_extension_loader_win.cc
|
| diff --git a/chrome/browser/extensions/external_registry_extension_provider_win.cc b/chrome/browser/extensions/external_registry_extension_loader_win.cc
|
| similarity index 52%
|
| rename from chrome/browser/extensions/external_registry_extension_provider_win.cc
|
| rename to chrome/browser/extensions/external_registry_extension_loader_win.cc
|
| index 16b107ff9fdd3b040688442ac4eed3065f5dae12..7f2df55b57f15aac25a8b9c640c7ea6586165366 100644
|
| --- a/chrome/browser/extensions/external_registry_extension_provider_win.cc
|
| +++ b/chrome/browser/extensions/external_registry_extension_loader_win.cc
|
| @@ -2,13 +2,16 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/extensions/external_registry_extension_provider_win.h"
|
| +#include "chrome/browser/extensions/external_registry_extension_loader_win.h"
|
|
|
| #include "base/file_path.h"
|
| #include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| +#include "base/values.h"
|
| #include "base/version.h"
|
| #include "base/win/registry.h"
|
| +#include "chrome/browser/browser_thread.h"
|
| +#include "chrome/browser/extensions/external_extension_provider_impl.h"
|
|
|
| namespace {
|
|
|
| @@ -24,24 +27,21 @@ const wchar_t kRegistryExtensionPath[] = L"path";
|
| // Registry value of that key that defines the current version of the .crx file.
|
| const wchar_t kRegistryExtensionVersion[] = L"version";
|
|
|
| -bool OpenKeyById(const std::string& id, base::win::RegKey *key) {
|
| - std::wstring key_path = ASCIIToWide(kRegistryExtensions);
|
| - key_path.append(L"\\");
|
| - key_path.append(ASCIIToWide(id));
|
| -
|
| - return key->Open(kRegRoot, key_path.c_str(), KEY_READ);
|
| -}
|
| -
|
| } // namespace
|
|
|
| -ExternalRegistryExtensionProvider::ExternalRegistryExtensionProvider() {
|
| +void ExternalRegistryExtensionLoader::StartLoading() {
|
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + BrowserThread::PostTask(
|
| + BrowserThread::FILE, FROM_HERE,
|
| + NewRunnableMethod(
|
| + this,
|
| + &ExternalRegistryExtensionLoader::LoadOnFileThread));
|
| }
|
|
|
| -ExternalRegistryExtensionProvider::~ExternalRegistryExtensionProvider() {
|
| -}
|
| +void ExternalRegistryExtensionLoader::LoadOnFileThread() {
|
| + CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| + scoped_ptr<DictionaryValue> prefs(new DictionaryValue);
|
|
|
| -void ExternalRegistryExtensionProvider::VisitRegisteredExtension(
|
| - Visitor* visitor) const {
|
| base::win::RegistryKeyIterator iterator(
|
| kRegRoot, ASCIIToWide(kRegistryExtensions).c_str());
|
| while (iterator.Valid()) {
|
| @@ -57,19 +57,12 @@ void ExternalRegistryExtensionProvider::VisitRegisteredExtension(
|
| std::string id = WideToASCII(iterator.Name());
|
| StringToLowerASCII(&id);
|
|
|
| - scoped_ptr<Version> version;
|
| - version.reset(Version::GetVersionFromString(
|
| - WideToASCII(extension_version)));
|
| - if (!version.get()) {
|
| - LOG(ERROR) << "Invalid version value " << extension_version
|
| - << " for key " << key_path;
|
| - ++iterator;
|
| - continue;
|
| - }
|
| -
|
| - FilePath path = FilePath::FromWStringHack(extension_path);
|
| - visitor->OnExternalExtensionFileFound(id, version.get(), path,
|
| - Extension::EXTERNAL_REGISTRY);
|
| + prefs->SetString(
|
| + id + "." + ExternalExtensionProviderImpl::kExternalVersion,
|
| + WideToASCII(extension_version));
|
| + prefs->SetString(
|
| + id + "." + ExternalExtensionProviderImpl::kExternalCrx,
|
| + extension_path);
|
| } else {
|
| // TODO(erikkay): find a way to get this into about:extensions
|
| LOG(ERROR) << "Missing value " << kRegistryExtensionVersion
|
| @@ -83,33 +76,11 @@ void ExternalRegistryExtensionProvider::VisitRegisteredExtension(
|
| }
|
| ++iterator;
|
| }
|
| -}
|
| -
|
| -
|
| -bool ExternalRegistryExtensionProvider::HasExtension(
|
| - const std::string& id) const {
|
| - base::win::RegKey key;
|
| - return OpenKeyById(id, &key);
|
| -}
|
| -
|
| -bool ExternalRegistryExtensionProvider::GetExtensionDetails(
|
| - const std::string& id,
|
| - Extension::Location* location,
|
| - scoped_ptr<Version>* version) const {
|
| - base::win::RegKey key;
|
| - if (!OpenKeyById(id, &key))
|
| - return false;
|
| -
|
| - std::wstring extension_version;
|
| - if (!key.ReadValue(kRegistryExtensionVersion, &extension_version))
|
| - return false;
|
| -
|
| - if (version) {
|
| - version->reset(Version::GetVersionFromString(
|
| - WideToASCII(extension_version)));
|
| - }
|
|
|
| - if (location)
|
| - *location = Extension::EXTERNAL_REGISTRY;
|
| - return true;
|
| + prefs_.reset(prefs.release());
|
| + BrowserThread::PostTask(
|
| + BrowserThread::UI, FROM_HERE,
|
| + NewRunnableMethod(
|
| + this,
|
| + &ExternalRegistryExtensionLoader::LoadFinished));
|
| }
|
|
|