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"
9f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)#include "chrome/browser/history/in_memory_url_index_types.h"
105f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "components/omnibox/autocomplete_provider.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class AutocompleteInput;
13116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass Profile;
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct AutocompleteMatch;
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This class is a base class for the history autocomplete providers and
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// provides functions useful to all derived classes.
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class HistoryProvider : public AutocompleteProvider {
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void DeleteMatch(const AutocompleteMatch& match) OVERRIDE;
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
22a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // Returns true if inline autocompletion should be prevented for URL-like
23a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // input.  This method returns true if input.prevent_inline_autocomplete()
24a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  // is true or the input text contains trailing whitespace.
25a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  static bool PreventInlineAutocomplete(const AutocompleteInput& input);
26a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected:
28116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  HistoryProvider(Profile* profile, AutocompleteProvider::Type type);
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~HistoryProvider();
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Finds and removes the match from the current collection of matches and
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // backing data.
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  void DeleteMatchFromMatches(const AutocompleteMatch& match);
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
35f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // Fill and return an ACMatchClassifications structure given the |matches|
36f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  // to highlight.
37f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  static ACMatchClassifications SpansFromTermMatch(
38f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      const history::TermMatches& matches,
39f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      size_t text_length,
40f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)      bool is_url);
41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  Profile* profile_;
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_H_
46