Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / chrome / browser / autocomplete / keyword_extensions_delegate_impl.h
blob047224fc6d47ace5bd591cd2e8838f8485936988
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 // KeywordExtensionsDelegateImpl contains the extensions-only logic used by
6 // KeywordProvider. Overrides KeywordExtensionsDelegate which does nothing.
8 #ifndef CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_EXTENSIONS_DELEGATE_IMPL_H_
9 #define CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_EXTENSIONS_DELEGATE_IMPL_H_
11 #include <vector>
13 #include "base/compiler_specific.h"
14 #include "components/omnibox/browser/autocomplete_input.h"
15 #include "components/omnibox/browser/autocomplete_match.h"
16 #include "components/omnibox/browser/autocomplete_provider_listener.h"
17 #include "components/omnibox/browser/keyword_extensions_delegate.h"
18 #include "components/omnibox/browser/keyword_provider.h"
19 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h"
22 #if !defined(ENABLE_EXTENSIONS)
23 #error "Should not be included when extensions are disabled"
24 #endif
26 class Profile;
28 class KeywordExtensionsDelegateImpl : public KeywordExtensionsDelegate,
29 public content::NotificationObserver {
30 public:
31 KeywordExtensionsDelegateImpl(Profile* profile, KeywordProvider* provider);
32 ~KeywordExtensionsDelegateImpl() override;
34 private:
35 // KeywordExtensionsDelegate:
36 void IncrementInputId() override;
37 bool IsEnabledExtension(const std::string& extension_id) override;
38 bool Start(const AutocompleteInput& input,
39 bool minimal_changes,
40 const TemplateURL* template_url,
41 const base::string16& remaining_input) override;
42 void EnterExtensionKeywordMode(const std::string& extension_id) override;
43 void MaybeEndExtensionKeywordMode() override;
45 // content::NotificationObserver:
46 void Observe(int type,
47 const content::NotificationSource& source,
48 const content::NotificationDetails& details) override;
50 ACMatches* matches() { return &provider_->matches_; }
51 void set_done(bool done) {
52 provider_->done_ = done;
55 // Notifies the KeywordProvider about asynchronous updates from the extension.
56 void OnProviderUpdate(bool updated_matches);
58 // Identifies the current input state. This is incremented each time the
59 // autocomplete edit's input changes in any way. It is used to tell whether
60 // suggest results from the extension are current.
61 int current_input_id_;
63 // The input state at the time we last asked the extension for suggest
64 // results.
65 AutocompleteInput extension_suggest_last_input_;
67 // We remember the last suggestions we've received from the extension in case
68 // we need to reset our matches without asking the extension again.
69 std::vector<AutocompleteMatch> extension_suggest_matches_;
71 // If non-empty, holds the ID of the extension whose keyword is currently in
72 // the URL bar while the autocomplete popup is open.
73 std::string current_keyword_extension_id_;
75 Profile* profile_;
77 // The owner of this class.
78 KeywordProvider* provider_;
80 content::NotificationRegistrar registrar_;
82 // We need our input IDs to be unique across all profiles, so we keep a global
83 // UID that each provider uses.
84 static int global_input_uid_;
86 DISALLOW_COPY_AND_ASSIGN(KeywordExtensionsDelegateImpl);
89 #endif // CHROME_BROWSER_AUTOCOMPLETE_KEYWORD_EXTENSIONS_DELEGATE_IMPL_H_