Home | History | Annotate | Download | only in autocomplete
      1 // Copyright 2014 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 // KeywordExtensionsDelegate contains the extensions-only logic used by
      6 // KeywordProvider.
      7 // This file contains the dummy implementation of KeywordExtensionsDelegate,
      8 // which does nothing.
      9 
     10 #ifndef CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_EXTENSIONS_DELEGATE_H_
     11 #define CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_EXTENSIONS_DELEGATE_H_
     12 
     13 #include <string>
     14 
     15 #include "base/basictypes.h"
     16 #include "base/macros.h"
     17 #include "base/strings/string16.h"
     18 
     19 class AutocompleteInput;
     20 class KeywordProvider;
     21 class Profile;
     22 class TemplateURL;
     23 
     24 class KeywordExtensionsDelegate {
     25  public:
     26   explicit KeywordExtensionsDelegate(KeywordProvider* provider);
     27   virtual ~KeywordExtensionsDelegate();
     28 
     29   // Increments the input ID used to identify if the suggest results from an
     30   // extension are current.
     31   virtual void IncrementInputId();
     32 
     33   // Returns true if an extension is enabled in a given profile.
     34   virtual bool IsEnabledExtension(Profile* profile,
     35                                   const std::string& extension_id);
     36 
     37   // Handles the extensions portion of KeywordProvider::Start().
     38   // Depending on |minimal_changes| and whether |input| wants matches
     39   // synchronous or not, either updates the KeywordProvider's matches with
     40   // the existing suggestions or asks the |template_url|'s extension to provide
     41   // matches.
     42   // Returns true if this delegate should stay in extension keyword mode.
     43   virtual bool Start(const AutocompleteInput& input,
     44                      bool minimal_changes,
     45                      const TemplateURL* template_url,
     46                      const base::string16& remaining_input);
     47 
     48   // Tells the extension with |extension_id| that the user typed the omnibox
     49   // keyword.
     50   virtual void EnterExtensionKeywordMode(const std::string& extension_id);
     51 
     52   // If an extension previously entered extension keyword mode, exits extension
     53   // keyword mode. This happens when the user has cleared the keyword or closed
     54   // the omnibox popup.
     55   virtual void MaybeEndExtensionKeywordMode();
     56 
     57  private:
     58   DISALLOW_COPY_AND_ASSIGN(KeywordExtensionsDelegate);
     59 };
     60 
     61 #endif  // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_EXTENSIONS_DELEGATE_H_
     62