| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ | |
| 7 | |
| 8 #include "base/callback_forward.h" | |
| 9 #include "base/memory/ref_counted_memory.h" | |
| 10 #include "base/memory/weak_ptr.h" | |
| 11 #include "base/optional.h" | |
| 12 #include "base/sequenced_task_runner.h" | |
| 13 #include "ui/gfx/image/image_skia.h" | |
| 14 | |
| 15 namespace base { | |
| 16 class FilePath; | |
| 17 } | |
| 18 | |
| 19 namespace chromeos { | |
| 20 | |
| 21 // Loads locally stored icon data and decodes it. | |
| 22 class KioskAppIconLoader { | |
| 23 public: | |
| 24 enum LoadResult { | |
| 25 SUCCESS, | |
| 26 FAILED_TO_LOAD, | |
| 27 FAILED_TO_DECODE, | |
| 28 }; | |
| 29 | |
| 30 class Delegate { | |
| 31 public: | |
| 32 virtual void OnIconLoadSuccess(const gfx::ImageSkia& icon) = 0; | |
| 33 virtual void OnIconLoadFailure() = 0; | |
| 34 | |
| 35 protected: | |
| 36 virtual ~Delegate() = default; | |
| 37 }; | |
| 38 | |
| 39 using ResultCallback = | |
| 40 base::Callback<void(base::Optional<gfx::ImageSkia> result)>; | |
| 41 | |
| 42 explicit KioskAppIconLoader(Delegate* delegate); | |
| 43 | |
| 44 ~KioskAppIconLoader(); | |
| 45 | |
| 46 void Start(const base::FilePath& icon_path); | |
| 47 | |
| 48 private: | |
| 49 void OnImageDecodingFinished(base::Optional<gfx::ImageSkia> result); | |
| 50 | |
| 51 // Delegate always lives longer than this class as it's owned by delegate. | |
| 52 Delegate* const delegate_; | |
| 53 | |
| 54 scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
| 55 | |
| 56 gfx::ImageSkia icon_; | |
| 57 | |
| 58 base::WeakPtrFactory<KioskAppIconLoader> weak_factory_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(KioskAppIconLoader); | |
| 61 }; | |
| 62 | |
| 63 } // namespace chromeos | |
| 64 | |
| 65 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ | |
| OLD | NEW |