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

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

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 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/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"
11 #include "chrome/browser/extensions/tab_helper.h" 10 #include "chrome/browser/extensions/tab_helper.h"
12 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url_service_factory.h" 12 #include "chrome/browser/search_engines/template_url_service_factory.h"
14 #include "chrome/common/extensions/api/omnibox.h" 13 #include "chrome/common/extensions/api/omnibox.h"
15 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h" 14 #include "chrome/common/extensions/api/omnibox/omnibox_handler.h"
16 #include "components/search_engines/template_url.h" 15 #include "components/search_engines/template_url.h"
17 #include "components/search_engines/template_url_service.h" 16 #include "components/search_engines/template_url_service.h"
18 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
19 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
20 #include "extensions/browser/event_router.h" 19 #include "extensions/browser/event_router.h"
21 #include "extensions/browser/extension_prefs.h" 20 #include "extensions/browser/extension_prefs.h"
22 #include "extensions/browser/extension_prefs_factory.h" 21 #include "extensions/browser/extension_prefs_factory.h"
23 #include "extensions/browser/extension_registry.h" 22 #include "extensions/browser/extension_registry.h"
23 #include "extensions/browser/notification_types.h"
24 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
25 25
26 namespace extensions { 26 namespace extensions {
27 27
28 namespace omnibox = api::omnibox; 28 namespace omnibox = api::omnibox;
29 namespace SendSuggestions = omnibox::SendSuggestions; 29 namespace SendSuggestions = omnibox::SendSuggestions;
30 namespace SetDefaultSuggestion = omnibox::SetDefaultSuggestion; 30 namespace SetDefaultSuggestion = omnibox::SetDefaultSuggestion;
31 31
32 namespace { 32 namespace {
33 33
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 else 152 else
153 args->Set(1, new base::StringValue(kCurrentTabDisposition)); 153 args->Set(1, new base::StringValue(kCurrentTabDisposition));
154 154
155 scoped_ptr<Event> event(new Event(omnibox::OnInputEntered::kEventName, 155 scoped_ptr<Event> event(new Event(omnibox::OnInputEntered::kEventName,
156 args.Pass())); 156 args.Pass()));
157 event->restrict_to_browser_context = profile; 157 event->restrict_to_browser_context = profile;
158 EventRouter::Get(profile) 158 EventRouter::Get(profile)
159 ->DispatchEventToExtension(extension_id, event.Pass()); 159 ->DispatchEventToExtension(extension_id, event.Pass());
160 160
161 content::NotificationService::current()->Notify( 161 content::NotificationService::current()->Notify(
162 chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, 162 extensions::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED,
163 content::Source<Profile>(profile), 163 content::Source<Profile>(profile),
164 content::NotificationService::NoDetails()); 164 content::NotificationService::NoDetails());
165 } 165 }
166 166
167 // static 167 // static
168 void ExtensionOmniboxEventRouter::OnInputCancelled( 168 void ExtensionOmniboxEventRouter::OnInputCancelled(
169 Profile* profile, const std::string& extension_id) { 169 Profile* profile, const std::string& extension_id) {
170 scoped_ptr<Event> event(new Event( 170 scoped_ptr<Event> event(new Event(
171 omnibox::OnInputCancelled::kEventName, 171 omnibox::OnInputCancelled::kEventName,
172 make_scoped_ptr(new base::ListValue()))); 172 make_scoped_ptr(new base::ListValue())));
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 DependsOn(ExtensionPrefsFactory::GetInstance()); 275 DependsOn(ExtensionPrefsFactory::GetInstance());
276 DependsOn(TemplateURLServiceFactory::GetInstance()); 276 DependsOn(TemplateURLServiceFactory::GetInstance());
277 } 277 }
278 278
279 bool OmniboxSendSuggestionsFunction::RunSync() { 279 bool OmniboxSendSuggestionsFunction::RunSync() {
280 scoped_ptr<SendSuggestions::Params> params( 280 scoped_ptr<SendSuggestions::Params> params(
281 SendSuggestions::Params::Create(*args_)); 281 SendSuggestions::Params::Create(*args_));
282 EXTENSION_FUNCTION_VALIDATE(params); 282 EXTENSION_FUNCTION_VALIDATE(params);
283 283
284 content::NotificationService::current()->Notify( 284 content::NotificationService::current()->Notify(
285 chrome::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY, 285 extensions::NOTIFICATION_EXTENSION_OMNIBOX_SUGGESTIONS_READY,
286 content::Source<Profile>(GetProfile()->GetOriginalProfile()), 286 content::Source<Profile>(GetProfile()->GetOriginalProfile()),
287 content::Details<SendSuggestions::Params>(params.get())); 287 content::Details<SendSuggestions::Params>(params.get()));
288 288
289 return true; 289 return true;
290 } 290 }
291 291
292 bool OmniboxSetDefaultSuggestionFunction::RunSync() { 292 bool OmniboxSetDefaultSuggestionFunction::RunSync() {
293 scoped_ptr<SetDefaultSuggestion::Params> params( 293 scoped_ptr<SetDefaultSuggestion::Params> params(
294 SetDefaultSuggestion::Params::Create(*args_)); 294 SetDefaultSuggestion::Params::Create(*args_));
295 EXTENSION_FUNCTION_VALIDATE(params); 295 EXTENSION_FUNCTION_VALIDATE(params);
296 296
297 if (SetOmniboxDefaultSuggestion( 297 if (SetOmniboxDefaultSuggestion(
298 GetProfile(), extension_id(), params->suggestion)) { 298 GetProfile(), extension_id(), params->suggestion)) {
299 content::NotificationService::current()->Notify( 299 content::NotificationService::current()->Notify(
300 chrome::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED, 300 extensions::NOTIFICATION_EXTENSION_OMNIBOX_DEFAULT_SUGGESTION_CHANGED,
301 content::Source<Profile>(GetProfile()->GetOriginalProfile()), 301 content::Source<Profile>(GetProfile()->GetOriginalProfile()),
302 content::NotificationService::NoDetails()); 302 content::NotificationService::NoDetails());
303 } 303 }
304 304
305 return true; 305 return true;
306 } 306 }
307 307
308 // This function converts style information populated by the JSON schema 308 // This function converts style information populated by the JSON schema
309 // compiler into an ACMatchClassifications object. 309 // compiler into an ACMatchClassifications object.
310 ACMatchClassifications StyleTypesToACMatchClassifications( 310 ACMatchClassifications StyleTypesToACMatchClassifications(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 for (size_t i = 0; i < description_styles.size(); ++i) { 389 for (size_t i = 0; i < description_styles.size(); ++i) {
390 if (description_styles[i].offset > placeholder) 390 if (description_styles[i].offset > placeholder)
391 description_styles[i].offset += replacement.length() - 2; 391 description_styles[i].offset += replacement.length() - 2;
392 } 392 }
393 } 393 }
394 394
395 match->contents.assign(description); 395 match->contents.assign(description);
396 } 396 }
397 397
398 } // namespace extensions 398 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698