| 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" |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 pending_extensions_.clear(); | 277 pending_extensions_.clear(); |
| 278 } | 278 } |
| 279 | 279 |
| 280 template <> | 280 template <> |
| 281 void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { | 281 void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { |
| 282 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 282 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 283 DependsOn(ExtensionPrefsFactory::GetInstance()); | 283 DependsOn(ExtensionPrefsFactory::GetInstance()); |
| 284 DependsOn(TemplateURLServiceFactory::GetInstance()); | 284 DependsOn(TemplateURLServiceFactory::GetInstance()); |
| 285 } | 285 } |
| 286 | 286 |
| 287 bool OmniboxSendSuggestionsFunction::RunImpl() { | 287 bool OmniboxSendSuggestionsFunction::RunSync() { |
| 288 scoped_ptr<SendSuggestions::Params> params( | 288 scoped_ptr<SendSuggestions::Params> params( |
| 289 SendSuggestions::Params::Create(*args_)); | 289 SendSuggestions::Params::Create(*args_)); |
| 290 EXTENSION_FUNCTION_VALIDATE(params); | 290 EXTENSION_FUNCTION_VALIDATE(params); |
| 291 | 291 |
| 292 content::NotificationService::current()->Notify( | 292 content::NotificationService::current()->Notify( |
| 293 chrome::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, | 293 chrome::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, |
| 294 content::Source<Profile>(GetProfile()->GetOriginalProfile()), | 294 content::Source<Profile>(GetProfile()->GetOriginalProfile()), |
| 295 content::Details<SendSuggestions::Params>(params.get())); | 295 content::Details<SendSuggestions::Params>(params.get())); |
| 296 | 296 |
| 297 return true; | 297 return true; |
| 298 } | 298 } |
| 299 | 299 |
| 300 bool OmniboxSetDefaultSuggestionFunction::RunImpl() { | 300 bool OmniboxSetDefaultSuggestionFunction::RunSync() { |
| 301 scoped_ptr<SetDefaultSuggestion::Params> params( | 301 scoped_ptr<SetDefaultSuggestion::Params> params( |
| 302 SetDefaultSuggestion::Params::Create(*args_)); | 302 SetDefaultSuggestion::Params::Create(*args_)); |
| 303 EXTENSION_FUNCTION_VALIDATE(params); | 303 EXTENSION_FUNCTION_VALIDATE(params); |
| 304 | 304 |
| 305 if (SetOmniboxDefaultSuggestion( | 305 if (SetOmniboxDefaultSuggestion( |
| 306 GetProfile(), extension_id(), params->suggestion)) { | 306 GetProfile(), extension_id(), params->suggestion)) { |
| 307 content::NotificationService::current()->Notify( | 307 content::NotificationService::current()->Notify( |
| 308 chrome::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED, | 308 chrome::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED, |
| 309 content::Source<Profile>(GetProfile()->GetOriginalProfile()), | 309 content::Source<Profile>(GetProfile()->GetOriginalProfile()), |
| 310 content::NotificationService::NoDetails()); | 310 content::NotificationService::NoDetails()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 for (size_t i = 0; i < description_styles.size(); ++i) { | 397 for (size_t i = 0; i < description_styles.size(); ++i) { |
| 398 if (description_styles[i].offset > placeholder) | 398 if (description_styles[i].offset > placeholder) |
| 399 description_styles[i].offset += replacement.length() - 2; | 399 description_styles[i].offset += replacement.length() - 2; |
| 400 } | 400 } |
| 401 } | 401 } |
| 402 | 402 |
| 403 match->contents.assign(description); | 403 match->contents.assign(description); |
| 404 } | 404 } |
| 405 | 405 |
| 406 } // namespace extensions | 406 } // namespace extensions |
| OLD | NEW |