| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/external_registry_extension_loader_win.h" | 5 #include "chrome/browser/extensions/external_registry_extension_loader_win.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 key_path.append(L"\\"); | 50 key_path.append(L"\\"); |
| 51 key_path.append(iterator.Name()); | 51 key_path.append(iterator.Name()); |
| 52 if (key.Open(kRegRoot, key_path.c_str(), KEY_READ)) { | 52 if (key.Open(kRegRoot, key_path.c_str(), KEY_READ)) { |
| 53 std::wstring extension_path; | 53 std::wstring extension_path; |
| 54 if (key.ReadValue(kRegistryExtensionPath, &extension_path)) { | 54 if (key.ReadValue(kRegistryExtensionPath, &extension_path)) { |
| 55 std::wstring extension_version; | 55 std::wstring extension_version; |
| 56 if (key.ReadValue(kRegistryExtensionVersion, &extension_version)) { | 56 if (key.ReadValue(kRegistryExtensionVersion, &extension_version)) { |
| 57 std::string id = WideToASCII(iterator.Name()); | 57 std::string id = WideToASCII(iterator.Name()); |
| 58 StringToLowerASCII(&id); | 58 StringToLowerASCII(&id); |
| 59 | 59 |
| 60 if (!Extension::IdIsValid(id)) { |
| 61 LOG(ERROR) << "Invalid id value " << id |
| 62 << " for key " << key_path << " ."; |
| 63 ++iterator; |
| 64 continue; |
| 65 } |
| 66 |
| 67 scoped_ptr<Version> version; |
| 68 version.reset(Version::GetVersionFromString( |
| 69 WideToASCII(extension_version))); |
| 70 if (!version.get()) { |
| 71 LOG(ERROR) << "Invalid version value " << extension_version |
| 72 << " for key " << key_path << " ."; |
| 73 ++iterator; |
| 74 continue; |
| 75 } |
| 76 |
| 60 prefs->SetString( | 77 prefs->SetString( |
| 61 id + "." + ExternalExtensionProviderImpl::kExternalVersion, | 78 id + "." + ExternalExtensionProviderImpl::kExternalVersion, |
| 62 WideToASCII(extension_version)); | 79 WideToASCII(extension_version)); |
| 63 prefs->SetString( | 80 prefs->SetString( |
| 64 id + "." + ExternalExtensionProviderImpl::kExternalCrx, | 81 id + "." + ExternalExtensionProviderImpl::kExternalCrx, |
| 65 extension_path); | 82 extension_path); |
| 66 } else { | 83 } else { |
| 67 // TODO(erikkay): find a way to get this into about:extensions | 84 // TODO(erikkay): find a way to get this into about:extensions |
| 68 LOG(ERROR) << "Missing value " << kRegistryExtensionVersion | 85 LOG(ERROR) << "Missing value " << kRegistryExtensionVersion |
| 69 << " for key " << key_path; | 86 << " for key " << key_path << " ."; |
| 70 } | 87 } |
| 71 } else { | 88 } else { |
| 72 // TODO(erikkay): find a way to get this into about:extensions | 89 // TODO(erikkay): find a way to get this into about:extensions |
| 73 LOG(ERROR) << "Missing value " << kRegistryExtensionPath | 90 LOG(ERROR) << "Missing value " << kRegistryExtensionPath |
| 74 << " for key " << key_path; | 91 << " for key " << key_path << " ."; |
| 75 } | 92 } |
| 76 } | 93 } |
| 77 ++iterator; | 94 ++iterator; |
| 78 } | 95 } |
| 79 | 96 |
| 80 prefs_.reset(prefs.release()); | 97 prefs_.reset(prefs.release()); |
| 81 BrowserThread::PostTask( | 98 BrowserThread::PostTask( |
| 82 BrowserThread::UI, FROM_HERE, | 99 BrowserThread::UI, FROM_HERE, |
| 83 NewRunnableMethod( | 100 NewRunnableMethod( |
| 84 this, | 101 this, |
| 85 &ExternalRegistryExtensionLoader::LoadFinished)); | 102 &ExternalRegistryExtensionLoader::LoadFinished)); |
| 86 } | 103 } |
| OLD | NEW |