Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3468)

Unified Diff: chrome/common/extensions/extension_file_util.cc

Issue 11724002: Move ContentScripts out of Extension (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: Latest master for CQ Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/extensions/extension_file_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_file_util.cc
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc
index 1ed7356daa0bb74bf089bf2cba4af913ce4662de..4c2fbb00783500b17dc3a91adca890e73b2caab6 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -49,12 +49,6 @@ const base::FilePath::CharType kTempDirectoryName[] = FILE_PATH_LITERAL("Temp");
namespace extension_file_util {
-// Returns false and sets the error if script file can't be loaded,
-// or if it's not UTF-8 encoded.
-static bool IsScriptValid(const base::FilePath& path,
- const base::FilePath& relative_path,
- int message_id, std::string* error);
-
base::FilePath InstallExtension(const base::FilePath& unpacked_source_dir,
const std::string& id,
const std::string& version,
@@ -254,41 +248,6 @@ bool ValidateExtension(const Extension* extension,
extension, error, warnings))
return false;
- // TODO(yoz): Move this to content scripts manifest handler.
- // Validate that claimed script resources actually exist,
- // and are UTF-8 encoded.
- ExtensionResource::SymlinkPolicy symlink_policy;
- if ((extension->creation_flags() &
- Extension::FOLLOW_SYMLINKS_ANYWHERE) != 0) {
- symlink_policy = ExtensionResource::FOLLOW_SYMLINKS_ANYWHERE;
- } else {
- symlink_policy = ExtensionResource::SYMLINKS_MUST_RESOLVE_WITHIN_ROOT;
- }
-
- for (size_t i = 0; i < extension->content_scripts().size(); ++i) {
- const extensions::UserScript& script = extension->content_scripts()[i];
-
- for (size_t j = 0; j < script.js_scripts().size(); j++) {
- const extensions::UserScript::File& js_script = script.js_scripts()[j];
- const base::FilePath& path = ExtensionResource::GetFilePath(
- js_script.extension_root(), js_script.relative_path(),
- symlink_policy);
- if (!IsScriptValid(path, js_script.relative_path(),
- IDS_EXTENSION_LOAD_JAVASCRIPT_FAILED, error))
- return false;
- }
-
- for (size_t j = 0; j < script.css_scripts().size(); j++) {
- const extensions::UserScript::File& css_script = script.css_scripts()[j];
- const base::FilePath& path = ExtensionResource::GetFilePath(
- css_script.extension_root(), css_script.relative_path(),
- symlink_policy);
- if (!IsScriptValid(path, css_script.relative_path(),
- IDS_EXTENSION_LOAD_CSS_FAILED, error))
- return false;
- }
- }
-
// Check children of extension root to see if any of them start with _ and is
// not on the reserved list.
if (!CheckForIllegalFilenames(extension->path(), error)) {
@@ -452,29 +411,6 @@ SubstitutionMap* LoadMessageBundleSubstitutionMap(
return returnValue;
}
-static bool IsScriptValid(const base::FilePath& path,
- const base::FilePath& relative_path,
- int message_id,
- std::string* error) {
- std::string content;
- if (!file_util::PathExists(path) ||
- !file_util::ReadFileToString(path, &content)) {
- *error = l10n_util::GetStringFUTF8(
- message_id,
- relative_path.LossyDisplayName());
- return false;
- }
-
- if (!IsStringUTF8(content)) {
- *error = l10n_util::GetStringFUTF8(
- IDS_EXTENSION_BAD_FILE_ENCODING,
- relative_path.LossyDisplayName());
- return false;
- }
-
- return true;
-}
-
bool CheckForIllegalFilenames(const base::FilePath& extension_path,
std::string* error) {
// Reserved underscore names.
« no previous file with comments | « chrome/common/extensions/extension.cc ('k') | chrome/common/extensions/extension_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698