| 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 make_scoped_ptr(new base::ListValue()))); | 171 make_scoped_ptr(new base::ListValue()))); |
| 172 event->restrict_to_browser_context = profile; | 172 event->restrict_to_browser_context = profile; |
| 173 EventRouter::Get(profile) | 173 EventRouter::Get(profile) |
| 174 ->DispatchEventToExtension(extension_id, event.Pass()); | 174 ->DispatchEventToExtension(extension_id, event.Pass()); |
| 175 } | 175 } |
| 176 | 176 |
| 177 OmniboxAPI::OmniboxAPI(content::BrowserContext* context) | 177 OmniboxAPI::OmniboxAPI(content::BrowserContext* context) |
| 178 : profile_(Profile::FromBrowserContext(context)), | 178 : profile_(Profile::FromBrowserContext(context)), |
| 179 url_service_(TemplateURLServiceFactory::GetForProfile(profile_)) { | 179 url_service_(TemplateURLServiceFactory::GetForProfile(profile_)) { |
| 180 registrar_.Add(this, | 180 registrar_.Add(this, |
| 181 chrome::NOTIFICATION_EXTENSION_LOADED, | 181 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 182 content::Source<Profile>(profile_)); | 182 content::Source<Profile>(profile_)); |
| 183 registrar_.Add(this, | 183 registrar_.Add(this, |
| 184 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 184 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 185 content::Source<Profile>(profile_)); | 185 content::Source<Profile>(profile_)); |
| 186 if (url_service_) { | 186 if (url_service_) { |
| 187 template_url_sub_ = url_service_->RegisterOnLoadedCallback( | 187 template_url_sub_ = url_service_->RegisterOnLoadedCallback( |
| 188 base::Bind(&OmniboxAPI::OnTemplateURLsLoaded, | 188 base::Bind(&OmniboxAPI::OnTemplateURLsLoaded, |
| 189 base::Unretained(this))); | 189 base::Unretained(this))); |
| 190 } | 190 } |
| 191 | 191 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 212 } | 212 } |
| 213 | 213 |
| 214 // static | 214 // static |
| 215 OmniboxAPI* OmniboxAPI::Get(content::BrowserContext* context) { | 215 OmniboxAPI* OmniboxAPI::Get(content::BrowserContext* context) { |
| 216 return BrowserContextKeyedAPIFactory<OmniboxAPI>::Get(context); | 216 return BrowserContextKeyedAPIFactory<OmniboxAPI>::Get(context); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void OmniboxAPI::Observe(int type, | 219 void OmniboxAPI::Observe(int type, |
| 220 const content::NotificationSource& source, | 220 const content::NotificationSource& source, |
| 221 const content::NotificationDetails& details) { | 221 const content::NotificationDetails& details) { |
| 222 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { | 222 if (type == chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED) { |
| 223 const Extension* extension = | 223 const Extension* extension = |
| 224 content::Details<const Extension>(details).ptr(); | 224 content::Details<const Extension>(details).ptr(); |
| 225 const std::string& keyword = OmniboxInfo::GetKeyword(extension); | 225 const std::string& keyword = OmniboxInfo::GetKeyword(extension); |
| 226 if (!keyword.empty()) { | 226 if (!keyword.empty()) { |
| 227 // Load the omnibox icon so it will be ready to display in the URL bar. | 227 // Load the omnibox icon so it will be ready to display in the URL bar. |
| 228 omnibox_popup_icon_manager_.LoadIcon(profile_, extension); | 228 omnibox_popup_icon_manager_.LoadIcon(profile_, extension); |
| 229 omnibox_icon_manager_.LoadIcon(profile_, extension); | 229 omnibox_icon_manager_.LoadIcon(profile_, extension); |
| 230 | 230 |
| 231 if (url_service_) { | 231 if (url_service_) { |
| 232 url_service_->Load(); | 232 url_service_->Load(); |
| (...skipping 164 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 |