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 "chrome/browser/chromeos/app_mode/kiosk_external_updater.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_external_updater.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 KioskExternalUpdater::ExternalUpdateErrorCode* error_code) { | 37 KioskExternalUpdater::ExternalUpdateErrorCode* error_code) { |
38 base::FilePath manifest = | 38 base::FilePath manifest = |
39 external_update_dir.AppendASCII(kExternalUpdateManifest); | 39 external_update_dir.AppendASCII(kExternalUpdateManifest); |
40 if (!base::PathExists(manifest)) { | 40 if (!base::PathExists(manifest)) { |
41 *error_code = KioskExternalUpdater::ERROR_NO_MANIFEST; | 41 *error_code = KioskExternalUpdater::ERROR_NO_MANIFEST; |
42 return; | 42 return; |
43 } | 43 } |
44 | 44 |
45 JSONFileValueDeserializer deserializer(manifest); | 45 JSONFileValueDeserializer deserializer(manifest); |
46 std::string error_msg; | 46 std::string error_msg; |
47 base::Value* extensions = deserializer.Deserialize(NULL, &error_msg); | 47 base::Value* extensions = |
48 deserializer.Deserialize(NULL, &error_msg).release(); | |
48 if (!extensions) { | 49 if (!extensions) { |
49 *error_code = KioskExternalUpdater::ERROR_INVALID_MANIFEST; | 50 *error_code = KioskExternalUpdater::ERROR_INVALID_MANIFEST; |
50 return; | 51 return; |
51 } | 52 } |
52 | 53 |
53 base::DictionaryValue* dict_value = NULL; | 54 base::DictionaryValue* dict_value = NULL; |
54 if (!extensions->GetAsDictionary(&dict_value)) { | 55 if (!extensions->GetAsDictionary(&dict_value)) { |
55 *error_code = KioskExternalUpdater::ERROR_INVALID_MANIFEST; | 56 *error_code = KioskExternalUpdater::ERROR_INVALID_MANIFEST; |
Lei Zhang
2015/10/12 22:42:21
Sorry to bug you about these possibly existing iss
| |
56 return; | 57 return; |
57 } | 58 } |
58 | 59 |
59 parsed_manifest->Swap(dict_value); | 60 parsed_manifest->Swap(dict_value); |
Lei Zhang
2015/10/12 22:42:21
After we swap, do we need to free the pointer that
| |
60 *error_code = KioskExternalUpdater::ERROR_NONE; | 61 *error_code = KioskExternalUpdater::ERROR_NONE; |
61 } | 62 } |
62 | 63 |
63 // Copies |external_crx_file| to |temp_crx_file|, and removes |temp_dir| | 64 // Copies |external_crx_file| to |temp_crx_file|, and removes |temp_dir| |
64 // created for unpacking |external_crx_file|. | 65 // created for unpacking |external_crx_file|. |
65 void CopyExternalCrxAndDeleteTempDir(const base::FilePath& external_crx_file, | 66 void CopyExternalCrxAndDeleteTempDir(const base::FilePath& external_crx_file, |
66 const base::FilePath& temp_crx_file, | 67 const base::FilePath& temp_crx_file, |
67 const base::FilePath& temp_dir, | 68 const base::FilePath& temp_dir, |
68 bool* success) { | 69 bool* success) { |
69 base::DeleteFile(temp_dir, true); | 70 base::DeleteFile(temp_dir, true); |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 if (failed) { | 525 if (failed) { |
525 failed_app_msg = ui::ResourceBundle::GetSharedInstance().GetLocalizedString( | 526 failed_app_msg = ui::ResourceBundle::GetSharedInstance().GetLocalizedString( |
526 IDS_KIOSK_EXTERNAL_UPDATE_FAILED_UPDATED_APPS) + | 527 IDS_KIOSK_EXTERNAL_UPDATE_FAILED_UPDATED_APPS) + |
527 base::ASCIIToUTF16("\n") + failed_apps; | 528 base::ASCIIToUTF16("\n") + failed_apps; |
528 message = message + base::ASCIIToUTF16("\n") + failed_app_msg; | 529 message = message + base::ASCIIToUTF16("\n") + failed_app_msg; |
529 } | 530 } |
530 return message; | 531 return message; |
531 } | 532 } |
532 | 533 |
533 } // namespace chromeos | 534 } // namespace chromeos |
OLD | NEW |