history_provider.h revision a02191e04bc25c4935f804f2c080ae28663d096d
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/compiler_specific.h"
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "chrome/browser/autocomplete/autocomplete_provider.h"
10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "chrome/browser/history/in_memory_url_index_types.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class AutocompleteInput;
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct AutocompleteMatch;
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This class is a base class for the history autocomplete providers and
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// provides functions useful to all derived classes.
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class HistoryProvider : public AutocompleteProvider {
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE;
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
21a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // Returns true if inline autocompletion should be prevented for URL-like
22a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // input.  This method returns true if input.prevent_inline_autocomplete()
23a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // is true or the input text contains trailing whitespace.
24a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  static bool PreventInlineAutocomplete(const AutocompleteInput& input);
25a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  HistoryProvider(AutocompleteProviderListener* listener,
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                  Profile* profile,
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                  AutocompleteProvider::Type type);
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~HistoryProvider();
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Finds and removes the match from the current collection of matches and
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // backing data.
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DeleteMatchFromMatches(const AutocompleteMatch& match);
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
36f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Fill and return an ACMatchClassifications structure given the |matches|
37f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // to highlight.
38f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  static ACMatchClassifications SpansFromTermMatch(
39f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const history::TermMatches& matches,
40f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      size_t text_length,
41f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      bool is_url);
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_
45