| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
| 10 #include "chrome/renderer/extensions/bindings_utils.h" | 10 #include "chrome/renderer/extensions/bindings_utils.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // | 26 // |
| 27 // Return true and set |out_matching_dict| if such a dictionary was | 27 // Return true and set |out_matching_dict| if such a dictionary was |
| 28 // found. If false is returned, |out_message| is set to an explanation. | 28 // found. If false is returned, |out_message| is set to an explanation. |
| 29 bool FindDictionaryWithProperyValue(ListValue* list, | 29 bool FindDictionaryWithProperyValue(ListValue* list, |
| 30 const std::string& property, | 30 const std::string& property, |
| 31 const std::string& expected_value, | 31 const std::string& expected_value, |
| 32 DictionaryValue** out_matching_dict, | 32 DictionaryValue** out_matching_dict, |
| 33 std::string* out_error_message) { | 33 std::string* out_error_message) { |
| 34 bool found = false; | 34 bool found = false; |
| 35 for (ListValue::const_iterator it = list->begin(); it != list->end(); ++it) { | 35 for (ListValue::const_iterator it = list->begin(); it != list->end(); ++it) { |
| 36 if (!(*it)->IsType(Value::TYPE_DICTIONARY)) { | 36 if (!(*it)->IsDictionary()) { |
| 37 *out_error_message = "List contains an item taht is not a dictionary."; | 37 *out_error_message = "List contains an item taht is not a dictionary."; |
| 38 return false; | 38 return false; |
| 39 } | 39 } |
| 40 | 40 |
| 41 DictionaryValue* dict = static_cast<DictionaryValue*>(*it); | 41 DictionaryValue* dict = static_cast<DictionaryValue*>(*it); |
| 42 | 42 |
| 43 std::string actual_value; | 43 std::string actual_value; |
| 44 if (!dict->GetStringASCII(property, &actual_value)) { | 44 if (!dict->GetStringASCII(property, &actual_value)) { |
| 45 *out_error_message = | 45 *out_error_message = |
| 46 "Dictionary has no string property \'" + property + "'."; | 46 "Dictionary has no string property \'" + property + "'."; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 bindings_utils::GetStringResource(IDR_EXTENSION_API_JSON); | 133 bindings_utils::GetStringResource(IDR_EXTENSION_API_JSON); |
| 134 | 134 |
| 135 // Create a global variable holding the text of extension_api.json . | 135 // Create a global variable holding the text of extension_api.json . |
| 136 SetGlobalStringVar("ext_api_json_text", ext_api_string); | 136 SetGlobalStringVar("ext_api_json_text", ext_api_string); |
| 137 | 137 |
| 138 // Parse the text of extension_api.json . If there is a parse error, | 138 // Parse the text of extension_api.json . If there is a parse error, |
| 139 // an exception will be printed that includes a line number. | 139 // an exception will be printed that includes a line number. |
| 140 std::string test_js = "var extension_api = JSON.parse(ext_api_json_text);"; | 140 std::string test_js = "var extension_api = JSON.parse(ext_api_json_text);"; |
| 141 ExecuteScriptInContext(test_js, "ParseExtensionApiJson"); | 141 ExecuteScriptInContext(test_js, "ParseExtensionApiJson"); |
| 142 } | 142 } |
| OLD | NEW |