File: kiosk_arcvm_app_data.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (79 lines) | stat: -rw-r--r-- 2,785 bytes parent folder | download | duplicates (5)
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_