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/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
15 #include "chrome/browser/extensions/tab_helper.h" | 15 #include "chrome/browser/extensions/tab_helper.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/search_engines/template_url.h" | 17 #include "chrome/browser/search_engines/template_url.h" |
18 #include "chrome/browser/search_engines/template_url_service.h" | 18 #include "chrome/browser/search_engines/template_url_service.h" |
19 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
20 #include "chrome/common/extensions/api/omnibox.h" | 20 #include "chrome/common/extensions/api/omnibox.h" |
21 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" | 21 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" |
22 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
24 #include "extensions/browser/event_router.h" | 24 #include "extensions/browser/event_router.h" |
25 #include "extensions/browser/extension_prefs.h" | 25 #include "extensions/browser/extension_prefs.h" |
26 #include "extensions/browser/extension_system.h" | 26 #include "extensions/browser/extension_system.h" |
| 27 #include "extensions/browser/extension_system_provider.h" |
| 28 #include "extensions/browser/extensions_browser_client.h" |
27 #include "extensions/common/extension.h" | 29 #include "extensions/common/extension.h" |
28 #include "ui/gfx/image/image.h" | 30 #include "ui/gfx/image/image.h" |
29 | 31 |
30 namespace extensions { | 32 namespace extensions { |
31 | 33 |
32 namespace omnibox = api::omnibox; | 34 namespace omnibox = api::omnibox; |
33 namespace SendSuggestions = omnibox::SendSuggestions; | 35 namespace SendSuggestions = omnibox::SendSuggestions; |
34 namespace SetDefaultSuggestion = omnibox::SetDefaultSuggestion; | 36 namespace SetDefaultSuggestion = omnibox::SetDefaultSuggestion; |
35 | 37 |
36 namespace { | 38 namespace { |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 i != pending_extensions_.end(); ++i) { | 273 i != pending_extensions_.end(); ++i) { |
272 url_service_->RegisterOmniboxKeyword((*i)->id(), | 274 url_service_->RegisterOmniboxKeyword((*i)->id(), |
273 (*i)->name(), | 275 (*i)->name(), |
274 OmniboxInfo::GetKeyword(*i)); | 276 OmniboxInfo::GetKeyword(*i)); |
275 } | 277 } |
276 pending_extensions_.clear(); | 278 pending_extensions_.clear(); |
277 } | 279 } |
278 | 280 |
279 template <> | 281 template <> |
280 void ProfileKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { | 282 void ProfileKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { |
281 DependsOn(ExtensionSystemFactory::GetInstance()); | 283 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
282 DependsOn(TemplateURLServiceFactory::GetInstance()); | 284 DependsOn(TemplateURLServiceFactory::GetInstance()); |
283 } | 285 } |
284 | 286 |
285 bool OmniboxSendSuggestionsFunction::RunImpl() { | 287 bool OmniboxSendSuggestionsFunction::RunImpl() { |
286 scoped_ptr<SendSuggestions::Params> params( | 288 scoped_ptr<SendSuggestions::Params> params( |
287 SendSuggestions::Params::Create(*args_)); | 289 SendSuggestions::Params::Create(*args_)); |
288 EXTENSION_FUNCTION_VALIDATE(params); | 290 EXTENSION_FUNCTION_VALIDATE(params); |
289 | 291 |
290 content::NotificationService::current()->Notify( | 292 content::NotificationService::current()->Notify( |
291 chrome::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, | 293 chrome::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 for (size_t i = 0; i < description_styles.size(); ++i) { | 397 for (size_t i = 0; i < description_styles.size(); ++i) { |
396 if (description_styles[i].offset > placeholder) | 398 if (description_styles[i].offset > placeholder) |
397 description_styles[i].offset += replacement.length() - 2; | 399 description_styles[i].offset += replacement.length() - 2; |
398 } | 400 } |
399 } | 401 } |
400 | 402 |
401 match->contents.assign(description); | 403 match->contents.assign(description); |
402 } | 404 } |
403 | 405 |
404 } // namespace extensions | 406 } // namespace extensions |
OLD | NEW |