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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autocomplete/contact_provider_chromeos.h
diff --git a/chrome/browser/autocomplete/contact_provider_chromeos.h b/chrome/browser/autocomplete/contact_provider_chromeos.h
new file mode 100644
index 0000000000000000000000000000000000000000..d11693c956e945a0d595a97605e75962cdb87e0b
--- /dev/null
+++ b/chrome/browser/autocomplete/contact_provider_chromeos.h
@@ -0,0 +1,93 @@
+// 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_AUTOCOMPLETE_CONTACT_PROVIDER_CHROMEOS_H_
+#define CHROME_BROWSER_AUTOCOMPLETE_CONTACT_PROVIDER_CHROMEOS_H_
+
+#include <utility>
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/memory/weak_ptr.h"
+#include "base/string16.h"
+#include "chrome/browser/autocomplete/autocomplete_match.h"
+#include "chrome/browser/autocomplete/autocomplete_provider.h"
+#include "chrome/browser/chromeos/contacts/contact_manager_observer.h"
+
+class AutocompleteInput;
+
+namespace contacts {
+class ContactManagerInterface;
+}
+
+// AutocompleteProvider implementation that searches through the contacts
+// provided by contacts::ContactManager.
+class ContactProvider : public AutocompleteProvider,
+ public contacts::ContactManagerObserver {
+ public:
+ typedef std::pair<size_t, size_t> MatchSpan;
+ typedef std::vector<MatchSpan> MatchSpans;
+
+ // Key within AutocompleteMatch::additional_info where the corresponding
+ // contact's ID is stored.
+ static const char kMatchContactIdKey[];
+
+ class TestAPI {
+ public:
+ explicit TestAPI(ContactProvider* provider);
+ ~TestAPI();
+
+ // Runs the FillACMatchClassifications() function.
+ static AutocompleteMatch::ACMatchClassifications
+ RunFillACMatchClassifications(
+ const MatchSpans& match_spans,
+ size_t text_length);
+
+ private:
+ ContactProvider* provider_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestAPI);
+ };
+
+ ContactProvider(
+ AutocompleteProviderListener* listener,
+ Profile* profile,
+ base::WeakPtr<contacts::ContactManagerInterface> contact_manager);
+
+ // AutocompleteProvider overrides:
+ virtual void Start(const AutocompleteInput& input,
+ bool minimal_changes) OVERRIDE;
+
+ // contacts::ContactManagerObserver overrides:
+ virtual void OnContactsUpdated(Profile* profile) OVERRIDE;
+
+ private:
+ struct ContactData;
+ typedef std::vector<ContactData> ContactDataVector;
+
+ virtual ~ContactProvider();
+
+ // Updates |contacts_| to match the contacts currently reported by
+ // ContactManager.
+ void RefreshContacts();
+
+ // Returns an AutocompleteMatch object corresponding to the passed-in data.
+ // |match_spans| contains sorted (but possibly overlapping) [index, length]
+ // pairs describing the spans within |contact.full_name| that were matched by
+ // |input|.
+ AutocompleteMatch CreateAutocompleteMatch(
+ const AutocompleteInput& input,
+ const ContactData& contact,
+ const MatchSpans& match_spans);
+
+ base::WeakPtr<contacts::ContactManagerInterface> contact_manager_;
+
+ // Contacts through which we search.
+ ContactDataVector contacts_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContactProvider);
+};
+
+#endif // CHROME_BROWSER_AUTOCOMPLETE_CONTACT_PROVIDER_CHROMEOS_H_
« 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