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

Side by Side 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: xiyuan@ comments Created 3 years, 8 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 unified diff | Download patch
OLDNEW
(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/memory/ref_counted_memory.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/sequenced_task_runner.h"
11 #include "ui/gfx/image/image_skia.h"
12
13 namespace base {
14 class FilePath;
15 }
16
17 namespace chromeos {
18
19 // Loads locally stored icon data and decodes it.
20 class KioskAppIconLoader {
21 public:
22 enum LoadResult {
23 SUCCESS,
24 FAILED_TO_LOAD,
25 FAILED_TO_DECODE,
26 };
27
28 class Delegate {
29 public:
30 virtual void OnIconLoadSuccess(const gfx::ImageSkia& icon) = 0;
31 virtual void OnIconLoadFailure() = 0;
32
33 protected:
34 virtual ~Delegate() = default;
35 };
36
37 explicit KioskAppIconLoader(Delegate* delegate);
38
39 ~KioskAppIconLoader();
40
41 void Start(const base::FilePath& icon_path);
42
43 private:
44 class IconImageRequest;
45
46 // Loads the icon from locally stored |icon_path| on the blocking pool
47 void LoadOnBlockingPool(const base::FilePath& icon_path);
48 void ReportResultOnBlockingPool(LoadResult result);
49 void NotifyDelegate(LoadResult result);
50 void ReportResultOnUIThread(LoadResult result);
51
52 // Delegate always live longer than this class as it's owned by delegate.
53 Delegate* const delegate_;
54
55 scoped_refptr<base::SequencedTaskRunner> task_runner_;
56
57 gfx::ImageSkia icon_;
58
59 base::WeakPtrFactory<KioskAppIconLoader> weak_factory_;
60
61 DISALLOW_COPY_AND_ASSIGN(KioskAppIconLoader);
62 };
63
64 } // namespace chromeos
65
66 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698