| 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 scoped_ptr<Event> event(new Event( | 177 scoped_ptr<Event> event(new Event( |
| 178 events::kOnInputCancelled, make_scoped_ptr(new ListValue()))); | 178 events::kOnInputCancelled, make_scoped_ptr(new ListValue()))); |
| 179 event->restrict_to_profile = profile; | 179 event->restrict_to_profile = profile; |
| 180 ExtensionSystem::Get(profile)->event_router()-> | 180 ExtensionSystem::Get(profile)->event_router()-> |
| 181 DispatchEventToExtension(extension_id, event.Pass()); | 181 DispatchEventToExtension(extension_id, event.Pass()); |
| 182 } | 182 } |
| 183 | 183 |
| 184 OmniboxAPI::OmniboxAPI(Profile* profile) | 184 OmniboxAPI::OmniboxAPI(Profile* profile) |
| 185 : profile_(profile), | 185 : profile_(profile), |
| 186 url_service_(TemplateURLServiceFactory::GetForProfile(profile)) { | 186 url_service_(TemplateURLServiceFactory::GetForProfile(profile)) { |
| 187 (new OmniboxHandler)->Register(); | |
| 188 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 187 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 189 content::Source<Profile>(profile)); | 188 content::Source<Profile>(profile)); |
| 190 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 189 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 191 content::Source<Profile>(profile)); | 190 content::Source<Profile>(profile)); |
| 192 if (url_service_) { | 191 if (url_service_) { |
| 193 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, | 192 registrar_.Add(this, chrome::NOTIFICATION_TEMPLATE_URL_SERVICE_LOADED, |
| 194 content::Source<TemplateURLService>(url_service_)); | 193 content::Source<TemplateURLService>(url_service_)); |
| 195 } | 194 } |
| 196 | 195 |
| 197 // Use monochrome icons for Omnibox icons. | 196 // Use monochrome icons for Omnibox icons. |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 for (size_t i = 0; i < description_styles.size(); ++i) { | 394 for (size_t i = 0; i < description_styles.size(); ++i) { |
| 396 if (description_styles[i].offset > placeholder) | 395 if (description_styles[i].offset > placeholder) |
| 397 description_styles[i].offset += replacement.length() - 2; | 396 description_styles[i].offset += replacement.length() - 2; |
| 398 } | 397 } |
| 399 } | 398 } |
| 400 | 399 |
| 401 match->contents.assign(description); | 400 match->contents.assign(description); |
| 402 } | 401 } |
| 403 | 402 |
| 404 } // namespace extensions | 403 } // namespace extensions |
| OLD | NEW |