| 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/common/extensions/extension_file_util.h" | 5 #include "chrome/common/extensions/extension_file_util.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/json/json_file_value_serializer.h" | 13 #include "base/json/json_file_value_serializer.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
| 18 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
| 19 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
| 21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
| 22 #include "chrome/common/extensions/api/extension_action/action_info.h" | 22 #include "chrome/common/extensions/api/extension_action/action_info.h" |
| 23 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h
" | 23 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h
" |
| 24 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
| 24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_l10n_util.h" | 26 #include "chrome/common/extensions/extension_l10n_util.h" |
| 26 #include "chrome/common/extensions/extension_manifest_constants.h" | 27 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 27 #include "chrome/common/extensions/extension_messages.h" | 28 #include "chrome/common/extensions/extension_messages.h" |
| 28 #include "chrome/common/extensions/extension_resource.h" | 29 #include "chrome/common/extensions/extension_resource.h" |
| 29 #include "chrome/common/extensions/manifest_url_handler.h" | 30 #include "chrome/common/extensions/manifest_url_handler.h" |
| 30 #include "chrome/common/extensions/message_bundle.h" | 31 #include "chrome/common/extensions/message_bundle.h" |
| 31 #include "grit/generated_resources.h" | 32 #include "grit/generated_resources.h" |
| 32 #include "net/base/escape.h" | 33 #include "net/base/escape.h" |
| 33 #include "net/base/file_stream.h" | 34 #include "net/base/file_stream.h" |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 | 557 |
| 557 return returnValue; | 558 return returnValue; |
| 558 } | 559 } |
| 559 | 560 |
| 560 static bool ValidateLocaleInfo(const Extension& extension, | 561 static bool ValidateLocaleInfo(const Extension& extension, |
| 561 std::string* error) { | 562 std::string* error) { |
| 562 // default_locale and _locales have to be both present or both missing. | 563 // default_locale and _locales have to be both present or both missing. |
| 563 const FilePath path = extension.path().Append( | 564 const FilePath path = extension.path().Append( |
| 564 Extension::kLocaleFolder); | 565 Extension::kLocaleFolder); |
| 565 bool path_exists = file_util::PathExists(path); | 566 bool path_exists = file_util::PathExists(path); |
| 566 std::string default_locale = extension.default_locale(); | 567 std::string default_locale = |
| 568 extensions::LocaleInfo::GetDefaultLocale(&extension); |
| 567 | 569 |
| 568 // If both default locale and _locales folder are empty, skip verification. | 570 // If both default locale and _locales folder are empty, skip verification. |
| 569 if (default_locale.empty() && !path_exists) | 571 if (default_locale.empty() && !path_exists) |
| 570 return true; | 572 return true; |
| 571 | 573 |
| 572 if (default_locale.empty() && path_exists) { | 574 if (default_locale.empty() && path_exists) { |
| 573 *error = l10n_util::GetStringUTF8( | 575 *error = l10n_util::GetStringUTF8( |
| 574 IDS_EXTENSION_LOCALES_NO_DEFAULT_LOCALE_SPECIFIED); | 576 IDS_EXTENSION_LOCALES_NO_DEFAULT_LOCALE_SPECIFIED); |
| 575 return false; | 577 return false; |
| 576 } else if (!default_locale.empty() && !path_exists) { | 578 } else if (!default_locale.empty() && !path_exists) { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 return FilePath(); | 759 return FilePath(); |
| 758 } | 760 } |
| 759 return temp_path; | 761 return temp_path; |
| 760 } | 762 } |
| 761 | 763 |
| 762 void DeleteFile(const FilePath& path, bool recursive) { | 764 void DeleteFile(const FilePath& path, bool recursive) { |
| 763 file_util::Delete(path, recursive); | 765 file_util::Delete(path, recursive); |
| 764 } | 766 } |
| 765 | 767 |
| 766 } // namespace extension_file_util | 768 } // namespace extension_file_util |
| OLD | NEW |