| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/scoped_vector.h" | |
| 16 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 17 #include "components/webdata/common/web_database_table.h" | 16 #include "components/webdata/common/web_database_table.h" |
| 18 | 17 |
| 19 class WebDatabase; | 18 class WebDatabase; |
| 20 | 19 |
| 21 namespace base { | 20 namespace base { |
| 22 class Time; | 21 class Time; |
| 23 } | 22 } |
| 24 | 23 |
| 25 namespace autofill { | 24 namespace autofill { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 // Updates the database values for the specified profile. Mulit-value aware. | 309 // Updates the database values for the specified profile. Mulit-value aware. |
| 311 virtual bool UpdateAutofillProfile(const AutofillProfile& profile); | 310 virtual bool UpdateAutofillProfile(const AutofillProfile& profile); |
| 312 | 311 |
| 313 // Removes a row from the autofill_profiles table. |guid| is the identifier | 312 // Removes a row from the autofill_profiles table. |guid| is the identifier |
| 314 // of the profile to remove. | 313 // of the profile to remove. |
| 315 virtual bool RemoveAutofillProfile(const std::string& guid); | 314 virtual bool RemoveAutofillProfile(const std::string& guid); |
| 316 | 315 |
| 317 // Retrieves a profile with guid |guid|. | 316 // Retrieves a profile with guid |guid|. |
| 318 std::unique_ptr<AutofillProfile> GetAutofillProfile(const std::string& guid); | 317 std::unique_ptr<AutofillProfile> GetAutofillProfile(const std::string& guid); |
| 319 | 318 |
| 320 // Retrieves local/server profiles in the database. Caller owns the returned | 319 // Retrieves local/server profiles in the database. |
| 321 // profiles. | 320 virtual bool GetAutofillProfiles( |
| 322 // TODO(thestig): Convert to scopers. | 321 std::vector<std::unique_ptr<AutofillProfile>>* profiles); |
| 323 virtual bool GetAutofillProfiles(std::vector<AutofillProfile*>* profiles); | 322 virtual bool GetServerProfiles( |
| 324 virtual bool GetServerProfiles(std::vector<AutofillProfile*>* profiles); | 323 std::vector<std::unique_ptr<AutofillProfile>>* profiles); |
| 325 | 324 |
| 326 // Sets the server profiles. All old profiles are deleted and replaced with | 325 // Sets the server profiles. All old profiles are deleted and replaced with |
| 327 // the given ones. | 326 // the given ones. |
| 328 void SetServerProfiles(const std::vector<AutofillProfile>& profiles); | 327 void SetServerProfiles(const std::vector<AutofillProfile>& profiles); |
| 329 | 328 |
| 330 // Records a single credit card in the credit_cards table. | 329 // Records a single credit card in the credit_cards table. |
| 331 bool AddCreditCard(const CreditCard& credit_card); | 330 bool AddCreditCard(const CreditCard& credit_card); |
| 332 | 331 |
| 333 // Updates the database values for the specified credit card. | 332 // Updates the database values for the specified credit card. |
| 334 bool UpdateCreditCard(const CreditCard& credit_card); | 333 bool UpdateCreditCard(const CreditCard& credit_card); |
| 335 | 334 |
| 336 // Removes a row from the credit_cards table. |guid| is the identifer of the | 335 // Removes a row from the credit_cards table. |guid| is the identifier of the |
| 337 // credit card to remove. | 336 // credit card to remove. |
| 338 bool RemoveCreditCard(const std::string& guid); | 337 bool RemoveCreditCard(const std::string& guid); |
| 339 | 338 |
| 340 // Retrieves a credit card with guid |guid|. | 339 // Retrieves a credit card with guid |guid|. |
| 341 std::unique_ptr<CreditCard> GetCreditCard(const std::string& guid); | 340 std::unique_ptr<CreditCard> GetCreditCard(const std::string& guid); |
| 342 | 341 |
| 343 // Retrieves the local/server credit cards in the database. Caller owns the | 342 // Retrieves the local/server credit cards in the database. |
| 344 // returned credit cards. | 343 virtual bool GetCreditCards( |
| 345 // TODO(thestig): Convert to scopers. | 344 std::vector<std::unique_ptr<CreditCard>>* credit_cards); |
| 346 virtual bool GetCreditCards(std::vector<CreditCard*>* credit_cards); | 345 virtual bool GetServerCreditCards( |
| 347 virtual bool GetServerCreditCards(std::vector<CreditCard*>* credit_cards); | 346 std::vector<std::unique_ptr<CreditCard>>* credit_cards); |
| 348 | 347 |
| 349 // Replaces all server credit cards with the given vector. Unmasked cards | 348 // Replaces all server credit cards with the given vector. Unmasked cards |
| 350 // present in the new list will be preserved (even if the input is MASKED). | 349 // present in the new list will be preserved (even if the input is MASKED). |
| 351 void SetServerCreditCards(const std::vector<CreditCard>& credit_cards); | 350 void SetServerCreditCards(const std::vector<CreditCard>& credit_cards); |
| 352 | 351 |
| 353 // Cards synced from the server may be "masked" (only last 4 digits | 352 // Cards synced from the server may be "masked" (only last 4 digits |
| 354 // available) or "unmasked" (everything is available). These functions set | 353 // available) or "unmasked" (everything is available). These functions set |
| 355 // that state. | 354 // that state. |
| 356 bool UnmaskServerCreditCard(const CreditCard& masked, | 355 bool UnmaskServerCreditCard(const CreditCard& masked, |
| 357 const base::string16& full_number); | 356 const base::string16& full_number); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 381 | 380 |
| 382 // Removes origin URLs from the autofill_profiles and credit_cards tables if | 381 // Removes origin URLs from the autofill_profiles and credit_cards tables if |
| 383 // they were written on or after |delete_begin| and strictly before | 382 // they were written on or after |delete_begin| and strictly before |
| 384 // |delete_end|. Returns the list of modified profiles in |profiles|. Return | 383 // |delete_end|. Returns the list of modified profiles in |profiles|. Return |
| 385 // value is true if all rows were successfully updated. Returns false on | 384 // value is true if all rows were successfully updated. Returns false on |
| 386 // database error. In that case, the output vector state is undefined, and | 385 // database error. In that case, the output vector state is undefined, and |
| 387 // may be partially filled. | 386 // may be partially filled. |
| 388 bool RemoveOriginURLsModifiedBetween( | 387 bool RemoveOriginURLsModifiedBetween( |
| 389 const base::Time& delete_begin, | 388 const base::Time& delete_begin, |
| 390 const base::Time& delete_end, | 389 const base::Time& delete_end, |
| 391 ScopedVector<AutofillProfile>* profiles); | 390 std::vector<std::unique_ptr<AutofillProfile>>* profiles); |
| 392 | 391 |
| 393 // Retrieves all profiles in the database that have been deleted since last | 392 // Retrieves all profiles in the database that have been deleted since last |
| 394 // "empty" of the trash. | 393 // "empty" of the trash. |
| 395 bool GetAutofillProfilesInTrash(std::vector<std::string>* guids); | 394 bool GetAutofillProfilesInTrash(std::vector<std::string>* guids); |
| 396 | 395 |
| 397 // Empties the Autofill profiles "trash can". | 396 // Empties the Autofill profiles "trash can". |
| 398 bool EmptyAutofillProfilesTrash(); | 397 bool EmptyAutofillProfilesTrash(); |
| 399 | 398 |
| 400 // Retrieves all profiles in the database that have been deleted since last | 399 // Retrieves all profiles in the database that have been deleted since last |
| 401 // "empty" of the trash. | 400 // "empty" of the trash. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 bool InitServerCardMetadataTable(); | 496 bool InitServerCardMetadataTable(); |
| 498 bool InitServerAddressesTable(); | 497 bool InitServerAddressesTable(); |
| 499 bool InitServerAddressMetadataTable(); | 498 bool InitServerAddressMetadataTable(); |
| 500 | 499 |
| 501 DISALLOW_COPY_AND_ASSIGN(AutofillTable); | 500 DISALLOW_COPY_AND_ASSIGN(AutofillTable); |
| 502 }; | 501 }; |
| 503 | 502 |
| 504 } // namespace autofill | 503 } // namespace autofill |
| 505 | 504 |
| 506 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ | 505 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_WEBDATA_AUTOFILL_TABLE_H_ |
| OLD | NEW |