Index: chrome/browser/chromeos/app_mode/kiosk_app_icon_loader.h |
diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_icon_loader.h b/chrome/browser/chromeos/app_mode/kiosk_app_icon_loader.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d6fbedc62d4432762273d0a8a898f4755610b2d7 |
--- /dev/null |
+++ b/chrome/browser/chromeos/app_mode/kiosk_app_icon_loader.h |
@@ -0,0 +1,68 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ |
+#define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ |
+ |
+#include "base/memory/ref_counted_memory.h" |
+#include "base/memory/weak_ptr.h" |
+#include "base/sequenced_task_runner.h" |
+#include "ui/gfx/image/image_skia.h" |
+ |
+namespace base { |
+class FilePath; |
+} |
+ |
+namespace chromeos { |
+ |
+// Loads locally stored icon data and decodes it. |
+class KioskAppIconLoader { |
+ public: |
+ enum LoadResult { |
+ SUCCESS, |
+ FAILED_TO_LOAD, |
+ FAILED_TO_DECODE, |
+ }; |
+ |
+ class Delegate { |
+ public: |
+ Delegate() = default; |
+ |
+ virtual void OnIconLoadSuccess(const gfx::ImageSkia& icon) = 0; |
+ virtual void OnIconLoadFailure() = 0; |
+ |
+ protected: |
+ virtual ~Delegate() = default; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(Delegate); |
+ }; |
+ |
+ explicit KioskAppIconLoader(const base::WeakPtr<Delegate>& delegate); |
+ |
+ void Start(const base::FilePath& icon_path); |
+ |
+ private: |
+ class IconImageRequest; |
+ |
+ ~KioskAppIconLoader(); |
+ |
+ // Loads the icon from locally stored |icon_path| on the blocking pool |
+ void LoadOnBlockingPool(const base::FilePath& icon_path); |
+ void ReportResultOnBlockingPool(LoadResult result); |
+ void NotifyDelegate(LoadResult result); |
+ void ReportResultOnUIThread(LoadResult result); |
+ |
+ base::WeakPtr<Delegate> delegate_; |
+ |
+ scoped_refptr<base::SequencedTaskRunner> task_runner_; |
+ |
+ gfx::ImageSkia icon_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(KioskAppIconLoader); |
+}; |
+ |
+} // namespace chromeos |
+ |
+#endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ |