Chromium Code Reviews| Index: chrome/browser/chromeos/app_mode/kiosk_app_data_base.h |
| diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_data_base.h b/chrome/browser/chromeos/app_mode/kiosk_app_data_base.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b5b67dd888b06d8bfff6ee464edb8f8277adfbc0 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/app_mode/kiosk_app_data_base.h |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_BASE_H_ |
| +#define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_BASE_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/files/file_path.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "chrome/browser/chromeos/app_mode/kiosk_app_icon_loader.h" |
| +#include "components/prefs/scoped_user_pref_update.h" |
| +#include "components/signin/core/account_id/account_id.h" |
| +#include "ui/gfx/image/image_skia.h" |
| + |
| +namespace base { |
| +class DictionaryValue; |
| +} |
| + |
| +namespace chromeos { |
| + |
| +class KioskAppDataBase : public base::SupportsWeakPtr<KioskAppDataBase>, |
| + public KioskAppIconLoader::Delegate { |
| + public: |
| + // Dictionary key for apps. |
| + static const char kKeyApps[]; |
| + |
| + const std::string& app_id() const { return app_id_; } |
| + const AccountId& account_id() const { return account_id_; } |
| + const std::string& name() const { return name_; } |
| + const gfx::ImageSkia& icon() const { return icon_; } |
| + |
| + // Name of a dictionary that holds kiosk app info in Local State. |
| + 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.
|
| + |
| + // Callbacks for KioskAppIconLoader. |
| + 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
|
| + void OnIconLoadFailure() override = 0; |
| + |
| + // Clears locally cached data. |
| + void ClearCache(); |
| + |
| + protected: |
| + KioskAppDataBase(const std::string& app_id, const AccountId& account_id); |
| + ~KioskAppDataBase() override; |
| + |
| + // Helper to save name and icon to provided dictionary. |
| + void SaveToDictionary(DictionaryPrefUpdate& dict_update); |
| + // 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.
|
| + bool LoadFromDictionary(const base::DictionaryValue* dict); |
| + // Helper to cache |icon| to |cache_dir|. |
| + void SaveIcon(const SkBitmap& icon, const base::FilePath& cache_dir); |
| + |
| + 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.
|
| + AccountId account_id_; |
| + std::string name_; |
| + gfx::ImageSkia icon_; |
| + |
| + 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
|
| + |
| + private: |
| + class IconLoader; |
|
xiyuan
2017/03/30 16:46:59
remove since it is now KioskAppIconLoader ?
Sergey Poromov
2017/03/30 18:22:07
Done.
|
| + |
| + DISALLOW_COPY_AND_ASSIGN(KioskAppDataBase); |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_DATA_BASE_H_ |