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

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: kalman's requests Created 7 years, 9 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 21
21 class Profile; 22 class Profile;
22 class TemplateURL; 23 class TemplateURL;
23 class TemplateURLService; 24 class TemplateURLService;
24 25
25 namespace base { 26 namespace base {
26 class ListValue; 27 class ListValue;
27 } 28 }
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion", 139 DECLARE_EXTENSION_FUNCTION("omnibox.setDefaultSuggestion",
139 OMNIBOX_SETDEFAULTSUGGESTION) 140 OMNIBOX_SETDEFAULTSUGGESTION)
140 141
141 protected: 142 protected:
142 virtual ~OmniboxSetDefaultSuggestionFunction() {} 143 virtual ~OmniboxSetDefaultSuggestionFunction() {}
143 144
144 // ExtensionFunction: 145 // ExtensionFunction:
145 virtual bool RunImpl() OVERRIDE; 146 virtual bool RunImpl() OVERRIDE;
146 }; 147 };
147 148
148 struct ExtensionOmniboxSuggestion {
149 ExtensionOmniboxSuggestion();
150 ~ExtensionOmniboxSuggestion();
151
152 // Populate a suggestion value from a DictionaryValue. If |require_content|
153 // is false, then we won't fail if |content| is missing, to support
154 // default suggestions.
155 bool Populate(const base::DictionaryValue& value, bool require_content);
156
157 // Converts a list of style ranges from the extension into the format expected
158 // by the autocomplete system.
159 bool ReadStylesFromValue(const base::ListValue& value);
160
161 // Converts this structure to a DictionaryValue suitable for saving to disk.
162 scoped_ptr<base::DictionaryValue> ToValue() const;
163
164 // The text that gets put in the edit box.
165 string16 content;
166
167 // The text that is displayed in the drop down.
168 string16 description;
169
170 // Contains style ranges for the description.
171 ACMatchClassifications description_styles;
172 };
173
174 struct ExtensionOmniboxSuggestions {
175 ExtensionOmniboxSuggestions();
176 ~ExtensionOmniboxSuggestions();
177
178 int request_id;
179 std::vector<ExtensionOmniboxSuggestion> suggestions;
180
181 private:
182 // This class is passed around by pointer.
183 DISALLOW_COPY_AND_ASSIGN(ExtensionOmniboxSuggestions);
184 };
185
186 // If the extension has set a custom default suggestion via 149 // If the extension has set a custom default suggestion via
187 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing. 150 // omnibox.setDefaultSuggestion, apply that to |match|. Otherwise, do nothing.
188 void ApplyDefaultSuggestionForExtensionKeyword( 151 void ApplyDefaultSuggestionForExtensionKeyword(
189 Profile* profile, 152 Profile* profile,
190 const TemplateURL* keyword, 153 const TemplateURL* keyword,
191 const string16& remaining_input, 154 const string16& remaining_input,
192 AutocompleteMatch* match); 155 AutocompleteMatch* match);
193 156
157 // This function converts style information populated by the JSON schema
158 // // compiler into an ACMatchClassifications object.
159 ACMatchClassifications StyleTypesToACMatchClassifications(
160 const api::omnibox::SuggestResult &suggestion);
161
194 } // namespace extensions 162 } // namespace extensions
195 163
196 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_ 164 #endif // CHROME_BROWSER_EXTENSIONS_API_OMNIBOX_OMNIBOX_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698