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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 // static | 121 // static |
122 bool ExtensionOmniboxEventRouter::OnInputChanged( | 122 bool ExtensionOmniboxEventRouter::OnInputChanged( |
123 Profile* profile, const std::string& extension_id, | 123 Profile* profile, const std::string& extension_id, |
124 const std::string& input, int suggest_id) { | 124 const std::string& input, int suggest_id) { |
125 if (!extensions::ExtensionSystem::Get(profile)->event_router()-> | 125 if (!extensions::ExtensionSystem::Get(profile)->event_router()-> |
126 ExtensionHasEventListener(extension_id, events::kOnInputChanged)) | 126 ExtensionHasEventListener(extension_id, events::kOnInputChanged)) |
127 return false; | 127 return false; |
128 | 128 |
129 scoped_ptr<base::ListValue> args(new base::ListValue()); | 129 scoped_ptr<base::ListValue> args(new base::ListValue()); |
130 args->Set(0, Value::CreateStringValue(input)); | 130 args->Set(0, new base::StringValue(input)); |
131 args->Set(1, Value::CreateIntegerValue(suggest_id)); | 131 args->Set(1, new base::FundamentalValue(suggest_id)); |
132 | 132 |
133 scoped_ptr<Event> event(new Event(events::kOnInputChanged, args.Pass())); | 133 scoped_ptr<Event> event(new Event(events::kOnInputChanged, args.Pass())); |
134 event->restrict_to_profile = profile; | 134 event->restrict_to_profile = profile; |
135 ExtensionSystem::Get(profile)->event_router()-> | 135 ExtensionSystem::Get(profile)->event_router()-> |
136 DispatchEventToExtension(extension_id, event.Pass()); | 136 DispatchEventToExtension(extension_id, event.Pass()); |
137 return true; | 137 return true; |
138 } | 138 } |
139 | 139 |
140 // static | 140 // static |
141 void ExtensionOmniboxEventRouter::OnInputEntered( | 141 void ExtensionOmniboxEventRouter::OnInputEntered( |
142 content::WebContents* web_contents, | 142 content::WebContents* web_contents, |
143 const std::string& extension_id, | 143 const std::string& extension_id, |
144 const std::string& input, | 144 const std::string& input, |
145 WindowOpenDisposition disposition) { | 145 WindowOpenDisposition disposition) { |
146 Profile* profile = | 146 Profile* profile = |
147 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 147 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
148 | 148 |
149 const Extension* extension = | 149 const Extension* extension = |
150 ExtensionSystem::Get(profile)->extension_service()->extensions()-> | 150 ExtensionSystem::Get(profile)->extension_service()->extensions()-> |
151 GetByID(extension_id); | 151 GetByID(extension_id); |
152 CHECK(extension); | 152 CHECK(extension); |
153 extensions::TabHelper::FromWebContents(web_contents)-> | 153 extensions::TabHelper::FromWebContents(web_contents)-> |
154 active_tab_permission_granter()->GrantIfRequested(extension); | 154 active_tab_permission_granter()->GrantIfRequested(extension); |
155 | 155 |
156 scoped_ptr<base::ListValue> args(new base::ListValue()); | 156 scoped_ptr<base::ListValue> args(new base::ListValue()); |
157 args->Set(0, Value::CreateStringValue(input)); | 157 args->Set(0, new base::StringValue(input)); |
158 if (disposition == NEW_FOREGROUND_TAB) | 158 if (disposition == NEW_FOREGROUND_TAB) |
159 args->Set(1, Value::CreateStringValue(kForegroundTabDisposition)); | 159 args->Set(1, new base::StringValue(kForegroundTabDisposition)); |
160 else if (disposition == NEW_BACKGROUND_TAB) | 160 else if (disposition == NEW_BACKGROUND_TAB) |
161 args->Set(1, Value::CreateStringValue(kBackgroundTabDisposition)); | 161 args->Set(1, new base::StringValue(kBackgroundTabDisposition)); |
162 else | 162 else |
163 args->Set(1, Value::CreateStringValue(kCurrentTabDisposition)); | 163 args->Set(1, new base::StringValue(kCurrentTabDisposition)); |
164 | 164 |
165 scoped_ptr<Event> event(new Event(events::kOnInputEntered, args.Pass())); | 165 scoped_ptr<Event> event(new Event(events::kOnInputEntered, args.Pass())); |
166 event->restrict_to_profile = profile; | 166 event->restrict_to_profile = profile; |
167 ExtensionSystem::Get(profile)->event_router()-> | 167 ExtensionSystem::Get(profile)->event_router()-> |
168 DispatchEventToExtension(extension_id, event.Pass()); | 168 DispatchEventToExtension(extension_id, event.Pass()); |
169 | 169 |
170 content::NotificationService::current()->Notify( | 170 content::NotificationService::current()->Notify( |
171 chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, | 171 chrome::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, |
172 content::Source<Profile>(profile), | 172 content::Source<Profile>(profile), |
173 content::NotificationService::NoDetails()); | 173 content::NotificationService::NoDetails()); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 for (size_t i = 0; i < description_styles.size(); ++i) { | 396 for (size_t i = 0; i < description_styles.size(); ++i) { |
397 if (description_styles[i].offset > placeholder) | 397 if (description_styles[i].offset > placeholder) |
398 description_styles[i].offset += replacement.length() - 2; | 398 description_styles[i].offset += replacement.length() - 2; |
399 } | 399 } |
400 } | 400 } |
401 | 401 |
402 match->contents.assign(description); | 402 match->contents.assign(description); |
403 } | 403 } |
404 | 404 |
405 } // namespace extensions | 405 } // namespace extensions |
OLD | NEW |