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

Side by Side Diff: chrome/browser/autocomplete/contact_provider_chromeos.h

Issue 10542076: ABANDONED: chromeos: Download contacts (work in progress). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ContactProvider cleanup and tests Created 8 years, 3 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_AUTOCOMPLETE_CONTACT_PROVIDER_CHROMEOS_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_CONTACT_PROVIDER_CHROMEOS_H_
7
8 #include <utility>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/string16.h"
15 #include "chrome/browser/autocomplete/autocomplete_match.h"
16 #include "chrome/browser/autocomplete/autocomplete_provider.h"
17 #include "chrome/browser/chromeos/contacts/contact_manager_observer.h"
18
19 class AutocompleteInput;
20
21 namespace contacts {
22 class ContactManagerInterface;
23 }
24
25 // AutocompleteProvider implementation that searches through the contacts
26 // provided by contacts::ContactManager.
27 class ContactProvider : public AutocompleteProvider,
28 public contacts::ContactManagerObserver {
29 public:
30 typedef std::pair<size_t, size_t> MatchSpan;
31 typedef std::vector<MatchSpan> MatchSpans;
32
33 // Key within AutocompleteMatch::additional_info where the corresponding
34 // contact's ID is stored.
35 static const char kMatchContactIdKey[];
36
37 class TestAPI {
38 public:
39 explicit TestAPI(ContactProvider* provider);
40 ~TestAPI();
41
42 // Runs the FillACMatchClassifications() function.
43 static AutocompleteMatch::ACMatchClassifications
44 RunFillACMatchClassifications(
45 const MatchSpans& match_spans,
46 size_t text_length);
47
48 private:
49 ContactProvider* provider_;
50
51 DISALLOW_COPY_AND_ASSIGN(TestAPI);
52 };
53
54 ContactProvider(
55 AutocompleteProviderListener* listener,
56 Profile* profile,
57 base::WeakPtr<contacts::ContactManagerInterface> contact_manager);
58
59 // AutocompleteProvider overrides:
60 virtual void Start(const AutocompleteInput& input,
61 bool minimal_changes) OVERRIDE;
62
63 // contacts::ContactManagerObserver overrides:
64 virtual void OnContactsUpdated(Profile* profile) OVERRIDE;
65
66 private:
67 struct ContactData;
68 typedef std::vector<ContactData> ContactDataVector;
69
70 virtual ~ContactProvider();
71
72 // Updates |contacts_| to match the contacts currently reported by
73 // ContactManager.
74 void RefreshContacts();
75
76 // Returns an AutocompleteMatch object corresponding to the passed-in data.
77 // |match_spans| contains sorted (but possibly overlapping) [index, length]
78 // pairs describing the spans within |contact.full_name| that were matched by
79 // |input|.
80 AutocompleteMatch CreateAutocompleteMatch(
81 const AutocompleteInput& input,
82 const ContactData& contact,
83 const MatchSpans& match_spans);
84
85 base::WeakPtr<contacts::ContactManagerInterface> contact_manager_;
86
87 // Contacts through which we search.
88 ContactDataVector contacts_;
89
90 DISALLOW_COPY_AND_ASSIGN(ContactProvider);
91 };
92
93 #endif // CHROME_BROWSER_AUTOCOMPLETE_CONTACT_PROVIDER_CHROMEOS_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_match.cc ('k') | chrome/browser/autocomplete/contact_provider_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698