OLD | NEW |
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 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 5 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 gfx::Image OmniboxAPI::GetOmniboxIcon(const std::string& extension_id) { | 212 gfx::Image OmniboxAPI::GetOmniboxIcon(const std::string& extension_id) { |
213 return gfx::Image::CreateFrom1xBitmap( | 213 return gfx::Image::CreateFrom1xBitmap( |
214 omnibox_icon_manager_.GetIcon(extension_id)); | 214 omnibox_icon_manager_.GetIcon(extension_id)); |
215 } | 215 } |
216 | 216 |
217 gfx::Image OmniboxAPI::GetOmniboxPopupIcon(const std::string& extension_id) { | 217 gfx::Image OmniboxAPI::GetOmniboxPopupIcon(const std::string& extension_id) { |
218 return gfx::Image::CreateFrom1xBitmap( | 218 return gfx::Image::CreateFrom1xBitmap( |
219 omnibox_popup_icon_manager_.GetIcon(extension_id)); | 219 omnibox_popup_icon_manager_.GetIcon(extension_id)); |
220 } | 220 } |
221 | 221 |
| 222 template <> |
| 223 void ProfileKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { |
| 224 DependsOn(ExtensionSystemFactory::GetInstance()); |
| 225 DependsOn(TemplateURLServiceFactory::GetInstance()); |
| 226 } |
| 227 |
222 bool OmniboxSendSuggestionsFunction::RunImpl() { | 228 bool OmniboxSendSuggestionsFunction::RunImpl() { |
223 ExtensionOmniboxSuggestions suggestions; | 229 ExtensionOmniboxSuggestions suggestions; |
224 ListValue* suggestions_value; | 230 ListValue* suggestions_value; |
225 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &suggestions.request_id)); | 231 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &suggestions.request_id)); |
226 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &suggestions_value)); | 232 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &suggestions_value)); |
227 | 233 |
228 suggestions.suggestions.resize(suggestions_value->GetSize()); | 234 suggestions.suggestions.resize(suggestions_value->GetSize()); |
229 for (size_t i = 0; i < suggestions_value->GetSize(); ++i) { | 235 for (size_t i = 0; i < suggestions_value->GetSize(); ++i) { |
230 ExtensionOmniboxSuggestion& suggestion = suggestions.suggestions[i]; | 236 ExtensionOmniboxSuggestion& suggestion = suggestions.suggestions[i]; |
231 DictionaryValue* suggestion_value; | 237 DictionaryValue* suggestion_value; |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 for (size_t i = 0; i < description_styles.size(); ++i) { | 419 for (size_t i = 0; i < description_styles.size(); ++i) { |
414 if (description_styles[i].offset > placeholder) | 420 if (description_styles[i].offset > placeholder) |
415 description_styles[i].offset += replacement.length() - 2; | 421 description_styles[i].offset += replacement.length() - 2; |
416 } | 422 } |
417 } | 423 } |
418 | 424 |
419 match->contents.assign(description); | 425 match->contents.assign(description); |
420 } | 426 } |
421 | 427 |
422 } // namespace extensions | 428 } // namespace extensions |
OLD | NEW |