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/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 pending_extensions_.clear(); | 259 pending_extensions_.clear(); |
260 } | 260 } |
261 | 261 |
262 template <> | 262 template <> |
263 void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { | 263 void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { |
264 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 264 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
265 DependsOn(ExtensionPrefsFactory::GetInstance()); | 265 DependsOn(ExtensionPrefsFactory::GetInstance()); |
266 DependsOn(TemplateURLServiceFactory::GetInstance()); | 266 DependsOn(TemplateURLServiceFactory::GetInstance()); |
267 } | 267 } |
268 | 268 |
269 bool OmniboxSendSuggestionsFunction::RunImpl() { | 269 bool OmniboxSendSuggestionsFunction::RunSync() { |
270 scoped_ptr<SendSuggestions::Params> params( | 270 scoped_ptr<SendSuggestions::Params> params( |
271 SendSuggestions::Params::Create(*args_)); | 271 SendSuggestions::Params::Create(*args_)); |
272 EXTENSION_FUNCTION_VALIDATE(params); | 272 EXTENSION_FUNCTION_VALIDATE(params); |
273 | 273 |
274 content::NotificationService::current()->Notify( | 274 content::NotificationService::current()->Notify( |
275 chrome::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, | 275 chrome::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, |
276 content::Source<Profile>(GetProfile()->GetOriginalProfile()), | 276 content::Source<Profile>(GetProfile()->GetOriginalProfile()), |
277 content::Details<SendSuggestions::Params>(params.get())); | 277 content::Details<SendSuggestions::Params>(params.get())); |
278 | 278 |
279 return true; | 279 return true; |
280 } | 280 } |
281 | 281 |
282 bool OmniboxSetDefaultSuggestionFunction::RunImpl() { | 282 bool OmniboxSetDefaultSuggestionFunction::RunSync() { |
283 scoped_ptr<SetDefaultSuggestion::Params> params( | 283 scoped_ptr<SetDefaultSuggestion::Params> params( |
284 SetDefaultSuggestion::Params::Create(*args_)); | 284 SetDefaultSuggestion::Params::Create(*args_)); |
285 EXTENSION_FUNCTION_VALIDATE(params); | 285 EXTENSION_FUNCTION_VALIDATE(params); |
286 | 286 |
287 if (SetOmniboxDefaultSuggestion( | 287 if (SetOmniboxDefaultSuggestion( |
288 GetProfile(), extension_id(), params->suggestion)) { | 288 GetProfile(), extension_id(), params->suggestion)) { |
289 content::NotificationService::current()->Notify( | 289 content::NotificationService::current()->Notify( |
290 chrome::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED, | 290 chrome::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED, |
291 content::Source<Profile>(GetProfile()->GetOriginalProfile()), | 291 content::Source<Profile>(GetProfile()->GetOriginalProfile()), |
292 content::NotificationService::NoDetails()); | 292 content::NotificationService::NoDetails()); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 for (size_t i = 0; i < description_styles.size(); ++i) { | 379 for (size_t i = 0; i < description_styles.size(); ++i) { |
380 if (description_styles[i].offset > placeholder) | 380 if (description_styles[i].offset > placeholder) |
381 description_styles[i].offset += replacement.length() - 2; | 381 description_styles[i].offset += replacement.length() - 2; |
382 } | 382 } |
383 } | 383 } |
384 | 384 |
385 match->contents.assign(description); | 385 match->contents.assign(description); |
386 } | 386 } |
387 | 387 |
388 } // namespace extensions | 388 } // namespace extensions |
OLD | NEW |