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.
5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_
11 #include "base/basictypes.h"
18 typedef std::vector
<const Contact
*> ContactPointers
;
19 class ContactStoreObserver
;
21 // Interface for classes that store contacts from a particular source.
25 virtual ~ContactStore() {}
27 // Initializes the object.
28 virtual void Init() = 0;
30 // Appends all (non-deleted) contacts to |contacts_out|.
31 virtual void AppendContacts(ContactPointers
* contacts_out
) = 0;
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;
37 // Adds or removes an observer.
38 virtual void AddObserver(ContactStoreObserver
* observer
) = 0;
39 virtual void RemoveObserver(ContactStoreObserver
* observer
) = 0;
42 DISALLOW_COPY_AND_ASSIGN(ContactStore
);
45 // Interface for factories that return ContactStore objects of a given type.
46 class ContactStoreFactory
{
48 ContactStoreFactory() {}
49 virtual ~ContactStoreFactory() {}
51 // Does |profile| support this type of ContactStore?
52 virtual bool CanCreateContactStoreForProfile(Profile
* profile
) = 0;
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;
62 DISALLOW_COPY_AND_ASSIGN(ContactStoreFactory
);
65 } // namespace contacts
67 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_STORE_H_