blob: 0e1f5ef9c884e4fd19400c262d24fa2a525ab052 [file] [log] [blame]
gogerald6d16ea52017-04-13 20:43:281// 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 COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_
6#define COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_
7
8#include <string>
9#include <vector>
10
11#include "components/webdata/common/web_database.h"
12#include "components/webdata/common/web_database_table.h"
13
14namespace payments {
15
16// This class manages payment_method_manifest table in SQLite database. It
17// expects the following schema.
18//
19// payment_method_manifest The table stores WebAppManifestSection.id of the
20// supported web app in this payment method manifest.
21// Note that a payment method manifest might contain
22// multiple supported web apps ids.
23// method_name The method name.
24// web_app_id The supported web app id.
25// (WebAppManifestSection.id).
26//
27class PaymentMethodManifestTable : public WebDatabaseTable {
28 public:
29 PaymentMethodManifestTable();
30 ~PaymentMethodManifestTable() override;
31
32 // Retrieves the PaymentMethodManifestTable* owned by |db|.
33 static PaymentMethodManifestTable* FromWebDatabase(WebDatabase* db);
34
35 // WebDatabaseTable:
36 WebDatabaseTable::TypeKey GetTypeKey() const override;
37 bool CreateTablesIfNecessary() override;
38 bool IsSyncable() override;
39 bool MigrateToVersion(int version, bool* update_compatible_version) override;
40
41 // Adds |payment_method|'s manifest. |web_app_ids| contains supported web apps
42 // ids.
43 bool AddManifest(const std::string& payment_method,
44 const std::vector<std::string>& web_app_ids);
45
46 // Gets manifest for |payment_method|. Return empty vector if no manifest
47 // exists for this method.
48 std::vector<std::string> GetManifest(const std::string& payment_method);
49
50 private:
51 DISALLOW_COPY_AND_ASSIGN(PaymentMethodManifestTable);
52};
53
54} // namespace payments
55
56#endif // COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_