Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Side by Side Diff: chrome/browser/chromeos/contacts/contact_manager.h

Issue 10542076: ABANDONED: chromeos: Download contacts (work in progress). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor changes Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/observer_list.h"
14 #include "base/stl_util.h"
15 #include "chrome/browser/chromeos/contacts/contact_source_observer.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18
19 class Profile;
20
21 namespace contacts {
22
23 struct Contact;
24 typedef std::vector<const Contact*> ContactPointers;
25
26 class ContactManagerObserver;
27 class GoogleContactSource;
28
29 // Singleton class that stores contacts.
30 class ContactManager : public ContactSourceObserver,
31 public content::NotificationObserver {
32 public:
33 static ContactManager* GetInstance();
34
35 ContactManager();
36 ~ContactManager();
37
38 void Init();
39
40 void AddObserver(ContactManagerObserver* observer);
41 void RemoveObserver(ContactManagerObserver* observer);
42
43 // Clears |contacts| and fills it with all currently-loaded contacts.
44 // Ownership of the underlying Contact objects remains with ContactManager.
45 // Moreover, the returned Contact objects may not persist indefinitely; the
46 // caller must not refer to them again after unblocking the UI thread.
47 void GetAllContacts(ContactPointers* contacts);
48
49 // Returns the contact identified by |provider_id|.
50 // NULL is returned if the contact doesn't exist.
51 // FIXME: Find a better way of doing this?
52 const Contact* GetContactByProviderId(const std::string& provider_id);
53
54 // ContactSourceObserver overrides:
55 virtual void OnContactsUpdated(ContactSource* source) OVERRIDE;
56
57 // content::NotificationObserver overrides:
58 virtual void Observe(int type,
59 const content::NotificationSource& source,
60 const content::NotificationDetails& details) OVERRIDE;
61
62 private:
63 typedef std::map<Profile*, GoogleContactSource*> GoogleContactSourceMap;
64
65 // Singleton instance.
66 static ContactManager* instance_;
67
68 ObserverList<ContactManagerObserver> observers_;
69
70 // Maps from a profile to a source for getting the profile's Google-stored
71 // contacts.
72 GoogleContactSourceMap google_contact_sources_;
73
74 // Deletes values in |google_contact_sources_|.
75 STLValueDeleter<GoogleContactSourceMap> google_contact_sources_deleter_;
76
77 content::NotificationRegistrar registrar_;
78
79 DISALLOW_COPY_AND_ASSIGN(ContactManager);
80 };
81
82 } // namespace contacts
83
84 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_database_unittest.cc ('k') | chrome/browser/chromeos/contacts/contact_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698