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 #include "chrome/browser/chromeos/contacts/contact_manager.h" | 5 #include "chrome/browser/chromeos/contacts/contact_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/chromeos/contacts/contact.pb.h" | 9 #include "chrome/browser/chromeos/contacts/contact.pb.h" |
10 #include "chrome/browser/chromeos/contacts/contact_manager_observer.h" | 10 #include "chrome/browser/chromeos/contacts/contact_manager_observer.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 scoped_ptr<ContactPointers> ContactManager::GetAllContacts(Profile* profile) { | 99 scoped_ptr<ContactPointers> ContactManager::GetAllContacts(Profile* profile) { |
100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
101 DCHECK(profile); | 101 DCHECK(profile); |
102 scoped_ptr<ContactPointers> contacts(new ContactPointers); | 102 scoped_ptr<ContactPointers> contacts(new ContactPointers); |
103 ContactStoreMap::const_iterator it = contact_stores_.find(profile); | 103 ContactStoreMap::const_iterator it = contact_stores_.find(profile); |
104 if (it != contact_stores_.end()) | 104 if (it != contact_stores_.end()) |
105 it->second->AppendContacts(contacts.get()); | 105 it->second->AppendContacts(contacts.get()); |
106 return contacts.Pass(); | 106 return contacts.Pass(); |
107 } | 107 } |
108 | 108 |
109 const Contact* ContactManager::GetContactByProviderId( | 109 const Contact* ContactManager::GetContactById(Profile* profile, |
110 Profile* profile, | 110 const std::string& contact_id) { |
111 const std::string& provider_id) { | |
112 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 111 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
113 DCHECK(profile); | 112 DCHECK(profile); |
114 ContactStoreMap::const_iterator it = contact_stores_.find(profile); | 113 ContactStoreMap::const_iterator it = contact_stores_.find(profile); |
115 return it != contact_stores_.end() ? | 114 return it != contact_stores_.end() ? |
116 it->second->GetContactByProviderId(provider_id) : | 115 it->second->GetContactById(contact_id) : |
117 NULL; | 116 NULL; |
118 } | 117 } |
119 | 118 |
120 void ContactManager::OnContactsUpdated(ContactStore* store) { | 119 void ContactManager::OnContactsUpdated(ContactStore* store) { |
121 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 120 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
122 for (ContactStoreMap::const_iterator it = contact_stores_.begin(); | 121 for (ContactStoreMap::const_iterator it = contact_stores_.begin(); |
123 it != contact_stores_.end(); ++it) { | 122 it != contact_stores_.end(); ++it) { |
124 if (it->second == store) { | 123 if (it->second == store) { |
125 Profile* profile = it->first; | 124 Profile* profile = it->first; |
126 Observers* observers = GetObserversForProfile(profile, false); | 125 Observers* observers = GetObserversForProfile(profile, false); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 200 } |
202 | 201 |
203 ProfileObserversMap::iterator observer_it = profile_observers_.find(profile); | 202 ProfileObserversMap::iterator observer_it = profile_observers_.find(profile); |
204 if (observer_it != profile_observers_.end()) { | 203 if (observer_it != profile_observers_.end()) { |
205 delete observer_it->second; | 204 delete observer_it->second; |
206 profile_observers_.erase(observer_it); | 205 profile_observers_.erase(observer_it); |
207 } | 206 } |
208 } | 207 } |
209 | 208 |
210 } // namespace contacts | 209 } // namespace contacts |
OLD | NEW |