OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/update_client/component_unpacker.h" | 5 #include "components/update_client/component_unpacker.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 // TODO(cpu): add a specific attribute check to a component json that the | 119 // TODO(cpu): add a specific attribute check to a component json that the |
120 // extension unpacker will reject, so that a component cannot be installed | 120 // extension unpacker will reject, so that a component cannot be installed |
121 // as an extension. | 121 // as an extension. |
122 scoped_ptr<base::DictionaryValue> ReadManifest( | 122 scoped_ptr<base::DictionaryValue> ReadManifest( |
123 const base::FilePath& unpack_path) { | 123 const base::FilePath& unpack_path) { |
124 base::FilePath manifest = | 124 base::FilePath manifest = |
125 unpack_path.Append(FILE_PATH_LITERAL("manifest.json")); | 125 unpack_path.Append(FILE_PATH_LITERAL("manifest.json")); |
126 if (!base::PathExists(manifest)) | 126 if (!base::PathExists(manifest)) |
127 return scoped_ptr<base::DictionaryValue>(); | 127 return scoped_ptr<base::DictionaryValue>(); |
128 JSONFileValueSerializer serializer(manifest); | 128 JSONFileValueDeserializer deserializer(manifest); |
129 std::string error; | 129 std::string error; |
130 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); | 130 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, &error)); |
131 if (!root.get()) | 131 if (!root.get()) |
132 return scoped_ptr<base::DictionaryValue>(); | 132 return scoped_ptr<base::DictionaryValue>(); |
133 if (!root->IsType(base::Value::TYPE_DICTIONARY)) | 133 if (!root->IsType(base::Value::TYPE_DICTIONARY)) |
134 return scoped_ptr<base::DictionaryValue>(); | 134 return scoped_ptr<base::DictionaryValue>(); |
135 return scoped_ptr<base::DictionaryValue>( | 135 return scoped_ptr<base::DictionaryValue>( |
136 static_cast<base::DictionaryValue*>(root.release())).Pass(); | 136 static_cast<base::DictionaryValue*>(root.release())).Pass(); |
137 } | 137 } |
138 | 138 |
139 bool ComponentUnpacker::UnpackInternal() { | 139 bool ComponentUnpacker::UnpackInternal() { |
140 return Verify() && Unzip() && BeginPatching(); | 140 return Verify() && Unzip() && BeginPatching(); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 base::DeleteFile(unpack_diff_path_, true); | 270 base::DeleteFile(unpack_diff_path_, true); |
271 if (!unpack_path_.empty()) | 271 if (!unpack_path_.empty()) |
272 base::DeleteFile(unpack_path_, true); | 272 base::DeleteFile(unpack_path_, true); |
273 callback_.Run(error_, extended_error_); | 273 callback_.Run(error_, extended_error_); |
274 } | 274 } |
275 | 275 |
276 ComponentUnpacker::~ComponentUnpacker() { | 276 ComponentUnpacker::~ComponentUnpacker() { |
277 } | 277 } |
278 | 278 |
279 } // namespace update_client | 279 } // namespace update_client |
OLD | NEW |