| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_ | 5 #ifndef COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_ |
| 6 #define COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_ | 6 #define COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "components/webdata/common/web_database.h" | 11 #include "components/webdata/common/web_database.h" |
| 12 #include "components/webdata/common/web_database_table.h" | 12 #include "components/webdata/common/web_database_table.h" |
| 13 | 13 |
| 14 namespace payments { | 14 namespace payments { |
| 15 | 15 |
| 16 // This class manages payment_method_manifest table in SQLite database. It | 16 // This class manages payment_method_manifest table in SQLite database. It |
| 17 // expects the following schema. | 17 // expects the following schema. |
| 18 // | 18 // |
| 19 // payment_method_manifest The table stores WebAppManifestSection.id of the | 19 // payment_method_manifest The table stores WebAppManifestSection.id of the |
| 20 // supported web app in this payment method manifest. | 20 // supported web app in this payment method manifest. |
| 21 // Note that a payment method manifest might contain | 21 // Note that a payment method manifest might contain |
| 22 // multiple supported web apps ids. | 22 // multiple supported web apps ids. |
| 23 // |
| 24 // expire_date The expire date in seconds from 1601-01-01 00:00:00 |
| 25 // UTC. |
| 23 // method_name The method name. | 26 // method_name The method name. |
| 24 // web_app_id The supported web app id. | 27 // web_app_id The supported web app id. |
| 25 // (WebAppManifestSection.id). | 28 // (WebAppManifestSection.id). |
| 26 // | 29 // |
| 27 class PaymentMethodManifestTable : public WebDatabaseTable { | 30 class PaymentMethodManifestTable : public WebDatabaseTable { |
| 28 public: | 31 public: |
| 29 PaymentMethodManifestTable(); | 32 PaymentMethodManifestTable(); |
| 30 ~PaymentMethodManifestTable() override; | 33 ~PaymentMethodManifestTable() override; |
| 31 | 34 |
| 32 // Retrieves the PaymentMethodManifestTable* owned by |db|. | 35 // Retrieves the PaymentMethodManifestTable* owned by |db|. |
| 33 static PaymentMethodManifestTable* FromWebDatabase(WebDatabase* db); | 36 static PaymentMethodManifestTable* FromWebDatabase(WebDatabase* db); |
| 34 | 37 |
| 35 // WebDatabaseTable: | 38 // WebDatabaseTable: |
| 36 WebDatabaseTable::TypeKey GetTypeKey() const override; | 39 WebDatabaseTable::TypeKey GetTypeKey() const override; |
| 37 bool CreateTablesIfNecessary() override; | 40 bool CreateTablesIfNecessary() override; |
| 38 bool IsSyncable() override; | 41 bool IsSyncable() override; |
| 39 bool MigrateToVersion(int version, bool* update_compatible_version) override; | 42 bool MigrateToVersion(int version, bool* update_compatible_version) override; |
| 40 | 43 |
| 44 // Remove expired data. |
| 45 void RemoveExpiredData(); |
| 46 |
| 41 // Adds |payment_method|'s manifest. |web_app_ids| contains supported web apps | 47 // Adds |payment_method|'s manifest. |web_app_ids| contains supported web apps |
| 42 // ids. | 48 // ids. |
| 43 bool AddManifest(const std::string& payment_method, | 49 bool AddManifest(const std::string& payment_method, |
| 44 const std::vector<std::string>& web_app_ids); | 50 const std::vector<std::string>& web_app_ids); |
| 45 | 51 |
| 46 // Gets manifest for |payment_method|. Return empty vector if no manifest | 52 // Gets manifest for |payment_method|. Return empty vector if no manifest |
| 47 // exists for this method. | 53 // exists for this method. |
| 48 std::vector<std::string> GetManifest(const std::string& payment_method); | 54 std::vector<std::string> GetManifest(const std::string& payment_method); |
| 49 | 55 |
| 50 private: | 56 private: |
| 51 DISALLOW_COPY_AND_ASSIGN(PaymentMethodManifestTable); | 57 DISALLOW_COPY_AND_ASSIGN(PaymentMethodManifestTable); |
| 52 }; | 58 }; |
| 53 | 59 |
| 54 } // namespace payments | 60 } // namespace payments |
| 55 | 61 |
| 56 #endif // COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_ | 62 #endif // COMPONENTS_PAYMENTS_ANDROID_PAYMENT_METHOD_MANIFEST_TABLE_H_ |
| OLD | NEW |