Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(668)

Unified Diff: chrome/browser/chromeos/app_mode/kiosk_app_icon_loader.h

Issue 2778053002: Fetch ARC Kiosk app name and icon from Android side. (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..e4dc6b884eff7afbeab93038bdcaa42b62a9f346
--- /dev/null
+++ b/chrome/browser/chromeos/app_mode/kiosk_app_icon_loader.h
@@ -0,0 +1,85 @@
+// 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/files/file_path.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/memory/weak_ptr.h"
+#include "base/sequenced_task_runner.h"
+#include "chrome/browser/image_decoder.h"
+#include "ui/gfx/image/image_skia.h"
+
+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);
+ };
+
+ KioskAppIconLoader(const base::WeakPtr<Delegate>& client,
+ const base::FilePath& icon_path);
+
+ void Start();
+
+ private:
+ friend class base::RefCountedThreadSafe<KioskAppIconLoader>;
+
+ ~KioskAppIconLoader();
+
+ class IconImageRequest : public ImageDecoder::ImageRequest {
khmel 2017/03/27 22:56:34 nit: Move to cc file and use here only forward dec
Sergey Poromov 2017/03/28 15:25:55 Done. Thanks, missed the opportunity.
+ public:
+ IconImageRequest(
+ const scoped_refptr<base::SequencedTaskRunner>& task_runner,
+ KioskAppIconLoader* icon_loader);
+
+ void OnImageDecoded(const SkBitmap& decoded_image) override;
+
+ void OnDecodeImageFailed() override;
+
+ private:
+ ~IconImageRequest() override = default;
+ KioskAppIconLoader* icon_loader_;
+ };
+
+ // Loads the icon from locally stored |icon_path_| on the blocking pool
+ void LoadOnBlockingPool();
+ void ReportResultOnBlockingPool(LoadResult result);
+ void NotifyClient();
+ void ReportResultOnUIThread();
+
+ base::WeakPtr<Delegate> client_;
+ base::FilePath icon_path_;
+
+ LoadResult load_result_;
+ scoped_refptr<base::SequencedTaskRunner> task_runner_;
+
+ gfx::ImageSkia icon_;
+ scoped_refptr<base::RefCountedString> raw_icon_;
+
+ DISALLOW_COPY_AND_ASSIGN(KioskAppIconLoader);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_

Powered by Google App Engine
This is Rietveld 408576698