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

Side by Side Diff: chrome/browser/chromeos/contacts/contact_manager_stub.cc

Issue 190063004: chromeos: Delete old, unused contacts code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge again Created 6 years, 9 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 #include "chrome/browser/chromeos/contacts/contact_manager_stub.h"
6
7 #include "base/logging.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/chromeos/contacts/contact.pb.h"
10 #include "chrome/browser/chromeos/contacts/contact_manager_observer.h"
11 #include "chrome/browser/chromeos/contacts/contact_test_util.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "content/public/browser/browser_thread.h"
14
15 using content::BrowserThread;
16
17 namespace contacts {
18
19 ContactManagerStub::ContactManagerStub(Profile* profile)
20 : profile_(profile),
21 weak_ptr_factory_(this) {
22 }
23
24 ContactManagerStub::~ContactManagerStub() {}
25
26 void ContactManagerStub::NotifyObserversAboutUpdatedContacts() {
27 FOR_EACH_OBSERVER(ContactManagerObserver,
28 observers_,
29 OnContactsUpdated(profile_));
30 }
31
32 void ContactManagerStub::SetContacts(const ContactPointers& contacts) {
33 test::CopyContacts(contacts, &contacts_);
34 }
35
36 base::WeakPtr<ContactManagerInterface> ContactManagerStub::GetWeakPtr() {
37 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
38 return weak_ptr_factory_.GetWeakPtr();
39 }
40
41 void ContactManagerStub::AddObserver(ContactManagerObserver* observer,
42 Profile* profile) {
43 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
44 CHECK(observer);
45 CHECK_EQ(profile, profile_);
46 CHECK(!observers_.HasObserver(observer));
47 observers_.AddObserver(observer);
48 }
49
50 void ContactManagerStub::RemoveObserver(ContactManagerObserver* observer,
51 Profile* profile) {
52 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
53 CHECK(observer);
54 CHECK_EQ(profile, profile_);
55 CHECK(observers_.HasObserver(observer));
56 observers_.RemoveObserver(observer);
57 }
58
59 scoped_ptr<ContactPointers> ContactManagerStub::GetAllContacts(
60 Profile* profile) {
61 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
62 CHECK_EQ(profile, profile_);
63 scoped_ptr<ContactPointers> contacts(new ContactPointers);
64 for (size_t i = 0; i < contacts_.size(); ++i)
65 contacts->push_back(contacts_[i]);
66 return contacts.Pass();
67 }
68
69 const Contact* ContactManagerStub::GetContactById(
70 Profile* profile,
71 const std::string& contact_id) {
72 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
73 CHECK_EQ(profile, profile_);
74 for (size_t i = 0; i < contacts_.size(); ++i) {
75 if (contacts_[i]->contact_id() == contact_id)
76 return contacts_[i];
77 }
78 return NULL;
79 }
80
81 } // namespace contacts
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/contacts/contact_manager_stub.h ('k') | chrome/browser/chromeos/contacts/contact_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698