| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/common/extensions/extension.h" | 5 #include "chrome/common/extensions/extension.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 path_ = FilePath(path_str); | 452 path_ = FilePath(path_str); |
| 453 #else | 453 #else |
| 454 path_ = path; | 454 path_ = path; |
| 455 #endif | 455 #endif |
| 456 } | 456 } |
| 457 | 457 |
| 458 // TODO(rafaelw): Move ParsePEMKeyBytes, ProducePEM & FormatPEMForOutput to a | 458 // TODO(rafaelw): Move ParsePEMKeyBytes, ProducePEM & FormatPEMForOutput to a |
| 459 // util class in base: | 459 // util class in base: |
| 460 // http://code.google.com/p/chromium/issues/detail?id=13572 | 460 // http://code.google.com/p/chromium/issues/detail?id=13572 |
| 461 bool Extension::ParsePEMKeyBytes(const std::string& input, | 461 bool Extension::ParsePEMKeyBytes(const std::string& input, |
| 462 std::string* output) { | 462 std::string* output) { |
| 463 DCHECK(output); | 463 DCHECK(output); |
| 464 if (!output) | 464 if (!output) |
| 465 return false; | 465 return false; |
| 466 if (input.length() == 0) | 466 if (input.length() == 0) |
| 467 return false; | 467 return false; |
| 468 | 468 |
| 469 std::string working = input; | 469 std::string working = input; |
| 470 if (StartsWithASCII(working, kKeyBeginHeaderMarker, true)) { | 470 if (StartsWithASCII(working, kKeyBeginHeaderMarker, true)) { |
| 471 working = CollapseWhitespaceASCII(working, true); | 471 working = CollapseWhitespaceASCII(working, true); |
| 472 size_t header_pos = working.find(kKeyInfoEndMarker, | 472 size_t header_pos = working.find(kKeyInfoEndMarker, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 491 bool Extension::ProducePEM(const std::string& input, | 491 bool Extension::ProducePEM(const std::string& input, |
| 492 std::string* output) { | 492 std::string* output) { |
| 493 CHECK(output); | 493 CHECK(output); |
| 494 if (input.length() == 0) | 494 if (input.length() == 0) |
| 495 return false; | 495 return false; |
| 496 | 496 |
| 497 return net::Base64Encode(input, output); | 497 return net::Base64Encode(input, output); |
| 498 } | 498 } |
| 499 | 499 |
| 500 bool Extension::FormatPEMForFileOutput(const std::string input, | 500 bool Extension::FormatPEMForFileOutput(const std::string input, |
| 501 std::string* output, | 501 std::string* output, |
| 502 bool is_public) { | 502 bool is_public) { |
| 503 CHECK(output); | 503 CHECK(output); |
| 504 if (input.length() == 0) | 504 if (input.length() == 0) |
| 505 return false; | 505 return false; |
| 506 *output = ""; | 506 *output = ""; |
| 507 output->append(kKeyBeginHeaderMarker); | 507 output->append(kKeyBeginHeaderMarker); |
| 508 output->append(" "); | 508 output->append(" "); |
| 509 output->append(is_public ? kPublic : kPrivate); | 509 output->append(is_public ? kPublic : kPrivate); |
| 510 output->append(" "); | 510 output->append(" "); |
| 511 output->append(kKeyInfoEndMarker); | 511 output->append(kKeyInfoEndMarker); |
| 512 output->append("\n"); | 512 output->append("\n"); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 543 // Generate a random ID | 543 // Generate a random ID |
| 544 id_ = StringPrintf("%x", NextGeneratedId()); | 544 id_ = StringPrintf("%x", NextGeneratedId()); |
| 545 | 545 |
| 546 // pad the string out to kIdSize*2 chars with zeroes. | 546 // pad the string out to kIdSize*2 chars with zeroes. |
| 547 id_.insert(0, Extension::kIdSize*2 - id_.length(), '0'); | 547 id_.insert(0, Extension::kIdSize*2 - id_.length(), '0'); |
| 548 | 548 |
| 549 // Convert to our mp-decimal. | 549 // Convert to our mp-decimal. |
| 550 ConvertHexadecimalToIDAlphabet(&id_); | 550 ConvertHexadecimalToIDAlphabet(&id_); |
| 551 } | 551 } |
| 552 | 552 |
| 553 // Make a copy of the manifest so we can store it in prefs. |
| 554 manifest_value_.reset(static_cast<DictionaryValue*>(source.DeepCopy())); |
| 555 |
| 553 // Initialize the URL. | 556 // Initialize the URL. |
| 554 extension_url_ = GURL(std::string(chrome::kExtensionScheme) + | 557 extension_url_ = GURL(std::string(chrome::kExtensionScheme) + |
| 555 chrome::kStandardSchemeSeparator + id_ + "/"); | 558 chrome::kStandardSchemeSeparator + id_ + "/"); |
| 556 | 559 |
| 557 // Initialize version. | 560 // Initialize version. |
| 558 std::string version_str; | 561 std::string version_str; |
| 559 if (!source.GetString(keys::kVersion, &version_str)) { | 562 if (!source.GetString(keys::kVersion, &version_str)) { |
| 560 *error = errors::kInvalidVersion; | 563 *error = errors::kInvalidVersion; |
| 561 return false; | 564 return false; |
| 562 } | 565 } |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 NotificationService::NoDetails()); | 1021 NotificationService::NoDetails()); |
| 1019 } | 1022 } |
| 1020 | 1023 |
| 1021 FilePath Extension::GetIconPath(Icons icon) { | 1024 FilePath Extension::GetIconPath(Icons icon) { |
| 1022 std::map<int, std::string>::const_iterator iter = | 1025 std::map<int, std::string>::const_iterator iter = |
| 1023 icons_.find(Extension::EXTENSION_ICON_LARGE); | 1026 icons_.find(Extension::EXTENSION_ICON_LARGE); |
| 1024 if (iter == icons_.end()) | 1027 if (iter == icons_.end()) |
| 1025 return FilePath(); | 1028 return FilePath(); |
| 1026 return GetResourcePath(iter->second); | 1029 return GetResourcePath(iter->second); |
| 1027 } | 1030 } |
| OLD | NEW |