blob: 4f4c727d7bd00c9365ba027743b310e47b86eabc [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2016 The Chromium Authors
khmel6f0c8b4b2016-02-19 02:09:062// 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_UI_APP_ICON_LOADER_H_
6#define CHROME_BROWSER_UI_APP_ICON_LOADER_H_
7
8#include <string>
9
Keishi Hattori0e45c022021-11-27 09:25:5210#include "base/memory/raw_ptr.h"
khmel6f0c8b4b2016-02-19 02:09:0611#include "chrome/browser/ui/app_icon_loader_delegate.h"
12
13class Profile;
14
khmel6f0c8b4b2016-02-19 02:09:0615// Base class that loads and updates Chrome app's icons.
khmel8c1f6622017-05-11 19:14:5016// TODO(khmel): Switch to using ChromeAppIconService instead ChromeAppIconLoader
17// and ArcAppIconLoader.
khmel6f0c8b4b2016-02-19 02:09:0618class AppIconLoader {
19 public:
Peter Boström53c6c5952021-09-17 09:41:2620 AppIconLoader(const AppIconLoader&) = delete;
21 AppIconLoader& operator=(const AppIconLoader&) = delete;
22
khmel6f0c8b4b2016-02-19 02:09:0623 virtual ~AppIconLoader();
24
25 // Returns true is this AppIconLoader is able to load an image for the
26 // requested app.
27 virtual bool CanLoadImageForApp(const std::string& app_id) = 0;
28
29 // Fetches the image for the specified id. When done (which may be
30 // synchronous), this should invoke SetAppImage() on the delegate.
31 virtual void FetchImage(const std::string& app_id) = 0;
32
33 // Clears the image for the specified id.
34 virtual void ClearImage(const std::string& app_id) = 0;
35
36 // Updates the image for the specified id. This is called to re-create
37 // the app icon with latest app state (enabled or disabled/terminiated).
38 // SetAppImage() is called when done.
39 virtual void UpdateImage(const std::string& app_id) = 0;
40
41 protected:
42 AppIconLoader();
43 AppIconLoader(Profile* profile,
Nigel Tao7cc6f7a2019-03-14 09:13:3844 int icon_size_in_dip,
khmel6f0c8b4b2016-02-19 02:09:0645 AppIconLoaderDelegate* delegate);
46
47 Profile* profile() { return profile_; }
Nigel Tao7cc6f7a2019-03-14 09:13:3848 int icon_size_in_dip() const { return icon_size_in_dip_; }
khmel6f0c8b4b2016-02-19 02:09:0649 AppIconLoaderDelegate* delegate() { return delegate_; }
50
51 private:
Ali Hijazi9594a642022-12-01 14:30:5652 const raw_ptr<Profile, DanglingUntriaged> profile_ = nullptr;
Nigel Tao7cc6f7a2019-03-14 09:13:3853 const int icon_size_in_dip_ = 0;
khmel6f0c8b4b2016-02-19 02:09:0654
55 // The delegate object which receives the icon images. No ownership.
Keishi Hattori0e45c022021-11-27 09:25:5256 const raw_ptr<AppIconLoaderDelegate> delegate_ = nullptr;
khmel6f0c8b4b2016-02-19 02:09:0657};
58
59#endif // CHROME_BROWSER_UI_APP_ICON_LOADER_H_