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

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

Issue 2257113002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // This URL is not actually used for navigation. It holds the extension's ID. 98 // This URL is not actually used for navigation. It holds the extension's ID.
99 return std::string(extensions::kExtensionScheme) + "://" + 99 return std::string(extensions::kExtensionScheme) + "://" +
100 extension_id + "/?q={searchTerms}"; 100 extension_id + "/?q={searchTerms}";
101 } 101 }
102 102
103 } // namespace 103 } // namespace
104 104
105 // static 105 // static
106 void ExtensionOmniboxEventRouter::OnInputStarted( 106 void ExtensionOmniboxEventRouter::OnInputStarted(
107 Profile* profile, const std::string& extension_id) { 107 Profile* profile, const std::string& extension_id) {
108 std::unique_ptr<Event> event(new Event( 108 std::unique_ptr<Event> event(new Event(events::OMNIBOX_ON_INPUT_STARTED,
Devlin 2016/08/29 15:10:01 optional: use MakeUnique here?
Adam Rice 2016/08/30 07:03:00 Done.
109 events::OMNIBOX_ON_INPUT_STARTED, omnibox::OnInputStarted::kEventName, 109 omnibox::OnInputStarted::kEventName,
110 base::WrapUnique(new base::ListValue()))); 110 base::MakeUnique<base::ListValue>()));
111 event->restrict_to_browser_context = profile; 111 event->restrict_to_browser_context = profile;
112 EventRouter::Get(profile) 112 EventRouter::Get(profile)
113 ->DispatchEventToExtension(extension_id, std::move(event)); 113 ->DispatchEventToExtension(extension_id, std::move(event));
114 } 114 }
115 115
116 // static 116 // static
117 bool ExtensionOmniboxEventRouter::OnInputChanged( 117 bool ExtensionOmniboxEventRouter::OnInputChanged(
118 Profile* profile, const std::string& extension_id, 118 Profile* profile, const std::string& extension_id,
119 const std::string& input, int suggest_id) { 119 const std::string& input, int suggest_id) {
120 EventRouter* event_router = EventRouter::Get(profile); 120 EventRouter* event_router = EventRouter::Get(profile);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 168
169 content::NotificationService::current()->Notify( 169 content::NotificationService::current()->Notify(
170 extensions::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED, 170 extensions::NOTIFICATION_EXTENSION_OMNIBOX_INPUT_ENTERED,
171 content::Source<Profile>(profile), 171 content::Source<Profile>(profile),
172 content::NotificationService::NoDetails()); 172 content::NotificationService::NoDetails());
173 } 173 }
174 174
175 // static 175 // static
176 void ExtensionOmniboxEventRouter::OnInputCancelled( 176 void ExtensionOmniboxEventRouter::OnInputCancelled(
177 Profile* profile, const std::string& extension_id) { 177 Profile* profile, const std::string& extension_id) {
178 std::unique_ptr<Event> event(new Event( 178 std::unique_ptr<Event> event(new Event(events::OMNIBOX_ON_INPUT_CANCELLED,
Devlin 2016/08/29 15:10:01 ditto
Adam Rice 2016/08/30 07:03:00 Done.
179 events::OMNIBOX_ON_INPUT_CANCELLED, omnibox::OnInputCancelled::kEventName, 179 omnibox::OnInputCancelled::kEventName,
180 base::WrapUnique(new base::ListValue()))); 180 base::MakeUnique<base::ListValue>()));
181 event->restrict_to_browser_context = profile; 181 event->restrict_to_browser_context = profile;
182 EventRouter::Get(profile) 182 EventRouter::Get(profile)
183 ->DispatchEventToExtension(extension_id, std::move(event)); 183 ->DispatchEventToExtension(extension_id, std::move(event));
184 } 184 }
185 185
186 OmniboxAPI::OmniboxAPI(content::BrowserContext* context) 186 OmniboxAPI::OmniboxAPI(content::BrowserContext* context)
187 : profile_(Profile::FromBrowserContext(context)), 187 : profile_(Profile::FromBrowserContext(context)),
188 url_service_(TemplateURLServiceFactory::GetForProfile(profile_)), 188 url_service_(TemplateURLServiceFactory::GetForProfile(profile_)),
189 extension_registry_observer_(this) { 189 extension_registry_observer_(this) {
190 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); 190 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 for (size_t i = 0; i < description_styles.size(); ++i) { 393 for (size_t i = 0; i < description_styles.size(); ++i) {
394 if (description_styles[i].offset > placeholder) 394 if (description_styles[i].offset > placeholder)
395 description_styles[i].offset += replacement.length() - 2; 395 description_styles[i].offset += replacement.length() - 2;
396 } 396 }
397 } 397 }
398 398
399 match->contents.assign(description); 399 match->contents.assign(description);
400 } 400 }
401 401
402 } // namespace extensions 402 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698