| 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 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/chromeos/contacts/contact_store.h" | 8 #include "chrome/browser/chromeos/contacts/contact_store.h" |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 // ContactStoreFactory implementation that returns FakeContactStores. | 66 // ContactStoreFactory implementation that returns FakeContactStores. |
| 67 class FakeContactStoreFactory : public ContactStoreFactory { | 67 class FakeContactStoreFactory : public ContactStoreFactory { |
| 68 public: | 68 public: |
| 69 FakeContactStoreFactory(); | 69 FakeContactStoreFactory(); |
| 70 virtual ~FakeContactStoreFactory(); | 70 virtual ~FakeContactStoreFactory(); |
| 71 | 71 |
| 72 void set_permit_store_creation(bool permit) { | 72 void set_permit_store_creation(bool permit) { |
| 73 permit_store_creation_ = permit; | 73 permit_store_creation_ = permit; |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Returns the FakeContactStore previously created for |profile|. | 76 // Returns the FakeContactStore previously created for |profile|, or NULL if |
| 77 // no store has been created for it. |
| 77 FakeContactStore* GetContactStoreForProfile(Profile* profile); | 78 FakeContactStore* GetContactStoreForProfile(Profile* profile); |
| 78 | 79 |
| 79 // Removes |store| from |stores_| after being called by a FakeContactStore's | 80 // Removes |store| from |stores_| after being called by a FakeContactStore's |
| 80 // d'tor. | 81 // d'tor. |
| 81 void RemoveStore(FakeContactStore* store); | 82 void RemoveStore(FakeContactStore* store); |
| 82 | 83 |
| 83 // ContactStoreFactory implementation: | 84 // ContactStoreFactory implementation: |
| 84 virtual bool CanCreateContactStoreForProfile(Profile* profile) OVERRIDE; | 85 virtual bool CanCreateContactStoreForProfile(Profile* profile) OVERRIDE; |
| 85 virtual ContactStore* CreateContactStore(Profile* profile) OVERRIDE; | 86 virtual ContactStore* CreateContactStore(Profile* profile) OVERRIDE; |
| 86 | 87 |
| 87 private: | 88 private: |
| 88 typedef std::map<Profile*, FakeContactStore*> ProfileStoreMap; | 89 typedef std::map<Profile*, FakeContactStore*> ProfileStoreMap; |
| 89 | 90 |
| 90 // Live FakeContactStore objects that we've handed out. We don't retain | 91 // Live FakeContactStore objects that we've handed out. We don't retain |
| 91 // ownership of these, but we hang on to the pointers so that tests can | 92 // ownership of these, but we hang on to the pointers so that tests can |
| 92 // manipulate the stores while they're in use. | 93 // manipulate the stores while they're in use. |
| 93 ProfileStoreMap stores_; | 94 ProfileStoreMap stores_; |
| 94 | 95 |
| 95 // Should CanCreateContactStoreForProfile() return true? | 96 // Should CanCreateContactStoreForProfile() return true? |
| 96 bool permit_store_creation_; | 97 bool permit_store_creation_; |
| 97 | 98 |
| 98 DISALLOW_COPY_AND_ASSIGN(FakeContactStoreFactory); | 99 DISALLOW_COPY_AND_ASSIGN(FakeContactStoreFactory); |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 } // namespace contacts | 102 } // namespace contacts |
| 102 | 103 |
| 103 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ | 104 #endif // CHROME_BROWSER_CHROMEOS_CONTACTS_FAKE_CONTACT_STORE_H_ |
| OLD | NEW |