| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 if (!path.IsAbsolute()) { | 278 if (!path.IsAbsolute()) { |
| 279 base::FilePath base_path = loader_->GetBaseCrxFilePath(); | 279 base::FilePath base_path = loader_->GetBaseCrxFilePath(); |
| 280 if (base_path.empty()) { | 280 if (base_path.empty()) { |
| 281 LOG(WARNING) << "File path " << external_crx.c_str() | 281 LOG(WARNING) << "File path " << external_crx.c_str() |
| 282 << " is relative. An absolute path is required."; | 282 << " is relative. An absolute path is required."; |
| 283 continue; | 283 continue; |
| 284 } | 284 } |
| 285 path = base_path.Append(external_crx); | 285 path = base_path.Append(external_crx); |
| 286 } | 286 } |
| 287 | 287 |
| 288 base::Version version(external_version); | 288 Version version(external_version); |
| 289 if (!version.IsValid()) { | 289 if (!version.IsValid()) { |
| 290 LOG(WARNING) << "Malformed extension dictionary for extension: " | 290 LOG(WARNING) << "Malformed extension dictionary for extension: " |
| 291 << extension_id.c_str() << ". Invalid version string \"" | 291 << extension_id.c_str() << ". Invalid version string \"" |
| 292 << external_version << "\"."; | 292 << external_version << "\"."; |
| 293 continue; | 293 continue; |
| 294 } | 294 } |
| 295 service_->OnExternalExtensionFileFound(extension_id, &version, path, | 295 service_->OnExternalExtensionFileFound(extension_id, &version, path, |
| 296 crx_location_, creation_flags, | 296 crx_location_, creation_flags, |
| 297 auto_acknowledge_, | 297 auto_acknowledge_, |
| 298 install_immediately_); | 298 install_immediately_); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 bool ExternalProviderImpl::HasExtension( | 341 bool ExternalProviderImpl::HasExtension( |
| 342 const std::string& id) const { | 342 const std::string& id) const { |
| 343 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 343 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 344 CHECK(prefs_.get()); | 344 CHECK(prefs_.get()); |
| 345 CHECK(ready_); | 345 CHECK(ready_); |
| 346 return prefs_->HasKey(id); | 346 return prefs_->HasKey(id); |
| 347 } | 347 } |
| 348 | 348 |
| 349 bool ExternalProviderImpl::GetExtensionDetails( | 349 bool ExternalProviderImpl::GetExtensionDetails( |
| 350 const std::string& id, | 350 const std::string& id, Manifest::Location* location, |
| 351 Manifest::Location* location, | 351 scoped_ptr<Version>* version) const { |
| 352 scoped_ptr<base::Version>* version) const { | |
| 353 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 352 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 354 CHECK(prefs_.get()); | 353 CHECK(prefs_.get()); |
| 355 CHECK(ready_); | 354 CHECK(ready_); |
| 356 base::DictionaryValue* extension = NULL; | 355 base::DictionaryValue* extension = NULL; |
| 357 if (!prefs_->GetDictionary(id, &extension)) | 356 if (!prefs_->GetDictionary(id, &extension)) |
| 358 return false; | 357 return false; |
| 359 | 358 |
| 360 Manifest::Location loc = Manifest::INVALID_LOCATION; | 359 Manifest::Location loc = Manifest::INVALID_LOCATION; |
| 361 if (extension->HasKey(kExternalUpdateUrl)) { | 360 if (extension->HasKey(kExternalUpdateUrl)) { |
| 362 loc = download_location_; | 361 loc = download_location_; |
| 363 | 362 |
| 364 } else if (extension->HasKey(kExternalCrx)) { | 363 } else if (extension->HasKey(kExternalCrx)) { |
| 365 loc = crx_location_; | 364 loc = crx_location_; |
| 366 | 365 |
| 367 std::string external_version; | 366 std::string external_version; |
| 368 if (!extension->GetString(kExternalVersion, &external_version)) | 367 if (!extension->GetString(kExternalVersion, &external_version)) |
| 369 return false; | 368 return false; |
| 370 | 369 |
| 371 if (version) | 370 if (version) |
| 372 version->reset(new base::Version(external_version)); | 371 version->reset(new Version(external_version)); |
| 373 | 372 |
| 374 } else { | 373 } else { |
| 375 NOTREACHED(); // Chrome should not allow prefs to get into this state. | 374 NOTREACHED(); // Chrome should not allow prefs to get into this state. |
| 376 return false; | 375 return false; |
| 377 } | 376 } |
| 378 | 377 |
| 379 if (location) | 378 if (location) |
| 380 *location = loc; | 379 *location = loc; |
| 381 | 380 |
| 382 return true; | 381 return true; |
| 383 } | 382 } |
| 384 | 383 |
| 385 bool ExternalProviderImpl::HandleMinProfileVersion( | 384 bool ExternalProviderImpl::HandleMinProfileVersion( |
| 386 const base::DictionaryValue* extension, | 385 const base::DictionaryValue* extension, |
| 387 const std::string& extension_id, | 386 const std::string& extension_id, |
| 388 std::set<std::string>* unsupported_extensions) { | 387 std::set<std::string>* unsupported_extensions) { |
| 389 std::string min_profile_created_by_version; | 388 std::string min_profile_created_by_version; |
| 390 if (profile_ && | 389 if (profile_ && |
| 391 extension->GetString(kMinProfileCreatedByVersion, | 390 extension->GetString(kMinProfileCreatedByVersion, |
| 392 &min_profile_created_by_version)) { | 391 &min_profile_created_by_version)) { |
| 393 base::Version profile_version( | 392 Version profile_version( |
| 394 profile_->GetPrefs()->GetString(prefs::kProfileCreatedByVersion)); | 393 profile_->GetPrefs()->GetString(prefs::kProfileCreatedByVersion)); |
| 395 base::Version min_version(min_profile_created_by_version); | 394 Version min_version(min_profile_created_by_version); |
| 396 if (min_version.IsValid() && profile_version.CompareTo(min_version) < 0) { | 395 if (min_version.IsValid() && profile_version.CompareTo(min_version) < 0) { |
| 397 unsupported_extensions->insert(extension_id); | 396 unsupported_extensions->insert(extension_id); |
| 398 VLOG(1) << "Skip installing (or uninstall) external extension: " | 397 VLOG(1) << "Skip installing (or uninstall) external extension: " |
| 399 << extension_id | 398 << extension_id |
| 400 << " profile.created_by_version: " << profile_version.GetString() | 399 << " profile.created_by_version: " << profile_version.GetString() |
| 401 << " min_profile_created_by_version: " | 400 << " min_profile_created_by_version: " |
| 402 << min_profile_created_by_version; | 401 << min_profile_created_by_version; |
| 403 return false; | 402 return false; |
| 404 } | 403 } |
| 405 } | 404 } |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 new ExternalProviderImpl( | 664 new ExternalProviderImpl( |
| 666 service, | 665 service, |
| 667 new ExternalComponentLoader(profile), | 666 new ExternalComponentLoader(profile), |
| 668 profile, | 667 profile, |
| 669 Manifest::INVALID_LOCATION, | 668 Manifest::INVALID_LOCATION, |
| 670 Manifest::EXTERNAL_COMPONENT, | 669 Manifest::EXTERNAL_COMPONENT, |
| 671 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); | 670 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); |
| 672 } | 671 } |
| 673 | 672 |
| 674 } // namespace extensions | 673 } // namespace extensions |
| OLD | NEW |