OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/extensions_service.h" | 5 #include "chrome/browser/extensions/extensions_service.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/scoped_handle.h" | 8 #include "base/scoped_handle.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 if (!val->IsType(Value::TYPE_DICTIONARY)) { | 395 if (!val->IsType(Value::TYPE_DICTIONARY)) { |
396 ReportExtensionInstallError("manifest isn't a JSON dictionary"); | 396 ReportExtensionInstallError("manifest isn't a JSON dictionary"); |
397 return NULL; | 397 return NULL; |
398 } | 398 } |
399 DictionaryValue* manifest = static_cast<DictionaryValue*>(val.get()); | 399 DictionaryValue* manifest = static_cast<DictionaryValue*>(val.get()); |
400 | 400 |
401 // Check the version before proceeding. Although we verify the version | 401 // Check the version before proceeding. Although we verify the version |
402 // again later, checking it here allows us to skip some potentially expensive | 402 // again later, checking it here allows us to skip some potentially expensive |
403 // work. | 403 // work. |
404 std::string id; | 404 std::string id; |
405 if (!manifest->GetString(Extension::kIdKey, &id)) { | 405 if (!manifest->GetString(WideToUTF16Hack(Extension::kIdKey), &id)) { |
406 ReportExtensionInstallError("missing id key"); | 406 ReportExtensionInstallError("missing id key"); |
407 return NULL; | 407 return NULL; |
408 } | 408 } |
409 FilePath dest_dir = install_directory_.AppendASCII(id.c_str()); | 409 FilePath dest_dir = install_directory_.AppendASCII(id.c_str()); |
410 if (file_util::PathExists(dest_dir)) { | 410 if (file_util::PathExists(dest_dir)) { |
411 std::string version; | 411 std::string version; |
412 if (!manifest->GetString(Extension::kVersionKey, &version)) { | 412 if (!manifest->GetString(WideToUTF16Hack(Extension::kVersionKey), |
| 413 &version)) { |
413 ReportExtensionInstallError("missing version key"); | 414 ReportExtensionInstallError("missing version key"); |
414 return NULL; | 415 return NULL; |
415 } | 416 } |
416 std::string current_version; | 417 std::string current_version; |
417 if (ReadCurrentVersion(dest_dir, ¤t_version)) { | 418 if (ReadCurrentVersion(dest_dir, ¤t_version)) { |
418 if (!CheckCurrentVersion(version, current_version, dest_dir)) | 419 if (!CheckCurrentVersion(version, current_version, dest_dir)) |
419 return NULL; | 420 return NULL; |
420 } | 421 } |
421 } | 422 } |
422 | 423 |
423 std::string zip_hash; | 424 std::string zip_hash; |
424 if (!manifest->GetString(Extension::kZipHashKey, &zip_hash)) { | 425 if (!manifest->GetString(WideToUTF16Hack(Extension::kZipHashKey), |
| 426 &zip_hash)) { |
425 ReportExtensionInstallError("missing zip_hash key"); | 427 ReportExtensionInstallError("missing zip_hash key"); |
426 return NULL; | 428 return NULL; |
427 } | 429 } |
428 if (zip_hash.size() != kZipHashHexBytes) { | 430 if (zip_hash.size() != kZipHashHexBytes) { |
429 ReportExtensionInstallError("invalid zip_hash key"); | 431 ReportExtensionInstallError("invalid zip_hash key"); |
430 return NULL; | 432 return NULL; |
431 } | 433 } |
432 | 434 |
433 // Read the rest of the zip file and compute a hash to compare against | 435 // Read the rest of the zip file and compute a hash to compare against |
434 // what the manifest claims. Compute the hash incrementally since the | 436 // what the manifest claims. Compute the hash incrementally since the |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 | 806 |
805 bool ExtensionsServiceBackend::ShouldInstall(const std::string& id, | 807 bool ExtensionsServiceBackend::ShouldInstall(const std::string& id, |
806 const std::string& version) { | 808 const std::string& version) { |
807 FilePath dir(install_directory_.AppendASCII(id.c_str())); | 809 FilePath dir(install_directory_.AppendASCII(id.c_str())); |
808 std::string current_version; | 810 std::string current_version; |
809 if (ReadCurrentVersion(dir, ¤t_version)) { | 811 if (ReadCurrentVersion(dir, ¤t_version)) { |
810 return !CheckCurrentVersion(version, current_version, dir); | 812 return !CheckCurrentVersion(version, current_version, dir); |
811 } | 813 } |
812 return true; | 814 return true; |
813 } | 815 } |
OLD | NEW |