Chromium Code Reviews| 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..dbd0a5b06c3fca2dcae46136ebecc9c9a88721e7 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,32 @@ class ArcAppListPrefs |
| int32_t task_id, |
| const arc::mojom::OrientationLock orientation_lock) override; |
| + void StartPrefs(); |
| + |
| + // Reads default app infos. |
| + static std::unique_ptr<DefaultAppInfoMap> ReadDefaultAppsFromFileThread(); |
|
xiyuan
2016/08/26 19:32:29
nit: private static can probably be moved to an an
khmel
2016/08/26 23:26:18
I used it here in order to access private declarat
|
| + // 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. Note it may be |
| + // marked as uninstalled. |
| + bool HasDefaultPackage(const std::string& package_name) const; |
|
xiyuan
2016/08/26 19:32:29
Could we move those default app methods and data i
khmel
2016/08/26 23:26:18
Initially did like this :) but moved to one file,
|
| + // 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 +325,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 +354,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 +381,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_; |