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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 DispatchEventToExtension(extension_id, event.Pass()); | 175 DispatchEventToExtension(extension_id, event.Pass()); |
176 } | 176 } |
177 | 177 |
178 OmniboxAPI::OmniboxAPI(content::BrowserContext* context) | 178 OmniboxAPI::OmniboxAPI(content::BrowserContext* context) |
179 : profile_(Profile::FromBrowserContext(context)), | 179 : profile_(Profile::FromBrowserContext(context)), |
180 url_service_(TemplateURLServiceFactory::GetForProfile(profile_)) { | 180 url_service_(TemplateURLServiceFactory::GetForProfile(profile_)) { |
181 registrar_.Add(this, | 181 registrar_.Add(this, |
182 chrome::NOTIFICATION_EXTENSION_LOADED, | 182 chrome::NOTIFICATION_EXTENSION_LOADED, |
183 content::Source<Profile>(profile_)); | 183 content::Source<Profile>(profile_)); |
184 registrar_.Add(this, | 184 registrar_.Add(this, |
185 chrome::NOTIFICATION_EXTENSION_UNLOADED, | 185 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
186 content::Source<Profile>(profile_)); | 186 content::Source<Profile>(profile_)); |
187 if (url_service_) { | 187 if (url_service_) { |
188 template_url_sub_ = url_service_->RegisterOnLoadedCallback( | 188 template_url_sub_ = url_service_->RegisterOnLoadedCallback( |
189 base::Bind(&OmniboxAPI::OnTemplateURLsLoaded, | 189 base::Bind(&OmniboxAPI::OnTemplateURLsLoaded, |
190 base::Unretained(this))); | 190 base::Unretained(this))); |
191 } | 191 } |
192 | 192 |
193 // Use monochrome icons for Omnibox icons. | 193 // Use monochrome icons for Omnibox icons. |
194 omnibox_popup_icon_manager_.set_monochrome(true); | 194 omnibox_popup_icon_manager_.set_monochrome(true); |
195 omnibox_icon_manager_.set_monochrome(true); | 195 omnibox_icon_manager_.set_monochrome(true); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 url_service_->Load(); | 233 url_service_->Load(); |
234 if (url_service_->loaded()) { | 234 if (url_service_->loaded()) { |
235 url_service_->RegisterOmniboxKeyword(extension->id(), | 235 url_service_->RegisterOmniboxKeyword(extension->id(), |
236 extension->name(), | 236 extension->name(), |
237 keyword); | 237 keyword); |
238 } else { | 238 } else { |
239 pending_extensions_.insert(extension); | 239 pending_extensions_.insert(extension); |
240 } | 240 } |
241 } | 241 } |
242 } | 242 } |
243 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED) { | 243 } else if (type == chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED) { |
244 const Extension* extension = | 244 const Extension* extension = |
245 content::Details<UnloadedExtensionInfo>(details)->extension; | 245 content::Details<UnloadedExtensionInfo>(details)->extension; |
246 if (!OmniboxInfo::GetKeyword(extension).empty()) { | 246 if (!OmniboxInfo::GetKeyword(extension).empty()) { |
247 if (url_service_) { | 247 if (url_service_) { |
248 if (url_service_->loaded()) | 248 if (url_service_->loaded()) |
249 url_service_->UnregisterOmniboxKeyword(extension->id()); | 249 url_service_->UnregisterOmniboxKeyword(extension->id()); |
250 else | 250 else |
251 pending_extensions_.erase(extension); | 251 pending_extensions_.erase(extension); |
252 } | 252 } |
253 } | 253 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 for (size_t i = 0; i < description_styles.size(); ++i) { | 398 for (size_t i = 0; i < description_styles.size(); ++i) { |
399 if (description_styles[i].offset > placeholder) | 399 if (description_styles[i].offset > placeholder) |
400 description_styles[i].offset += replacement.length() - 2; | 400 description_styles[i].offset += replacement.length() - 2; |
401 } | 401 } |
402 } | 402 } |
403 | 403 |
404 match->contents.assign(description); | 404 match->contents.assign(description); |
405 } | 405 } |
406 | 406 |
407 } // namespace extensions | 407 } // namespace extensions |
OLD | NEW |