| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/manifest_handlers/content_scripts_handler.h" | 5 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 static const char* keys[] = { | 377 static const char* keys[] = { |
| 378 keys::kContentScripts | 378 keys::kContentScripts |
| 379 }; | 379 }; |
| 380 return std::vector<std::string>(keys, keys + arraysize(keys)); | 380 return std::vector<std::string>(keys, keys + arraysize(keys)); |
| 381 } | 381 } |
| 382 | 382 |
| 383 bool ContentScriptsHandler::Parse(Extension* extension, base::string16* error) { | 383 bool ContentScriptsHandler::Parse(Extension* extension, base::string16* error) { |
| 384 scoped_ptr<ContentScriptsInfo> content_scripts_info(new ContentScriptsInfo); | 384 scoped_ptr<ContentScriptsInfo> content_scripts_info(new ContentScriptsInfo); |
| 385 const base::ListValue* scripts_list = NULL; | 385 const base::ListValue* scripts_list = NULL; |
| 386 if (!extension->manifest()->GetList(keys::kContentScripts, &scripts_list)) { | 386 if (!extension->manifest()->GetList(keys::kContentScripts, &scripts_list)) { |
| 387 *error = ASCIIToUTF16(errors::kInvalidContentScriptsList); | 387 *error = base::ASCIIToUTF16(errors::kInvalidContentScriptsList); |
| 388 return false; | 388 return false; |
| 389 } | 389 } |
| 390 | 390 |
| 391 for (size_t i = 0; i < scripts_list->GetSize(); ++i) { | 391 for (size_t i = 0; i < scripts_list->GetSize(); ++i) { |
| 392 const base::DictionaryValue* script_dict = NULL; | 392 const base::DictionaryValue* script_dict = NULL; |
| 393 if (!scripts_list->GetDictionary(i, &script_dict)) { | 393 if (!scripts_list->GetDictionary(i, &script_dict)) { |
| 394 *error = ErrorUtils::FormatErrorMessageUTF16( | 394 *error = ErrorUtils::FormatErrorMessageUTF16( |
| 395 errors::kInvalidContentScript, | 395 errors::kInvalidContentScript, |
| 396 base::IntToString(i)); | 396 base::IntToString(i)); |
| 397 return false; | 397 return false; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 if (!IsScriptValid(path, css_script.relative_path(), | 459 if (!IsScriptValid(path, css_script.relative_path(), |
| 460 IDS_EXTENSION_LOAD_CSS_FAILED, error)) | 460 IDS_EXTENSION_LOAD_CSS_FAILED, error)) |
| 461 return false; | 461 return false; |
| 462 } | 462 } |
| 463 } | 463 } |
| 464 | 464 |
| 465 return true; | 465 return true; |
| 466 } | 466 } |
| 467 | 467 |
| 468 } // namespace extensions | 468 } // namespace extensions |
| OLD | NEW |