| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_app_data_base.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_data_base.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 // Keys for local state data. | 25 // Keys for local state data. |
| 26 constexpr char kKeyName[] = "name"; | 26 constexpr char kKeyName[] = "name"; |
| 27 constexpr char kKeyIcon[] = "icon"; | 27 constexpr char kKeyIcon[] = "icon"; |
| 28 | 28 |
| 29 // Icon file extension. | 29 // Icon file extension. |
| 30 constexpr char kIconFileExtension[] = ".png"; | 30 constexpr char kIconFileExtension[] = ".png"; |
| 31 | 31 |
| 32 // Save |raw_icon| for given |app_id|. | 32 // Save |raw_icon| for given |app_id|. |
| 33 void SaveIconToLocalOnBlockingPool(const base::FilePath& icon_path, | 33 void SaveIconToLocalOnBlockingPool(const base::FilePath& icon_path, |
| 34 std::vector<unsigned char> image_data) { | 34 std::vector<unsigned char> image_data) { |
| 35 DCHECK(BrowserThread::GetBlockingPool()->RunsTasksOnCurrentThread()); | 35 base::ThreadRestrictions::AssertIOAllowed(); |
| 36 | |
| 37 const base::FilePath dir = icon_path.DirName(); | 36 const base::FilePath dir = icon_path.DirName(); |
| 38 if (!base::PathExists(dir) && !base::CreateDirectory(dir)) { | 37 if (!base::PathExists(dir) && !base::CreateDirectory(dir)) { |
| 39 LOG(ERROR) << "Failed to create directory to store kiosk icons"; | 38 LOG(ERROR) << "Failed to create directory to store kiosk icons"; |
| 40 return; | 39 return; |
| 41 } | 40 } |
| 42 | 41 |
| 43 const int wrote = base::WriteFile( | 42 const int wrote = base::WriteFile( |
| 44 icon_path, reinterpret_cast<char*>(image_data.data()), image_data.size()); | 43 icon_path, reinterpret_cast<char*>(image_data.data()), image_data.size()); |
| 45 if (wrote != static_cast<int>(image_data.size())) { | 44 if (wrote != static_cast<int>(image_data.size())) { |
| 46 LOG(ERROR) << "Failed to write kiosk icon file"; | 45 LOG(ERROR) << "Failed to write kiosk icon file"; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 dict_update->Remove(app_key, nullptr); | 118 dict_update->Remove(app_key, nullptr); |
| 120 | 119 |
| 121 if (!icon_path_.empty()) { | 120 if (!icon_path_.empty()) { |
| 122 base::PostTaskWithTraits( | 121 base::PostTaskWithTraits( |
| 123 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, | 122 FROM_HERE, {base::MayBlock(), base::TaskPriority::BACKGROUND}, |
| 124 base::Bind(base::IgnoreResult(&base::DeleteFile), icon_path_, false)); | 123 base::Bind(base::IgnoreResult(&base::DeleteFile), icon_path_, false)); |
| 125 } | 124 } |
| 126 } | 125 } |
| 127 | 126 |
| 128 } // namespace chromeos | 127 } // namespace chromeos |
| OLD | NEW |