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

Side by Side Diff: chrome/browser/extensions/extension_omnibox_api.h

Issue 2807033: Add support for omnibox.onInputStarted and onInputCancelled. (Closed)
Patch Set: fix Stop Created 10 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_OMNIBOX_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_OMNIBOX_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_OMNIBOX_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_OMNIBOX_API_H_
7 7
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "chrome/browser/autocomplete/autocomplete.h" 9 #include "chrome/browser/autocomplete/autocomplete.h"
10 #include "chrome/browser/extensions/extension_function.h" 10 #include "chrome/browser/extensions/extension_function.h"
11 11
12 // Event router class for events related to the omnibox API. 12 // Event router class for events related to the omnibox API.
13 class ExtensionOmniboxEventRouter { 13 class ExtensionOmniboxEventRouter {
14 public: 14 public:
15 // The user has just typed the omnibox keyword. This is sent exactly once in
16 // a given input session, before any OnInputChanged events.
17 static void OnInputStarted(
18 Profile* profile, const std::string& extension_id);
19
15 // The user has changed what is typed into the omnibox while in an extension 20 // The user has changed what is typed into the omnibox while in an extension
16 // keyword session. Returns true if someone is listening to this event, and 21 // keyword session. Returns true if someone is listening to this event, and
17 // thus we have some degree of confidence we'll get a response. 22 // thus we have some degree of confidence we'll get a response.
18 static bool OnInputChanged( 23 static bool OnInputChanged(
19 Profile* profile, const std::string& extension_id, 24 Profile* profile, const std::string& extension_id,
20 const std::string& input, int suggest_id); 25 const std::string& input, int suggest_id);
21 26
22 // The user has accepted the omnibox input. 27 // The user has accepted the omnibox input.
23 static void OnInputEntered( 28 static void OnInputEntered(
24 Profile* profile, const std::string& extension_id, 29 Profile* profile, const std::string& extension_id,
25 const std::string& input); 30 const std::string& input);
26 31
32 // The user has cleared the keyword, or closed the omnibox popup. This is
33 // sent at most once in a give input session, after any OnInputChanged events.
34 static void OnInputCancelled(
35 Profile* profile, const std::string& extension_id);
36
27 private: 37 private:
28 DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxEventRouter); 38 DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxEventRouter);
29 }; 39 };
30 40
31 class OmniboxSendSuggestionsFunction : public SyncExtensionFunction { 41 class OmniboxSendSuggestionsFunction : public SyncExtensionFunction {
32 public: 42 public:
33 virtual bool RunImpl(); 43 virtual bool RunImpl();
34 DECLARE_EXTENSION_FUNCTION_NAME("experimental.omnibox.sendSuggestions"); 44 DECLARE_EXTENSION_FUNCTION_NAME("experimental.omnibox.sendSuggestions");
35 }; 45 };
36 46
37 struct ExtensionOmniboxSuggestion { 47 struct ExtensionOmniboxSuggestion {
38 // The text that gets put in the edit box. 48 // The text that gets put in the edit box.
39 string16 content; 49 string16 content;
40 50
41 // The text that is displayed in the drop down. 51 // The text that is displayed in the drop down.
42 string16 description; 52 string16 description;
43 53
44 // Contains style ranges for the description. 54 // Contains style ranges for the description.
45 ACMatchClassifications description_styles; 55 ACMatchClassifications description_styles;
46 }; 56 };
47 57
48 struct ExtensionOmniboxSuggestions { 58 struct ExtensionOmniboxSuggestions {
49 int request_id; 59 int request_id;
50 std::vector<ExtensionOmniboxSuggestion> suggestions; 60 std::vector<ExtensionOmniboxSuggestion> suggestions;
51 }; 61 };
52 62
53 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_OMNIBOX_API_H_ 63 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_OMNIBOX_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_message_service.cc ('k') | chrome/browser/extensions/extension_omnibox_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698