OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_loader_win.h" | 5 #include "chrome/browser/extensions/external_registry_loader_win.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_handle.h" | 10 #include "base/memory/scoped_handle.h" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "base/version.h" | 16 #include "base/version.h" |
17 #include "base/win/registry.h" | 17 #include "base/win/registry.h" |
18 #include "chrome/browser/extensions/external_provider_impl.h" | 18 #include "chrome/browser/extensions/external_provider_impl.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
21 | 21 |
22 using content::BrowserThread; | 22 using content::BrowserThread; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 // The Registry subkey that contains information about external extensions. | 26 // The Registry subkey that contains information about external extensions. |
27 const char kRegistryExtensions[] = "Software\\Google\\Chrome\\Extensions"; | 27 const char kRegistryExtensions[] = "Software\\Google\\Chrome\\Extensions"; |
28 | 28 |
| 29 // Registry value of the key that defines the installation parameter. |
| 30 const wchar_t kRegistryExtensionInstallParam[] = L"install_parameter"; |
| 31 |
29 // Registry value of the key that defines the path to the .crx file. | 32 // Registry value of the key that defines the path to the .crx file. |
30 const wchar_t kRegistryExtensionPath[] = L"path"; | 33 const wchar_t kRegistryExtensionPath[] = L"path"; |
31 | 34 |
32 // Registry value of that key that defines the current version of the .crx file. | 35 // Registry value of that key that defines the current version of the .crx file. |
33 const wchar_t kRegistryExtensionVersion[] = L"version"; | 36 const wchar_t kRegistryExtensionVersion[] = L"version"; |
34 | 37 |
35 // Registry value of the key that defines an external update URL. | 38 // Registry value of the key that defines an external update URL. |
36 const wchar_t kRegistryExtensionUpdateUrl[] = L"update_url"; | 39 const wchar_t kRegistryExtensionUpdateUrl[] = L"update_url"; |
37 | 40 |
38 bool CanOpenFileForReading(const base::FilePath& path) { | 41 bool CanOpenFileForReading(const base::FilePath& path) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 90 } |
88 | 91 |
89 std::string id = base::UTF16ToASCII(*it); | 92 std::string id = base::UTF16ToASCII(*it); |
90 StringToLowerASCII(&id); | 93 StringToLowerASCII(&id); |
91 if (!Extension::IdIsValid(id)) { | 94 if (!Extension::IdIsValid(id)) { |
92 LOG(ERROR) << "Invalid id value " << id | 95 LOG(ERROR) << "Invalid id value " << id |
93 << " for key " << key_path << "."; | 96 << " for key " << key_path << "."; |
94 continue; | 97 continue; |
95 } | 98 } |
96 | 99 |
| 100 base::string16 extension_dist_id; |
| 101 if (key.ReadValue(kRegistryExtensionInstallParam, &extension_dist_id) == |
| 102 ERROR_SUCCESS) { |
| 103 prefs->SetString(id + "." + ExternalProviderImpl::kInstallParam, |
| 104 base::UTF16ToASCII(extension_dist_id)); |
| 105 } |
| 106 |
97 // If there is an update URL present, copy it to prefs and ignore | 107 // If there is an update URL present, copy it to prefs and ignore |
98 // path and version keys for this entry. | 108 // path and version keys for this entry. |
99 base::string16 extension_update_url; | 109 base::string16 extension_update_url; |
100 if (key.ReadValue(kRegistryExtensionUpdateUrl, &extension_update_url) | 110 if (key.ReadValue(kRegistryExtensionUpdateUrl, &extension_update_url) |
101 == ERROR_SUCCESS) { | 111 == ERROR_SUCCESS) { |
102 prefs->SetString( | 112 prefs->SetString( |
103 id + "." + ExternalProviderImpl::kExternalUpdateUrl, | 113 id + "." + ExternalProviderImpl::kExternalUpdateUrl, |
104 base::UTF16ToASCII(extension_update_url)); | 114 base::UTF16ToASCII(extension_update_url)); |
105 continue; | 115 continue; |
106 } | 116 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 | 173 |
164 prefs_.reset(prefs.release()); | 174 prefs_.reset(prefs.release()); |
165 HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWin", | 175 HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWin", |
166 base::TimeTicks::Now() - start_time); | 176 base::TimeTicks::Now() - start_time); |
167 BrowserThread::PostTask( | 177 BrowserThread::PostTask( |
168 BrowserThread::UI, FROM_HERE, | 178 BrowserThread::UI, FROM_HERE, |
169 base::Bind(&ExternalRegistryLoader::LoadFinished, this)); | 179 base::Bind(&ExternalRegistryLoader::LoadFinished, this)); |
170 } | 180 } |
171 | 181 |
172 } // namespace extensions | 182 } // namespace extensions |
OLD | NEW |