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