Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: chrome/browser/extensions/api/omnibox/omnibox_api.cc

Issue 178193030: Rename ProfileKeyedAPI to BrowserContextKeyedAPI and GetProfile to Get. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 0, kOmniboxIconPaddingRight)); 197 0, kOmniboxIconPaddingRight));
198 } 198 }
199 199
200 void OmniboxAPI::Shutdown() { 200 void OmniboxAPI::Shutdown() {
201 template_url_sub_.reset(); 201 template_url_sub_.reset();
202 } 202 }
203 203
204 OmniboxAPI::~OmniboxAPI() { 204 OmniboxAPI::~OmniboxAPI() {
205 } 205 }
206 206
207 static base::LazyInstance<ProfileKeyedAPIFactory<OmniboxAPI> > 207 static base::LazyInstance<BrowserContextKeyedAPIFactory<OmniboxAPI> >
208 g_factory = LAZY_INSTANCE_INITIALIZER; 208 g_factory = LAZY_INSTANCE_INITIALIZER;
209 209
210 // static 210 // static
211 ProfileKeyedAPIFactory<OmniboxAPI>* OmniboxAPI::GetFactoryInstance() { 211 BrowserContextKeyedAPIFactory<OmniboxAPI>* OmniboxAPI::GetFactoryInstance() {
212 return g_factory.Pointer(); 212 return g_factory.Pointer();
213 } 213 }
214 214
215 // static 215 // static
216 OmniboxAPI* OmniboxAPI::Get(content::BrowserContext* context) { 216 OmniboxAPI* OmniboxAPI::Get(content::BrowserContext* context) {
217 return ProfileKeyedAPIFactory<OmniboxAPI>::GetForProfile(context); 217 return BrowserContextKeyedAPIFactory<OmniboxAPI>::Get(context);
218 } 218 }
219 219
220 void OmniboxAPI::Observe(int type, 220 void OmniboxAPI::Observe(int type,
221 const content::NotificationSource& source, 221 const content::NotificationSource& source,
222 const content::NotificationDetails& details) { 222 const content::NotificationDetails& details) {
223 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { 223 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
224 const Extension* extension = 224 const Extension* extension =
225 content::Details<const Extension>(details).ptr(); 225 content::Details<const Extension>(details).ptr();
226 const std::string& keyword = OmniboxInfo::GetKeyword(extension); 226 const std::string& keyword = OmniboxInfo::GetKeyword(extension);
227 if (!keyword.empty()) { 227 if (!keyword.empty()) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 for (PendingExtensions::const_iterator i(pending_extensions_.begin()); 272 for (PendingExtensions::const_iterator i(pending_extensions_.begin());
273 i != pending_extensions_.end(); ++i) { 273 i != pending_extensions_.end(); ++i) {
274 url_service_->RegisterOmniboxKeyword((*i)->id(), 274 url_service_->RegisterOmniboxKeyword((*i)->id(),
275 (*i)->name(), 275 (*i)->name(),
276 OmniboxInfo::GetKeyword(*i)); 276 OmniboxInfo::GetKeyword(*i));
277 } 277 }
278 pending_extensions_.clear(); 278 pending_extensions_.clear();
279 } 279 }
280 280
281 template <> 281 template <>
282 void ProfileKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() { 282 void BrowserContextKeyedAPIFactory<OmniboxAPI>::DeclareFactoryDependencies() {
283 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 283 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
284 DependsOn(ExtensionPrefsFactory::GetInstance()); 284 DependsOn(ExtensionPrefsFactory::GetInstance());
285 DependsOn(TemplateURLServiceFactory::GetInstance()); 285 DependsOn(TemplateURLServiceFactory::GetInstance());
286 } 286 }
287 287
288 bool OmniboxSendSuggestionsFunction::RunImpl() { 288 bool OmniboxSendSuggestionsFunction::RunImpl() {
289 scoped_ptr<SendSuggestions::Params> params( 289 scoped_ptr<SendSuggestions::Params> params(
290 SendSuggestions::Params::Create(*args_)); 290 SendSuggestions::Params::Create(*args_));
291 EXTENSION_FUNCTION_VALIDATE(params); 291 EXTENSION_FUNCTION_VALIDATE(params);
292 292
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698