Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // 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_CHROMEOS_APP_MODE_KIOSK_APP_DATA_BASE_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_BASE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/files/file_path.h" | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "chrome/browser/chromeos/app_mode/kiosk_app_icon_loader.h" | |
| 13 #include "components/prefs/scoped_user_pref_update.h" | |
| 14 #include "components/signin/core/account_id/account_id.h" | |
| 15 #include "ui/gfx/image/image_skia.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class DictionaryValue; | |
| 19 } | |
| 20 | |
| 21 namespace chromeos { | |
| 22 | |
| 23 class KioskAppDataBase : public base::SupportsWeakPtr<KioskAppDataBase>, | |
| 24 public KioskAppIconLoader::Delegate { | |
| 25 public: | |
| 26 // Dictionary key for apps. | |
| 27 static const char kKeyApps[]; | |
| 28 | |
| 29 const std::string& app_id() const { return app_id_; } | |
| 30 const AccountId& account_id() const { return account_id_; } | |
| 31 const std::string& name() const { return name_; } | |
| 32 const gfx::ImageSkia& icon() const { return icon_; } | |
| 33 | |
| 34 // Name of a dictionary that holds kiosk app info in Local State. | |
| 35 virtual const char* kiosk_dictionary_name() const = 0; | |
|
xiyuan
2017/03/30 16:46:59
nit: Slightly prefer to pass this in as an arg of
Sergey Poromov
2017/03/30 18:22:07
Done.
| |
| 36 | |
| 37 // Callbacks for KioskAppIconLoader. | |
| 38 void OnIconLoadSuccess(const gfx::ImageSkia& icon) override = 0; | |
|
xiyuan
2017/03/30 16:46:59
It is a bit confusing to inherit from an interface
Sergey Poromov
2017/03/30 18:22:07
IconLoader is used from this class - see end of Lo
| |
| 39 void OnIconLoadFailure() override = 0; | |
| 40 | |
| 41 // Clears locally cached data. | |
| 42 void ClearCache(); | |
| 43 | |
| 44 protected: | |
| 45 KioskAppDataBase(const std::string& app_id, const AccountId& account_id); | |
| 46 ~KioskAppDataBase() override; | |
| 47 | |
| 48 // Helper to save name and icon to provided dictionary. | |
| 49 void SaveToDictionary(DictionaryPrefUpdate& dict_update); | |
| 50 // Helper to load name and icon from provided dictionary. | |
|
xiyuan
2017/03/30 16:46:59
nit: insert a blank line between each function.
Sergey Poromov
2017/03/30 18:22:07
Done.
| |
| 51 bool LoadFromDictionary(const base::DictionaryValue* dict); | |
| 52 // Helper to cache |icon| to |cache_dir|. | |
| 53 void SaveIcon(const SkBitmap& icon, const base::FilePath& cache_dir); | |
| 54 | |
| 55 std::string app_id_; | |
|
Luis Héctor Chávez
2017/03/30 16:49:54
nit: these two can be const.
Sergey Poromov
2017/03/30 18:22:07
Done.
| |
| 56 AccountId account_id_; | |
| 57 std::string name_; | |
| 58 gfx::ImageSkia icon_; | |
| 59 | |
| 60 base::FilePath icon_path_; | |
|
xiyuan
2017/03/30 16:46:59
Can this and above members be private since we hav
Sergey Poromov
2017/03/30 18:22:07
Some of them should be changeable from derived cla
| |
| 61 | |
| 62 private: | |
| 63 class IconLoader; | |
|
xiyuan
2017/03/30 16:46:59
remove since it is now KioskAppIconLoader ?
Sergey Poromov
2017/03/30 18:22:07
Done.
| |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(KioskAppDataBase); | |
| 66 }; | |
| 67 | |
| 68 } // namespace chromeos | |
| 69 | |
| 70 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_BASE_H_ | |
| OLD | NEW |