1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_APP_MODE_ARCVM_APP_KIOSK_ARCVM_APP_DATA_H_
#define CHROME_BROWSER_ASH_APP_MODE_ARCVM_APP_KIOSK_ARCVM_APP_DATA_H_
#include <optional>
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/ash/app_mode/kiosk_app_data_base.h"
#include "ui/gfx/image/image_skia.h"
class AccountId;
class PrefService;
namespace base {
class FilePath;
} // namespace base
namespace ash {
// Fetches from Android side and caches ARCVM kiosk app data such as name and
// icon.
class KioskArcvmAppData : public KioskAppDataBase {
public:
// static dictionary to store Android Kiosk app's local state.
inline static constexpr char kArcvmKioskDictionaryName[] = "arcvm-kiosk";
// local_state: Stores user defined app data such as name, icon, etc.
// It should outlive KioskArcvmAppData.
// app_id: Unique identifier string generated by ArcApplistPrefs::GetAppId
// package_name: Android package name.
// activity: Android activity class to be invoked within the package.
// intent: Android intent to communicate a system event to the activity.
// account_id: Autolaunch account identifier associated with the Android
// application.
// name: Display name for the Android application.
KioskArcvmAppData(PrefService* local_state,
std::string app_id,
std::string package_name,
std::string activity,
std::string intent,
AccountId account_id,
std::string name);
KioskArcvmAppData(const KioskArcvmAppData&) = delete;
KioskArcvmAppData& operator=(const KioskArcvmAppData&) = delete;
~KioskArcvmAppData() override;
const std::string& package_name() const { return package_name_; }
const std::string& activity() const { return activity_; }
const std::string& intent() const { return intent_; }
bool CompareByAppID(const std::string& other_app_id) const;
// Loads the locally cached data. Return false if there is none.
// Asynchronously populate icon_ value.
bool LoadFromCache();
// Sets the cached data.
void SetCache(const std::string& name,
const gfx::ImageSkia& icon,
const base::FilePath& cache_dir);
private:
void OnIconLoadDone(std::optional<gfx::ImageSkia> icon);
const raw_ptr<PrefService> local_state_;
const std::string package_name_;
const std::string activity_;
const std::string intent_;
base::WeakPtrFactory<KioskArcvmAppData> weak_ptr_factory_{this};
};
} // namespace ash
#endif // CHROME_BROWSER_ASH_APP_MODE_ARCVM_APP_KIOSK_ARCVM_APP_DATA_H_
|