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

Side by Side Diff: chrome/browser/extensions/api/omnibox/omnibox_api.h

Issue 12314164: Modified Omnibox extension api to use JSON Schema Compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced include with forward declaration Created 7 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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_API_OMNIBOX_OMNIBOX_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "chrome/browser/autocomplete/autocomplete_match.h" 14 #include "chrome/browser/autocomplete/autocomplete_match.h"
15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" 15 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h"
16 #include "chrome/browser/extensions/extension_function.h" 16 #include "chrome/browser/extensions/extension_function.h"
17 #include "chrome/browser/extensions/extension_icon_manager.h" 17 #include "chrome/browser/extensions/extension_icon_manager.h"
18 #include "chrome/common/extensions/api/omnibox.h"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 #include "ui/base/window_open_disposition.h" 21 #include "ui/base/window_open_disposition.h"
21 22
22 class Profile; 23 class Profile;
23 class TemplateURL; 24 class TemplateURL;
24 class TemplateURLService; 25 class TemplateURLService;
25 26
26 namespace base { 27 namespace base {
27 class ListValue; 28 class ListValue;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion", 141 DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion",
141 OMNIBOX_SETDEFAULTSUGGESTION) 142 OMNIBOX_SETDEFAULTSUGGESTION)
142 143
143 protected: 144 protected:
144 virtual ~OmniboxSetDefaultSuggestionFunction() {} 145 virtual ~OmniboxSetDefaultSuggestionFunction() {}
145 146
146 // ExtensionFunction: 147 // ExtensionFunction:
147 virtual bool RunImpl() OVERRIDE; 148 virtual bool RunImpl() OVERRIDE;
148 }; 149 };
149 150
150 struct ExtensionOmniboxSuggestion {
151 ExtensionOmniboxSuggestion();
152 ~ExtensionOmniboxSuggestion();
153
154 // Populate a suggestion value from a DictionaryValue. If |require_content|
155 // is false, then we won't fail if |content| is missing, to support
156 // default suggestions.
157 bool Populate(const base::DictionaryValue& value, bool require_content);
158
159 // Converts a list of style ranges from the extension into the format expected
160 // by the autocomplete system.
161 bool ReadStylesFromValue(const base::ListValue& value);
162
163 // Converts this structure to a DictionaryValue suitable for saving to disk.
164 scoped_ptr<base::DictionaryValue> ToValue() const;
165
166 // The text that gets put in the edit box.
167 string16 content;
168
169 // The text that is displayed in the drop down.
170 string16 description;
171
172 // Contains style ranges for the description.
173 ACMatchClassifications description_styles;
174 };
175
176 struct ExtensionOmniboxSuggestions {
177 ExtensionOmniboxSuggestions();
178 ~ExtensionOmniboxSuggestions();
179
180 int request_id;
181 std::vector<ExtensionOmniboxSuggestion> suggestions;
182
183 private:
184 // This class is passed around by pointer.
185 DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxSuggestions);
186 };
187
188 // If the extension has set a custom default suggestion via 151 // If the extension has set a custom default suggestion via
189 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. 152 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing.
190 void ApplyDefaultSuggestionForExtensionKeyword( 153 void ApplyDefaultSuggestionForExtensionKeyword(
191 Profile* profile, 154 Profile* profile,
192 const TemplateURL* keyword, 155 const TemplateURL* keyword,
193 const string16& remaining_input, 156 const string16& remaining_input,
194 AutocompleteMatch* match); 157 AutocompleteMatch* match);
195 158
159 // This function converts style information populated by the JSON schema
160 // // compiler into an ACMatchClassifications object.
161 ACMatchClassifications StyleTypesToACMatchClassifications(
162 const api::omnibox::SuggestResult &suggestion);
163
196 } // namespace extensions 164 } // namespace extensions
197 165
198 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ 166 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/keyword_provider.cc ('k') | chrome/browser/extensions/api/omnibox/omnibox_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698