| 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/terminal/terminal_private_api.h" | 5 #include "chrome/browser/extensions/api/terminal/terminal_private_api.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/chromeos/chromeos_version.h" | 8 #include "base/chromeos/chromeos_version.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 pid_t pid, | 43 pid_t pid, |
| 44 const std::string& output_type, | 44 const std::string& output_type, |
| 45 const std::string& output) { | 45 const std::string& output) { |
| 46 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { | 46 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
| 47 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 47 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 48 base::Bind(&NotifyProcessOutput, profile, extension_id, | 48 base::Bind(&NotifyProcessOutput, profile, extension_id, |
| 49 pid, output_type, output)); | 49 pid, output_type, output)); |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 | 52 |
| 53 base::ListValue args; | 53 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 54 args.Append(new base::FundamentalValue(pid)); | 54 args->Append(new base::FundamentalValue(pid)); |
| 55 args.Append(new base::StringValue(output_type)); | 55 args->Append(new base::StringValue(output_type)); |
| 56 args.Append(new base::StringValue(output)); | 56 args->Append(new base::StringValue(output)); |
| 57 | |
| 58 std::string args_json; | |
| 59 base::JSONWriter::Write(&args, &args_json); | |
| 60 | 57 |
| 61 if (profile && profile->GetExtensionEventRouter()) { | 58 if (profile && profile->GetExtensionEventRouter()) { |
| 62 profile->GetExtensionEventRouter()->DispatchEventToExtension( | 59 profile->GetExtensionEventRouter()->DispatchEventToExtension( |
| 63 extension_id, extensions::event_names::kOnTerminalProcessOutput, | 60 extension_id, extensions::event_names::kOnTerminalProcessOutput, |
| 64 args_json, NULL, GURL()); | 61 args.Pass(), NULL, GURL()); |
| 65 } | 62 } |
| 66 } | 63 } |
| 67 | 64 |
| 68 } // namespace | 65 } // namespace |
| 69 | 66 |
| 70 TerminalPrivateFunction::TerminalPrivateFunction() {} | 67 TerminalPrivateFunction::TerminalPrivateFunction() {} |
| 71 | 68 |
| 72 TerminalPrivateFunction::~TerminalPrivateFunction() {} | 69 TerminalPrivateFunction::~TerminalPrivateFunction() {} |
| 73 | 70 |
| 74 bool TerminalPrivateFunction::RunImpl() { | 71 bool TerminalPrivateFunction::RunImpl() { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 210 |
| 214 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 211 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 215 base::Bind(&OnTerminalResizeFunction::RespondOnUIThread, this, | 212 base::Bind(&OnTerminalResizeFunction::RespondOnUIThread, this, |
| 216 success)); | 213 success)); |
| 217 } | 214 } |
| 218 | 215 |
| 219 void OnTerminalResizeFunction::RespondOnUIThread(bool success) { | 216 void OnTerminalResizeFunction::RespondOnUIThread(bool success) { |
| 220 SetResult(new base::FundamentalValue(success)); | 217 SetResult(new base::FundamentalValue(success)); |
| 221 SendResponse(true); | 218 SendResponse(true); |
| 222 } | 219 } |
| OLD | NEW |