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