| Index: chrome/browser/ui/app_list/arc/arc_app_list_prefs.h
|
| diff --git a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.h b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.h
|
| index cff36005e483dd28d82ea613239945ea2ecc0751..2e86915f84ed36e846bb7e9e7c6e3a593c1d2ed4 100644
|
| --- a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.h
|
| +++ b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.h
|
| @@ -160,6 +160,8 @@ class ArcAppListPrefs
|
| // It is called from chrome/browser/prefs/browser_prefs.cc.
|
| static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
|
|
|
| + static void UseTestDefaultAppsDirectory();
|
| +
|
| ~ArcAppListPrefs() override;
|
|
|
| // Returns a list of all app ids, including ready and non-ready apps.
|
| @@ -201,6 +203,8 @@ class ArcAppListPrefs
|
|
|
| // Returns true if app is registered.
|
| bool IsRegistered(const std::string& app_id) const;
|
| + // Returns true if app is an Oem app.
|
| + bool IsOem(const std::string& app_id) const;
|
| // Returns true if app is a shortcut
|
| bool IsShortcut(const std::string& app_id) const;
|
|
|
| @@ -218,9 +222,32 @@ class ArcAppListPrefs
|
| return app_instance_holder_;
|
| }
|
|
|
| + bool default_apps_read() const { return default_apps_read_; }
|
| +
|
| private:
|
| friend class ChromeLauncherControllerImplTest;
|
|
|
| + struct DefaultAppInfo {
|
| + DefaultAppInfo(const std::string& name,
|
| + const std::string& package_name,
|
| + const std::string& activity,
|
| + bool oem,
|
| + const base::FilePath app_path);
|
| + ~DefaultAppInfo();
|
| +
|
| + std::string name;
|
| + std::string package_name;
|
| + std::string activity;
|
| + bool oem;
|
| + base::FilePath app_path; // App folder that contains pre-installed icons.
|
| + };
|
| +
|
| + // Defines App id to DefaultAppInfo mapping.
|
| + using DefaultAppInfoMap =
|
| + std::map<std::string, std::unique_ptr<DefaultAppInfo>>;
|
| + // Defines mapping package name to uninstalled state.
|
| + using DefaultPacakageMap = std::map<std::string, bool>;
|
| +
|
| // See the Create methods.
|
| ArcAppListPrefs(
|
| Profile* profile,
|
| @@ -261,6 +288,31 @@ class ArcAppListPrefs
|
| int32_t task_id,
|
| const arc::mojom::OrientationLock orientation_lock) override;
|
|
|
| + void StartPrefs();
|
| +
|
| + // Reads default app info on IO thread.
|
| + static std::unique_ptr<DefaultAppInfoMap> ReadDefaultApps();
|
| + // Called when default apps are read.
|
| + void OnDefaultAppsReady(std::unique_ptr<DefaultAppInfoMap> apps);
|
| + // Returns default app info if it is found in defaults and its package is not
|
| + // marked as uninstalled.
|
| + const DefaultAppInfo* GetDefaultApp(const std::string& app_id) const;
|
| + // Returns true if app is found in defaults and its package is not marked as
|
| + // uninstalled.
|
| + bool HasDefaultApp(const std::string& app_id) const;
|
| + // Returns true if package exists in default packages list.
|
| + bool HasDefaultPackage(const std::string& package_name) const;
|
| + // Sets uninstalled flag for default package if it exists in default packages
|
| + // list.
|
| + void MaybeMarkDefaultPackageUninstalled(const std::string& package_name,
|
| + bool uninstalled);
|
| +
|
| + // Returns list of packages from prefs. If |installed| is set to true then
|
| + // returns currently installed packages. If not, returns list of packages that
|
| + // where uninstalled. Note, we store uninstall packages only for packages of
|
| + // default apps.
|
| + std::vector<std::string> GetPackagesFromPrefs(bool installed) const;
|
| +
|
| void AddApp(const arc::mojom::AppInfo& app_info);
|
| void AddAppAndShortcut(const std::string& name,
|
| const std::string& package_name,
|
| @@ -272,6 +324,13 @@ class ArcAppListPrefs
|
| const bool shortcut,
|
| const bool launchable,
|
| arc::mojom::OrientationLock orientation_lock);
|
| + // Adds or updates local pref for given package.
|
| + void AddOrUpdatePackagePrefs(PrefService* prefs,
|
| + const arc::mojom::ArcPackageInfo& package);
|
| + // Removes given package from local pref.
|
| + void RemovePackageFromPrefs(PrefService* prefs,
|
| + const std::string& package_name);
|
| +
|
| void DisableAllApps();
|
| void RemoveAllApps();
|
| std::vector<std::string> GetAppIdsNoArcEnabledCheck() const;
|
| @@ -294,9 +353,9 @@ class ArcAppListPrefs
|
|
|
| // This checks if app is not registered yet and in this case creates
|
| // non-launchable app entry.
|
| - void MayAddNonLaunchableApp(const std::string& name,
|
| - const std::string& package_name,
|
| - const std::string& activity);
|
| + void MaybeAddNonLaunchableApp(const std::string& name,
|
| + const std::string& package_name,
|
| + const std::string& activity);
|
|
|
| Profile* const profile_;
|
|
|
| @@ -321,6 +380,11 @@ class ArcAppListPrefs
|
| // True if apps were restored.
|
| bool apps_restored_ = false;
|
|
|
| + // Contains map of default pre-installed apps and packages.
|
| + bool default_apps_read_ = false;
|
| + DefaultAppInfoMap default_apps_;
|
| + DefaultPacakageMap default_packages_;
|
| +
|
| arc::ArcPackageSyncableService* sync_service_;
|
|
|
| mojo::Binding<arc::mojom::AppHost> binding_;
|
|
|