OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 | 12 |
| 13 class Profile; |
| 14 |
13 namespace contacts { | 15 namespace contacts { |
14 | 16 |
15 class Contact; | 17 class Contact; |
16 typedef std::vector<const Contact*> ContactPointers; | 18 typedef std::vector<const Contact*> ContactPointers; |
17 class ContactStoreObserver; | 19 class ContactStoreObserver; |
18 | 20 |
19 // Interface for classes that store contacts from a particular source. | 21 // Interface for classes that store contacts from a particular source. |
20 class ContactStore { | 22 class ContactStore { |
21 public: | 23 public: |
22 ContactStore() {} | 24 ContactStore() {} |
23 virtual ~ContactStore() {} | 25 virtual ~ContactStore() {} |
24 | 26 |
| 27 // Initializes the object. |
| 28 virtual void Init() = 0; |
| 29 |
25 // Appends all (non-deleted) contacts to |contacts_out|. | 30 // Appends all (non-deleted) contacts to |contacts_out|. |
26 virtual void AppendContacts(ContactPointers* contacts_out) = 0; | 31 virtual void AppendContacts(ContactPointers* contacts_out) = 0; |
27 | 32 |
28 // Returns the contact identified by |provider_id|. | 33 // Returns the contact identified by |provider_id|. |
29 // NULL is returned if the contact doesn't exist. | 34 // NULL is returned if the contact doesn't exist. |
30 virtual const Contact* GetContactByProviderId( | 35 virtual const Contact* GetContactByProviderId( |
31 const std::string& provider_id) = 0; | 36 const std::string& provider_id) = 0; |
32 | 37 |
33 // Adds or removes an observer. | 38 // Adds or removes an observer. |
34 virtual void AddObserver(ContactStoreObserver* observer) = 0; | 39 virtual void AddObserver(ContactStoreObserver* observer) = 0; |
35 virtual void RemoveObserver(ContactStoreObserver* observer) = 0; | 40 virtual void RemoveObserver(ContactStoreObserver* observer) = 0; |
36 | 41 |
37 private: | 42 private: |
38 DISALLOW_COPY_AND_ASSIGN(ContactStore); | 43 DISALLOW_COPY_AND_ASSIGN(ContactStore); |
39 }; | 44 }; |
40 | 45 |
| 46 // Interface for factories that return ContactStore objects of a given type. |
| 47 class ContactStoreFactory { |
| 48 public: |
| 49 ContactStoreFactory() {} |
| 50 virtual ~ContactStoreFactory() {} |
| 51 |
| 52 // Creates and returns a new, uninitialized ContactStore for |profile|. |
| 53 // TODO(derat): Figure out how this should work if/when there are other |
| 54 // ContactStore implementations that need additional information beyond the |
| 55 // stuff contained in a Profile. |
| 56 virtual ContactStore* CreateContactStore(Profile* profile) = 0; |
| 57 |
| 58 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(ContactStoreFactory); |
| 60 }; |
| 61 |
41 } // namespace contacts | 62 } // namespace contacts |
42 | 63 |
43 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_ | 64 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_ |
OLD | NEW |