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

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

Issue 11440004: Remove deprecated extension EventRouter APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile Created 8 years 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/string_util.h" 10 #include "base/string_util.h"
(...skipping 27 matching lines...) Expand all
38 const char kSuggestionDescriptionStylesRaw[] = "descriptionStylesRaw"; 38 const char kSuggestionDescriptionStylesRaw[] = "descriptionStylesRaw";
39 const char kDescriptionStylesType[] = "type"; 39 const char kDescriptionStylesType[] = "type";
40 const char kDescriptionStylesOffset[] = "offset"; 40 const char kDescriptionStylesOffset[] = "offset";
41 const char kDescriptionStylesLength[] = "length"; 41 const char kDescriptionStylesLength[] = "length";
42 42
43 } // namespace 43 } // namespace
44 44
45 // static 45 // static
46 void ExtensionOmniboxEventRouter::OnInputStarted( 46 void ExtensionOmniboxEventRouter::OnInputStarted(
47 Profile* profile, const std::string& extension_id) { 47 Profile* profile, const std::string& extension_id) {
48 scoped_ptr<ListValue> event_args(new ListValue()); 48 scoped_ptr<Event> event(new Event(
49 extensions::ExtensionSystem::Get(profile)->event_router()-> 49 events::kOnInputStarted, make_scoped_ptr(new ListValue())));
50 DispatchEventToExtension(extension_id, events::kOnInputStarted, 50 event->restrict_to_profile = profile;
51 event_args.Pass(), profile, GURL()); 51 ExtensionSystem::Get(profile)->event_router()->
52 DispatchEventToExtension(extension_id, event.Pass());
52 } 53 }
53 54
54 // static 55 // static
55 bool ExtensionOmniboxEventRouter::OnInputChanged( 56 bool ExtensionOmniboxEventRouter::OnInputChanged(
56 Profile* profile, const std::string& extension_id, 57 Profile* profile, const std::string& extension_id,
57 const std::string& input, int suggest_id) { 58 const std::string& input, int suggest_id) {
58 if (!extensions::ExtensionSystem::Get(profile)->event_router()-> 59 if (!extensions::ExtensionSystem::Get(profile)->event_router()->
59 ExtensionHasEventListener(extension_id, events::kOnInputChanged)) 60 ExtensionHasEventListener(extension_id, events::kOnInputChanged))
60 return false; 61 return false;
61 62
62 scoped_ptr<ListValue> args(new ListValue()); 63 scoped_ptr<ListValue> args(new ListValue());
63 args->Set(0, Value::CreateStringValue(input)); 64 args->Set(0, Value::CreateStringValue(input));
64 args->Set(1, Value::CreateIntegerValue(suggest_id)); 65 args->Set(1, Value::CreateIntegerValue(suggest_id));
65 66
66 extensions::ExtensionSystem::Get(profile)->event_router()-> 67 scoped_ptr<Event> event(new Event(events::kOnInputChanged, args.Pass()));
67 DispatchEventToExtension(extension_id, events::kOnInputChanged, 68 event->restrict_to_profile = profile;
68 args.Pass(), profile, GURL()); 69 ExtensionSystem::Get(profile)->event_router()->
70 DispatchEventToExtension(extension_id, event.Pass());
69 return true; 71 return true;
70 } 72 }
71 73
72 // static 74 // static
73 void ExtensionOmniboxEventRouter::OnInputEntered( 75 void ExtensionOmniboxEventRouter::OnInputEntered(
74 content::WebContents* web_contents, 76 content::WebContents* web_contents,
75 const std::string& extension_id, 77 const std::string& extension_id,
76 const std::string& input) { 78 const std::string& input) {
77 Profile* profile = 79 Profile* profile =
78 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 80 Profile::FromBrowserContext(web_contents->GetBrowserContext());
79 81
80 const Extension* extension = 82 const Extension* extension =
81 ExtensionSystem::Get(profile)->extension_service()->extensions()-> 83 ExtensionSystem::Get(profile)->extension_service()->extensions()->
82 GetByID(extension_id); 84 GetByID(extension_id);
83 CHECK(extension); 85 CHECK(extension);
84 extensions::TabHelper::FromWebContents(web_contents)-> 86 extensions::TabHelper::FromWebContents(web_contents)->
85 active_tab_permission_granter()->GrantIfRequested(extension); 87 active_tab_permission_granter()->GrantIfRequested(extension);
86 88
87 scoped_ptr<ListValue> args(new ListValue()); 89 scoped_ptr<ListValue> args(new ListValue());
88 args->Set(0, Value::CreateStringValue(input)); 90 args->Set(0, Value::CreateStringValue(input));
89 91
90 extensions::ExtensionSystem::Get(profile)->event_router()-> 92 scoped_ptr<Event> event(new Event(events::kOnInputEntered, args.Pass()));
91 DispatchEventToExtension(extension_id, events::kOnInputEntered, 93 event->restrict_to_profile = profile;
92 args.Pass(), profile, GURL()); 94 ExtensionSystem::Get(profile)->event_router()->
95 DispatchEventToExtension(extension_id, event.Pass());
93 96
94 content::NotificationService::current()->Notify( 97 content::NotificationService::current()->Notify(
95 chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, 98 chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED,
96 content::Source<Profile>(profile), 99 content::Source<Profile>(profile),
97 content::NotificationService::NoDetails()); 100 content::NotificationService::NoDetails());
98 } 101 }
99 102
100 // static 103 // static
101 void ExtensionOmniboxEventRouter::OnInputCancelled( 104 void ExtensionOmniboxEventRouter::OnInputCancelled(
102 Profile* profile, const std::string& extension_id) { 105 Profile* profile, const std::string& extension_id) {
103 scoped_ptr<ListValue> args(new ListValue()); 106 scoped_ptr<Event> event(new Event(
104 extensions::ExtensionSystem::Get(profile)->event_router()-> 107 events::kOnInputCancelled, make_scoped_ptr(new ListValue())));
105 DispatchEventToExtension(extension_id, events::kOnInputCancelled, 108 event->restrict_to_profile = profile;
106 args.Pass(), profile, GURL()); 109 ExtensionSystem::Get(profile)->event_router()->
110 DispatchEventToExtension(extension_id, event.Pass());
107 } 111 }
108 112
109 bool OmniboxSendSuggestionsFunction::RunImpl() { 113 bool OmniboxSendSuggestionsFunction::RunImpl() {
110 ExtensionOmniboxSuggestions suggestions; 114 ExtensionOmniboxSuggestions suggestions;
111 ListValue* suggestions_value; 115 ListValue* suggestions_value;
112 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &suggestions.request_id)); 116 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &suggestions.request_id));
113 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &suggestions_value)); 117 EXTENSION_FUNCTION_VALIDATE(args_->GetList(1, &suggestions_value));
114 118
115 suggestions.suggestions.resize(suggestions_value->GetSize()); 119 suggestions.suggestions.resize(suggestions_value->GetSize());
116 for (size_t i = 0; i < suggestions_value->GetSize(); ++i) { 120 for (size_t i = 0; i < suggestions_value->GetSize(); ++i) {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 for (size_t i = 0; i < description_styles.size(); ++i) { 304 for (size_t i = 0; i < description_styles.size(); ++i) {
301 if (description_styles[i].offset > placeholder) 305 if (description_styles[i].offset > placeholder)
302 description_styles[i].offset += replacement.length() - 2; 306 description_styles[i].offset += replacement.length() - 2;
303 } 307 }
304 } 308 }
305 309
306 match->contents.assign(description); 310 match->contents.assign(description);
307 } 311 }
308 312
309 } // namespace extensions 313 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698