| 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 "chrome/browser/component_updater/component_unpacker.h" | 5 #include "chrome/browser/component_updater/component_unpacker.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // as an extension. | 122 // as an extension. |
| 123 base::DictionaryValue* ReadManifest(const FilePath& unpack_path) { | 123 base::DictionaryValue* ReadManifest(const FilePath& unpack_path) { |
| 124 FilePath manifest = unpack_path.Append(FILE_PATH_LITERAL("manifest.json")); | 124 FilePath manifest = unpack_path.Append(FILE_PATH_LITERAL("manifest.json")); |
| 125 if (!file_util::PathExists(manifest)) | 125 if (!file_util::PathExists(manifest)) |
| 126 return NULL; | 126 return NULL; |
| 127 JSONFileValueSerializer serializer(manifest); | 127 JSONFileValueSerializer serializer(manifest); |
| 128 std::string error; | 128 std::string error; |
| 129 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); | 129 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); |
| 130 if (!root.get()) | 130 if (!root.get()) |
| 131 return NULL; | 131 return NULL; |
| 132 if (!root->IsType(base::Value::TYPE_DICTIONARY)) | 132 if (!root->IsDictionary()) |
| 133 return NULL; | 133 return NULL; |
| 134 return static_cast<base::DictionaryValue*>(root.release()); | 134 return static_cast<base::DictionaryValue*>(root.release()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace. | 137 } // namespace. |
| 138 | 138 |
| 139 ComponentUnpacker::ComponentUnpacker(const std::vector<uint8>& pk_hash, | 139 ComponentUnpacker::ComponentUnpacker(const std::vector<uint8>& pk_hash, |
| 140 const FilePath& path, | 140 const FilePath& path, |
| 141 ComponentInstaller* installer) | 141 ComponentInstaller* installer) |
| 142 : error_(kNone) { | 142 : error_(kNone) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } | 201 } |
| 202 // Installation succesful. The directory is not our concern now. | 202 // Installation succesful. The directory is not our concern now. |
| 203 unpack_path_.clear(); | 203 unpack_path_.clear(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 ComponentUnpacker::~ComponentUnpacker() { | 206 ComponentUnpacker::~ComponentUnpacker() { |
| 207 if (!unpack_path_.empty()) { | 207 if (!unpack_path_.empty()) { |
| 208 file_util::Delete(unpack_path_, true); | 208 file_util::Delete(unpack_path_, true); |
| 209 } | 209 } |
| 210 } | 210 } |
| OLD | NEW |