OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/component_flash_hint_file_linux.h" | 5 #include "chrome/common/component_flash_hint_file_linux.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <sys/mman.h> | 8 #include <sys/mman.h> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/files/important_file_writer.h" | 13 #include "base/files/important_file_writer.h" |
14 #include "base/files/memory_mapped_file.h" | 14 #include "base/files/memory_mapped_file.h" |
15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
16 #include "base/json/json_string_value_serializer.h" | 16 #include "base/json/json_string_value_serializer.h" |
17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
18 #include "base/posix/eintr_wrapper.h" | 18 #include "base/posix/eintr_wrapper.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
22 #include "crypto/secure_hash.h" | 22 #include "crypto/secure_hash.h" |
23 #include "crypto/secure_util.h" | 23 #include "crypto/secure_util.h" |
24 #include "crypto/sha2.h" | 24 #include "crypto/sha2.h" |
25 | 25 |
26 namespace chrome { | |
27 | |
28 namespace component_flash_hint_file { | 26 namespace component_flash_hint_file { |
29 | 27 |
30 namespace { | 28 namespace { |
| 29 |
31 // The current version of the hints file. | 30 // The current version of the hints file. |
32 const int kCurrentHintFileVersion = 0x10; | 31 const int kCurrentHintFileVersion = 0x10; |
33 // The earliest version of the hints file. | 32 // The earliest version of the hints file. |
34 const int kEarliestHintFileVersion = 0x10; | 33 const int kEarliestHintFileVersion = 0x10; |
35 // The Version field in the JSON encoded file. | 34 // The Version field in the JSON encoded file. |
36 const char kVersionField[] = "Version"; | 35 const char kVersionField[] = "Version"; |
37 // The HashAlgorithm field in the JSON encoded file. | 36 // The HashAlgorithm field in the JSON encoded file. |
38 const char kHashAlgoField[] = "HashAlgorithm"; | 37 const char kHashAlgoField[] = "HashAlgorithm"; |
39 // The Hash field in the JSON encoded file. | 38 // The Hash field in the JSON encoded file. |
40 const char kHashField[] = "Hash"; | 39 const char kHashField[] = "Hash"; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 return false; | 154 return false; |
156 | 155 |
157 int error_code; | 156 int error_code; |
158 std::string error_message; | 157 std::string error_message; |
159 JSONStringValueDeserializer deserializer(json_string); | 158 JSONStringValueDeserializer deserializer(json_string); |
160 const scoped_ptr<base::Value> value( | 159 const scoped_ptr<base::Value> value( |
161 deserializer.Deserialize(&error_code, &error_message)); | 160 deserializer.Deserialize(&error_code, &error_message)); |
162 | 161 |
163 if (!value) { | 162 if (!value) { |
164 LOG(ERROR) | 163 LOG(ERROR) |
165 << "Could not deserialize the component updated flash hint file. Error " | 164 << "Could not deserialize the component updated Flash hint file. Error " |
166 << error_code << ": " << error_message; | 165 << error_code << ": " << error_message; |
167 return false; | 166 return false; |
168 } | 167 } |
169 | 168 |
170 base::DictionaryValue* dict = nullptr; | 169 base::DictionaryValue* dict = nullptr; |
171 if (!value->GetAsDictionary(&dict)) | 170 if (!value->GetAsDictionary(&dict)) |
172 return false; | 171 return false; |
173 | 172 |
174 int version; | 173 int version; |
175 if (!dict->GetInteger(kVersionField, &version)) | 174 if (!dict->GetInteger(kVersionField, &version)) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 "component flash plugin will not be loaded."; | 213 "component flash plugin will not be loaded."; |
215 return false; | 214 return false; |
216 } | 215 } |
217 | 216 |
218 *path = plugin_path; | 217 *path = plugin_path; |
219 flash_version->assign(plugin_version_str); | 218 flash_version->assign(plugin_version_str); |
220 return true; | 219 return true; |
221 } | 220 } |
222 | 221 |
223 } // namespace component_flash_hint_file | 222 } // namespace component_flash_hint_file |
224 | |
225 } // namespace chrome | |
OLD | NEW |