| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 scoped_ptr<DictionaryValue> prefs(new DictionaryValue); | 43 scoped_ptr<DictionaryValue> prefs(new DictionaryValue); |
| 44 | 44 |
| 45 base::win::RegistryKeyIterator iterator( | 45 base::win::RegistryKeyIterator iterator( |
| 46 kRegRoot, ASCIIToWide(kRegistryExtensions).c_str()); | 46 kRegRoot, ASCIIToWide(kRegistryExtensions).c_str()); |
| 47 while (iterator.Valid()) { | 47 while (iterator.Valid()) { |
| 48 base::win::RegKey key; | 48 base::win::RegKey key; |
| 49 std::wstring key_path = ASCIIToWide(kRegistryExtensions); | 49 std::wstring key_path = ASCIIToWide(kRegistryExtensions); |
| 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_str; |
| 54 if (key.ReadValue(kRegistryExtensionPath, &extension_path)) { | 54 if (key.ReadValue(kRegistryExtensionPath, &extension_path_str)) { |
| 55 FilePath extension_path(extension_path_str); |
| 56 if (!extension_path.IsAbsolute()) { |
| 57 LOG(ERROR) << "Path " << extension_path_str |
| 58 << " needs to be absolute in key " |
| 59 << key_path; |
| 60 ++iterator; |
| 61 continue; |
| 62 } |
| 63 |
| 55 std::wstring extension_version; | 64 std::wstring extension_version; |
| 56 if (key.ReadValue(kRegistryExtensionVersion, &extension_version)) { | 65 if (key.ReadValue(kRegistryExtensionVersion, &extension_version)) { |
| 57 std::string id = WideToASCII(iterator.Name()); | 66 std::string id = WideToASCII(iterator.Name()); |
| 58 StringToLowerASCII(&id); | 67 StringToLowerASCII(&id); |
| 59 | 68 |
| 60 if (!Extension::IdIsValid(id)) { | 69 if (!Extension::IdIsValid(id)) { |
| 61 LOG(ERROR) << "Invalid id value " << id | 70 LOG(ERROR) << "Invalid id value " << id |
| 62 << " for key " << key_path << " ."; | 71 << " for key " << key_path << " ."; |
| 63 ++iterator; | 72 ++iterator; |
| 64 continue; | 73 continue; |
| 65 } | 74 } |
| 66 | 75 |
| 67 scoped_ptr<Version> version; | 76 scoped_ptr<Version> version; |
| 68 version.reset(Version::GetVersionFromString( | 77 version.reset(Version::GetVersionFromString( |
| 69 WideToASCII(extension_version))); | 78 WideToASCII(extension_version))); |
| 70 if (!version.get()) { | 79 if (!version.get()) { |
| 71 LOG(ERROR) << "Invalid version value " << extension_version | 80 LOG(ERROR) << "Invalid version value " << extension_version |
| 72 << " for key " << key_path << " ."; | 81 << " for key " << key_path << " ."; |
| 73 ++iterator; | 82 ++iterator; |
| 74 continue; | 83 continue; |
| 75 } | 84 } |
| 76 | 85 |
| 77 prefs->SetString( | 86 prefs->SetString( |
| 78 id + "." + ExternalExtensionProviderImpl::kExternalVersion, | 87 id + "." + ExternalExtensionProviderImpl::kExternalVersion, |
| 79 WideToASCII(extension_version)); | 88 WideToASCII(extension_version)); |
| 80 prefs->SetString( | 89 prefs->SetString( |
| 81 id + "." + ExternalExtensionProviderImpl::kExternalCrx, | 90 id + "." + ExternalExtensionProviderImpl::kExternalCrx, |
| 82 extension_path); | 91 extension_path_str); |
| 83 } else { | 92 } else { |
| 84 // TODO(erikkay): find a way to get this into about:extensions | 93 // TODO(erikkay): find a way to get this into about:extensions |
| 85 LOG(ERROR) << "Missing value " << kRegistryExtensionVersion | 94 LOG(ERROR) << "Missing value " << kRegistryExtensionVersion |
| 86 << " for key " << key_path << " ."; | 95 << " for key " << key_path << " ."; |
| 87 } | 96 } |
| 88 } else { | 97 } else { |
| 89 // TODO(erikkay): find a way to get this into about:extensions | 98 // TODO(erikkay): find a way to get this into about:extensions |
| 90 LOG(ERROR) << "Missing value " << kRegistryExtensionPath | 99 LOG(ERROR) << "Missing value " << kRegistryExtensionPath |
| 91 << " for key " << key_path << " ."; | 100 << " for key " << key_path << " ."; |
| 92 } | 101 } |
| 93 } | 102 } |
| 94 ++iterator; | 103 ++iterator; |
| 95 } | 104 } |
| 96 | 105 |
| 97 prefs_.reset(prefs.release()); | 106 prefs_.reset(prefs.release()); |
| 98 BrowserThread::PostTask( | 107 BrowserThread::PostTask( |
| 99 BrowserThread::UI, FROM_HERE, | 108 BrowserThread::UI, FROM_HERE, |
| 100 NewRunnableMethod( | 109 NewRunnableMethod( |
| 101 this, | 110 this, |
| 102 &ExternalRegistryExtensionLoader::LoadFinished)); | 111 &ExternalRegistryExtensionLoader::LoadFinished)); |
| 103 } | 112 } |
| OLD | NEW |