| Index: chrome/browser/chromeos/contacts/contact_manager.h
|
| diff --git a/chrome/browser/chromeos/contacts/contact_manager.h b/chrome/browser/chromeos/contacts/contact_manager.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..362300cfff4c6cb499e8eaeab18a4f184b51daad
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/contacts/contact_manager.h
|
| @@ -0,0 +1,84 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_H_
|
| +#define CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_H_
|
| +
|
| +#include <map>
|
| +#include <vector>
|
| +
|
| +#include "base/basictypes.h"
|
| +#include "base/compiler_specific.h"
|
| +#include "base/observer_list.h"
|
| +#include "base/stl_util.h"
|
| +#include "chrome/browser/chromeos/contacts/contact_source_observer.h"
|
| +#include "content/public/browser/notification_observer.h"
|
| +#include "content/public/browser/notification_registrar.h"
|
| +
|
| +class Profile;
|
| +
|
| +namespace contacts {
|
| +
|
| +struct Contact;
|
| +typedef std::vector<const Contact*> ContactPointers;
|
| +
|
| +class ContactManagerObserver;
|
| +class GoogleContactSource;
|
| +
|
| +// Singleton class that stores contacts.
|
| +class ContactManager : public ContactSourceObserver,
|
| + public content::NotificationObserver {
|
| + public:
|
| + static ContactManager* GetInstance();
|
| +
|
| + ContactManager();
|
| + ~ContactManager();
|
| +
|
| + void Init();
|
| +
|
| + void AddObserver(ContactManagerObserver* observer);
|
| + void RemoveObserver(ContactManagerObserver* observer);
|
| +
|
| + // Clears |contacts| and fills it with all currently-loaded contacts.
|
| + // Ownership of the underlying Contact objects remains with ContactManager.
|
| + // Moreover, the returned Contact objects may not persist indefinitely; the
|
| + // caller must not refer to them again after unblocking the UI thread.
|
| + void GetAllContacts(ContactPointers* contacts);
|
| +
|
| + // Returns the contact identified by |provider_id|.
|
| + // NULL is returned if the contact doesn't exist.
|
| + // FIXME: Find a better way of doing this?
|
| + const Contact* GetContactByProviderId(const std::string& provider_id);
|
| +
|
| + // ContactSourceObserver overrides:
|
| + virtual void OnContactsUpdated(ContactSource* source) OVERRIDE;
|
| +
|
| + // content::NotificationObserver overrides:
|
| + virtual void Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) OVERRIDE;
|
| +
|
| + private:
|
| + typedef std::map<Profile*, GoogleContactSource*> GoogleContactSourceMap;
|
| +
|
| + // Singleton instance.
|
| + static ContactManager* instance_;
|
| +
|
| + ObserverList<ContactManagerObserver> observers_;
|
| +
|
| + // Maps from a profile to a source for getting the profile's Google-stored
|
| + // contacts.
|
| + GoogleContactSourceMap google_contact_sources_;
|
| +
|
| + // Deletes values in |google_contact_sources_|.
|
| + STLValueDeleter<GoogleContactSourceMap> google_contact_sources_deleter_;
|
| +
|
| + content::NotificationRegistrar registrar_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ContactManager);
|
| +};
|
| +
|
| +} // namespace contacts
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_CONTACTS_CONTACT_MANAGER_H_
|
|
|