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

Side by Side Diff: chrome/browser/extensions/api/terminal/terminal_private_api.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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/terminal/terminal_private_api.h" 5 #include "chrome/browser/extensions/api/terminal/terminal_private_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 const std::string& output_type, 60 const std::string& output_type,
61 const std::string& output) { 61 const std::string& output) {
62 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { 62 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
63 content::BrowserThread::PostTask( 63 content::BrowserThread::PostTask(
64 content::BrowserThread::UI, FROM_HERE, 64 content::BrowserThread::UI, FROM_HERE,
65 base::Bind(&NotifyProcessOutput, browser_context, extension_id, tab_id, 65 base::Bind(&NotifyProcessOutput, browser_context, extension_id, tab_id,
66 terminal_id, output_type, output)); 66 terminal_id, output_type, output));
67 return; 67 return;
68 } 68 }
69 69
70 scoped_ptr<base::ListValue> args(new base::ListValue()); 70 std::unique_ptr<base::ListValue> args(new base::ListValue());
71 args->Append(new base::FundamentalValue(tab_id)); 71 args->Append(new base::FundamentalValue(tab_id));
72 args->Append(new base::FundamentalValue(terminal_id)); 72 args->Append(new base::FundamentalValue(terminal_id));
73 args->Append(new base::StringValue(output_type)); 73 args->Append(new base::StringValue(output_type));
74 args->Append(new base::StringValue(output)); 74 args->Append(new base::StringValue(output));
75 75
76 extensions::EventRouter* event_router = 76 extensions::EventRouter* event_router =
77 extensions::EventRouter::Get(browser_context); 77 extensions::EventRouter::Get(browser_context);
78 if (event_router) { 78 if (event_router) {
79 scoped_ptr<extensions::Event> event(new extensions::Event( 79 std::unique_ptr<extensions::Event> event(new extensions::Event(
80 extensions::events::TERMINAL_PRIVATE_ON_PROCESS_OUTPUT, 80 extensions::events::TERMINAL_PRIVATE_ON_PROCESS_OUTPUT,
81 terminal_private::OnProcessOutput::kEventName, std::move(args))); 81 terminal_private::OnProcessOutput::kEventName, std::move(args)));
82 event_router->DispatchEventToExtension(extension_id, std::move(event)); 82 event_router->DispatchEventToExtension(extension_id, std::move(event));
83 } 83 }
84 } 84 }
85 85
86 // Returns tab ID, or window session ID (for platform apps) for |web_contents|. 86 // Returns tab ID, or window session ID (for platform apps) for |web_contents|.
87 int GetTabOrWindowSessionId(content::BrowserContext* browser_context, 87 int GetTabOrWindowSessionId(content::BrowserContext* browser_context,
88 content::WebContents* web_contents) { 88 content::WebContents* web_contents) {
89 int tab_id = extensions::ExtensionTabUtil::GetTabId(web_contents); 89 int tab_id = extensions::ExtensionTabUtil::GetTabId(web_contents);
(...skipping 10 matching lines...) Expand all
100 namespace extensions { 100 namespace extensions {
101 101
102 TerminalPrivateOpenTerminalProcessFunction:: 102 TerminalPrivateOpenTerminalProcessFunction::
103 TerminalPrivateOpenTerminalProcessFunction() : command_(NULL) {} 103 TerminalPrivateOpenTerminalProcessFunction() : command_(NULL) {}
104 104
105 TerminalPrivateOpenTerminalProcessFunction:: 105 TerminalPrivateOpenTerminalProcessFunction::
106 ~TerminalPrivateOpenTerminalProcessFunction() {} 106 ~TerminalPrivateOpenTerminalProcessFunction() {}
107 107
108 ExtensionFunction::ResponseAction 108 ExtensionFunction::ResponseAction
109 TerminalPrivateOpenTerminalProcessFunction::Run() { 109 TerminalPrivateOpenTerminalProcessFunction::Run() {
110 scoped_ptr<OpenTerminalProcess::Params> params( 110 std::unique_ptr<OpenTerminalProcess::Params> params(
111 OpenTerminalProcess::Params::Create(*args_)); 111 OpenTerminalProcess::Params::Create(*args_));
112 EXTENSION_FUNCTION_VALIDATE(params.get()); 112 EXTENSION_FUNCTION_VALIDATE(params.get());
113 113
114 command_ = GetProcessCommandForName(params->process_name); 114 command_ = GetProcessCommandForName(params->process_name);
115 if (!command_) 115 if (!command_)
116 return RespondNow(Error("Invalid process name.")); 116 return RespondNow(Error("Invalid process name."));
117 117
118 content::WebContents* caller_contents = GetSenderWebContents(); 118 content::WebContents* caller_contents = GetSenderWebContents();
119 if (!caller_contents) 119 if (!caller_contents)
120 return RespondNow(Error("No web contents.")); 120 return RespondNow(Error("No web contents."));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (terminal_id < 0) { 167 if (terminal_id < 0) {
168 SetError("Failed to open process."); 168 SetError("Failed to open process.");
169 SendResponse(false); 169 SendResponse(false);
170 return; 170 return;
171 } 171 }
172 SetResult(new base::FundamentalValue(terminal_id)); 172 SetResult(new base::FundamentalValue(terminal_id));
173 SendResponse(true); 173 SendResponse(true);
174 } 174 }
175 175
176 ExtensionFunction::ResponseAction TerminalPrivateSendInputFunction::Run() { 176 ExtensionFunction::ResponseAction TerminalPrivateSendInputFunction::Run() {
177 scoped_ptr<SendInput::Params> params(SendInput::Params::Create(*args_)); 177 std::unique_ptr<SendInput::Params> params(SendInput::Params::Create(*args_));
178 EXTENSION_FUNCTION_VALIDATE(params.get()); 178 EXTENSION_FUNCTION_VALIDATE(params.get());
179 179
180 // Registry lives on the FILE thread. 180 // Registry lives on the FILE thread.
181 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, 181 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE,
182 base::Bind(&TerminalPrivateSendInputFunction::SendInputOnFileThread, 182 base::Bind(&TerminalPrivateSendInputFunction::SendInputOnFileThread,
183 this, params->pid, params->input)); 183 this, params->pid, params->input));
184 return RespondLater(); 184 return RespondLater();
185 } 185 }
186 186
187 void TerminalPrivateSendInputFunction::SendInputOnFileThread( 187 void TerminalPrivateSendInputFunction::SendInputOnFileThread(
(...skipping 11 matching lines...) Expand all
199 void TerminalPrivateSendInputFunction::RespondOnUIThread(bool success) { 199 void TerminalPrivateSendInputFunction::RespondOnUIThread(bool success) {
200 SetResult(new base::FundamentalValue(success)); 200 SetResult(new base::FundamentalValue(success));
201 SendResponse(true); 201 SendResponse(true);
202 } 202 }
203 203
204 TerminalPrivateCloseTerminalProcessFunction:: 204 TerminalPrivateCloseTerminalProcessFunction::
205 ~TerminalPrivateCloseTerminalProcessFunction() {} 205 ~TerminalPrivateCloseTerminalProcessFunction() {}
206 206
207 ExtensionFunction::ResponseAction 207 ExtensionFunction::ResponseAction
208 TerminalPrivateCloseTerminalProcessFunction::Run() { 208 TerminalPrivateCloseTerminalProcessFunction::Run() {
209 scoped_ptr<CloseTerminalProcess::Params> params( 209 std::unique_ptr<CloseTerminalProcess::Params> params(
210 CloseTerminalProcess::Params::Create(*args_)); 210 CloseTerminalProcess::Params::Create(*args_));
211 EXTENSION_FUNCTION_VALIDATE(params.get()); 211 EXTENSION_FUNCTION_VALIDATE(params.get());
212 212
213 // Registry lives on the FILE thread. 213 // Registry lives on the FILE thread.
214 content::BrowserThread::PostTask( 214 content::BrowserThread::PostTask(
215 content::BrowserThread::FILE, FROM_HERE, 215 content::BrowserThread::FILE, FROM_HERE,
216 base::Bind( 216 base::Bind(
217 &TerminalPrivateCloseTerminalProcessFunction::CloseOnFileThread, this, 217 &TerminalPrivateCloseTerminalProcessFunction::CloseOnFileThread, this,
218 params->pid)); 218 params->pid));
219 219
(...skipping 14 matching lines...) Expand all
234 bool success) { 234 bool success) {
235 SetResult(new base::FundamentalValue(success)); 235 SetResult(new base::FundamentalValue(success));
236 SendResponse(true); 236 SendResponse(true);
237 } 237 }
238 238
239 TerminalPrivateOnTerminalResizeFunction:: 239 TerminalPrivateOnTerminalResizeFunction::
240 ~TerminalPrivateOnTerminalResizeFunction() {} 240 ~TerminalPrivateOnTerminalResizeFunction() {}
241 241
242 ExtensionFunction::ResponseAction 242 ExtensionFunction::ResponseAction
243 TerminalPrivateOnTerminalResizeFunction::Run() { 243 TerminalPrivateOnTerminalResizeFunction::Run() {
244 scoped_ptr<OnTerminalResize::Params> params( 244 std::unique_ptr<OnTerminalResize::Params> params(
245 OnTerminalResize::Params::Create(*args_)); 245 OnTerminalResize::Params::Create(*args_));
246 EXTENSION_FUNCTION_VALIDATE(params.get()); 246 EXTENSION_FUNCTION_VALIDATE(params.get());
247 247
248 // Registry lives on the FILE thread. 248 // Registry lives on the FILE thread.
249 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, 249 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE,
250 base::Bind(&TerminalPrivateOnTerminalResizeFunction::OnResizeOnFileThread, 250 base::Bind(&TerminalPrivateOnTerminalResizeFunction::OnResizeOnFileThread,
251 this, params->pid, params->width, params->height)); 251 this, params->pid, params->width, params->height));
252 252
253 return RespondLater(); 253 return RespondLater();
254 } 254 }
(...skipping 11 matching lines...) Expand all
266 } 266 }
267 267
268 void TerminalPrivateOnTerminalResizeFunction::RespondOnUIThread(bool success) { 268 void TerminalPrivateOnTerminalResizeFunction::RespondOnUIThread(bool success) {
269 SetResult(new base::FundamentalValue(success)); 269 SetResult(new base::FundamentalValue(success));
270 SendResponse(true); 270 SendResponse(true);
271 } 271 }
272 272
273 TerminalPrivateAckOutputFunction::~TerminalPrivateAckOutputFunction() {} 273 TerminalPrivateAckOutputFunction::~TerminalPrivateAckOutputFunction() {}
274 274
275 ExtensionFunction::ResponseAction TerminalPrivateAckOutputFunction::Run() { 275 ExtensionFunction::ResponseAction TerminalPrivateAckOutputFunction::Run() {
276 scoped_ptr<AckOutput::Params> params(AckOutput::Params::Create(*args_)); 276 std::unique_ptr<AckOutput::Params> params(AckOutput::Params::Create(*args_));
277 EXTENSION_FUNCTION_VALIDATE(params.get()); 277 EXTENSION_FUNCTION_VALIDATE(params.get());
278 278
279 content::WebContents* caller_contents = GetSenderWebContents(); 279 content::WebContents* caller_contents = GetSenderWebContents();
280 if (!caller_contents) 280 if (!caller_contents)
281 return RespondNow(Error("No web contents.")); 281 return RespondNow(Error("No web contents."));
282 282
283 int tab_id = GetTabOrWindowSessionId(browser_context(), caller_contents); 283 int tab_id = GetTabOrWindowSessionId(browser_context(), caller_contents);
284 if (tab_id < 0) 284 if (tab_id < 0)
285 return RespondNow(Error("Not called from a tab or app window")); 285 return RespondNow(Error("Not called from a tab or app window"));
286 286
287 if (tab_id != params->tab_id) 287 if (tab_id != params->tab_id)
288 return RespondNow(NoArguments()); 288 return RespondNow(NoArguments());
289 289
290 // Registry lives on the FILE thread. 290 // Registry lives on the FILE thread.
291 content::BrowserThread::PostTask( 291 content::BrowserThread::PostTask(
292 content::BrowserThread::FILE, FROM_HERE, 292 content::BrowserThread::FILE, FROM_HERE,
293 base::Bind(&TerminalPrivateAckOutputFunction::AckOutputOnFileThread, this, 293 base::Bind(&TerminalPrivateAckOutputFunction::AckOutputOnFileThread, this,
294 params->pid)); 294 params->pid));
295 295
296 return RespondNow(NoArguments()); 296 return RespondNow(NoArguments());
297 } 297 }
298 298
299 void TerminalPrivateAckOutputFunction::AckOutputOnFileThread(int terminal_id) { 299 void TerminalPrivateAckOutputFunction::AckOutputOnFileThread(int terminal_id) {
300 chromeos::ProcessProxyRegistry::Get()->AckOutput(terminal_id); 300 chromeos::ProcessProxyRegistry::Get()->AckOutput(terminal_id);
301 } 301 }
302 302
303 } // namespace extensions 303 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/tabs/windows_event_router.cc ('k') | chrome/browser/extensions/api/top_sites/top_sites_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698