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

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

Issue 10265022: Moving extensions inside chrome/browser/extensions/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-synced with the current trunk Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_OMNIBOX_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_OMNIBOX_API_H_
7 #pragma once
8
9 #include <string>
10 #include <vector>
11
12 #include "base/string16.h"
13 #include "chrome/browser/autocomplete/autocomplete_match.h"
14 #include "chrome/browser/extensions/extension_function.h"
15 #include "webkit/glue/window_open_disposition.h"
16
17 class TemplateURL;
18 namespace base {
19 class ListValue;
20 }
21
22 // Event router class for events related to the omnibox API.
23 class ExtensionOmniboxEventRouter {
24 public:
25 // The user has just typed the omnibox keyword. This is sent exactly once in
26 // a given input session, before any OnInputChanged events.
27 static void OnInputStarted(
28 Profile* profile, const std::string& extension_id);
29
30 // The user has changed what is typed into the omnibox while in an extension
31 // keyword session. Returns true if someone is listening to this event, and
32 // thus we have some degree of confidence we'll get a response.
33 static bool OnInputChanged(
34 Profile* profile, const std::string& extension_id,
35 const std::string& input, int suggest_id);
36
37 // The user has accepted the omnibox input.
38 static void OnInputEntered(
39 Profile* profile, const std::string& extension_id,
40 const std::string& input);
41
42 // The user has cleared the keyword, or closed the omnibox popup. This is
43 // sent at most once in a give input session, after any OnInputChanged events.
44 static void OnInputCancelled(
45 Profile* profile, const std::string& extension_id);
46
47 private:
48 DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxEventRouter);
49 };
50
51 class OmniboxSendSuggestionsFunction : public SyncExtensionFunction {
52 public:
53 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.sendSuggestions");
54
55 protected:
56 virtual ~OmniboxSendSuggestionsFunction() {}
57
58 // ExtensionFunction:
59 virtual bool RunImpl() OVERRIDE;
60 };
61
62 class OmniboxSetDefaultSuggestionFunction : public SyncExtensionFunction {
63 public:
64 DECLARE_EXTENSION_FUNCTION_NAME("omnibox.setDefaultSuggestion");
65
66 protected:
67 virtual ~OmniboxSetDefaultSuggestionFunction() {}
68
69 // ExtensionFunction:
70 virtual bool RunImpl() OVERRIDE;
71 };
72
73 struct ExtensionOmniboxSuggestion {
74 ExtensionOmniboxSuggestion();
75 ~ExtensionOmniboxSuggestion();
76
77 // Converts a list of style ranges from the extension into the format expected
78 // by the autocomplete system.
79 bool ReadStylesFromValue(const base::ListValue& value);
80
81 // The text that gets put in the edit box.
82 string16 content;
83
84 // The text that is displayed in the drop down.
85 string16 description;
86
87 // Contains style ranges for the description.
88 ACMatchClassifications description_styles;
89 };
90
91 struct ExtensionOmniboxSuggestions {
92 ExtensionOmniboxSuggestions();
93 ~ExtensionOmniboxSuggestions();
94
95 int request_id;
96 std::vector<ExtensionOmniboxSuggestion> suggestions;
97
98 private:
99 // This class is passed around by pointer.
100 DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxSuggestions);
101 };
102
103 // If the extension has set a custom default suggestion via
104 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing.
105 void ApplyDefaultSuggestionForExtensionKeyword(
106 Profile* profile,
107 const TemplateURL* keyword,
108 const string16& remaining_input,
109 AutocompleteMatch* match);
110
111 // Launch an Extension App from |match| details provided by the Omnibox. If the
112 // application wants to launch as a window or panel, |disposition| is ignored;
113 // otherwise it's used to determine in which tab we'll launch the application.
114 void LaunchAppFromOmnibox(const AutocompleteMatch& match,
115 Profile* profile,
116 WindowOpenDisposition disposition);
117
118 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_OMNIBOX_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_function_registry.cc ('k') | chrome/browser/extensions/extension_omnibox_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698