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_provider_impl.h" | 5 #include "chrome/browser/extensions/external_provider_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 | 48 |
49 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
50 #include "chrome/browser/extensions/external_registry_loader_win.h" | 50 #include "chrome/browser/extensions/external_registry_loader_win.h" |
51 #endif | 51 #endif |
52 | 52 |
53 using content::BrowserThread; | 53 using content::BrowserThread; |
54 | 54 |
55 namespace extensions { | 55 namespace extensions { |
56 | 56 |
57 // Constants for keeping track of extension preferences in a dictionary. | 57 // Constants for keeping track of extension preferences in a dictionary. |
| 58 const char ExternalProviderImpl::kInstallParam[] = "install_parameter"; |
58 const char ExternalProviderImpl::kExternalCrx[] = "external_crx"; | 59 const char ExternalProviderImpl::kExternalCrx[] = "external_crx"; |
59 const char ExternalProviderImpl::kExternalVersion[] = "external_version"; | 60 const char ExternalProviderImpl::kExternalVersion[] = "external_version"; |
60 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url"; | 61 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url"; |
61 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales"; | 62 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales"; |
62 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app"; | 63 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app"; |
63 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore"; | 64 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore"; |
64 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present"; | 65 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present"; |
65 | 66 |
66 ExternalProviderImpl::ExternalProviderImpl( | 67 ExternalProviderImpl::ExternalProviderImpl( |
67 VisitorInterface* service, | 68 VisitorInterface* service, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const Extension* extension = extension_service ? | 214 const Extension* extension = extension_service ? |
214 extension_service->GetExtensionById(extension_id, true) : NULL; | 215 extension_service->GetExtensionById(extension_id, true) : NULL; |
215 if (!extension) { | 216 if (!extension) { |
216 VLOG(1) << "Skip installing (or uninstall) external extension: " | 217 VLOG(1) << "Skip installing (or uninstall) external extension: " |
217 << extension_id << " because the extension should be kept " | 218 << extension_id << " because the extension should be kept " |
218 << "only if it is already installed."; | 219 << "only if it is already installed."; |
219 continue; | 220 continue; |
220 } | 221 } |
221 } | 222 } |
222 | 223 |
| 224 std::string install_parameter; |
| 225 extension->GetString(kInstallParam, &install_parameter); |
| 226 |
223 if (has_external_crx) { | 227 if (has_external_crx) { |
224 if (crx_location_ == Manifest::INVALID_LOCATION) { | 228 if (crx_location_ == Manifest::INVALID_LOCATION) { |
225 LOG(WARNING) << "This provider does not support installing external " | 229 LOG(WARNING) << "This provider does not support installing external " |
226 << "extensions from crx files."; | 230 << "extensions from crx files."; |
227 continue; | 231 continue; |
228 } | 232 } |
229 if (external_crx.find(base::FilePath::kParentDirectory) != | 233 if (external_crx.find(base::FilePath::kParentDirectory) != |
230 base::StringPiece::npos) { | 234 base::StringPiece::npos) { |
231 LOG(WARNING) << "Path traversal not allowed in path: " | 235 LOG(WARNING) << "Path traversal not allowed in path: " |
232 << external_crx.c_str(); | 236 << external_crx.c_str(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 continue; | 268 continue; |
265 } | 269 } |
266 GURL update_url(external_update_url); | 270 GURL update_url(external_update_url); |
267 if (!update_url.is_valid()) { | 271 if (!update_url.is_valid()) { |
268 LOG(WARNING) << "Malformed extension dictionary for extension: " | 272 LOG(WARNING) << "Malformed extension dictionary for extension: " |
269 << extension_id.c_str() << ". Key " << kExternalUpdateUrl | 273 << extension_id.c_str() << ". Key " << kExternalUpdateUrl |
270 << " has value \"" << external_update_url | 274 << " has value \"" << external_update_url |
271 << "\", which is not a valid URL."; | 275 << "\", which is not a valid URL."; |
272 continue; | 276 continue; |
273 } | 277 } |
274 service_->OnExternalExtensionUpdateUrlFound( | 278 service_->OnExternalExtensionUpdateUrlFound(extension_id, |
275 extension_id, update_url, download_location_, creation_flags, | 279 install_parameter, |
276 auto_acknowledge_); | 280 update_url, |
| 281 download_location_, |
| 282 creation_flags, |
| 283 auto_acknowledge_); |
277 } | 284 } |
278 } | 285 } |
279 | 286 |
280 for (std::set<std::string>::iterator it = unsupported_extensions.begin(); | 287 for (std::set<std::string>::iterator it = unsupported_extensions.begin(); |
281 it != unsupported_extensions.end(); ++it) { | 288 it != unsupported_extensions.end(); ++it) { |
282 // Remove extension for the list of know external extensions. The extension | 289 // Remove extension for the list of know external extensions. The extension |
283 // will be uninstalled later because provider doesn't provide it anymore. | 290 // will be uninstalled later because provider doesn't provide it anymore. |
284 prefs_->Remove(*it, NULL); | 291 prefs_->Remove(*it, NULL); |
285 } | 292 } |
286 | 293 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 service, | 544 service, |
538 new ExternalComponentLoader(profile), | 545 new ExternalComponentLoader(profile), |
539 profile, | 546 profile, |
540 Manifest::INVALID_LOCATION, | 547 Manifest::INVALID_LOCATION, |
541 Manifest::EXTERNAL_COMPONENT, | 548 Manifest::EXTERNAL_COMPONENT, |
542 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 549 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
543 } | 550 } |
544 } | 551 } |
545 | 552 |
546 } // namespace extensions | 553 } // namespace extensions |
OLD | NEW |