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

Unified Diff: chrome/browser/extensions/api/terminal/terminal_private_api.cc

Issue 2579833005: chrome: Add support for custom crosh command. (Closed)
Patch Set: remove else Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/api/terminal/terminal_private_api.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/terminal/terminal_private_api.cc
diff --git a/chrome/browser/extensions/api/terminal/terminal_private_api.cc b/chrome/browser/extensions/api/terminal/terminal_private_api.cc
index 3e7db7188c3a08b82857a2c11c761b8ec12de629..f42859dff1005c105f0b6104017d9988f7ba76f6 100644
--- a/chrome/browser/extensions/api/terminal/terminal_private_api.cc
+++ b/chrome/browser/extensions/api/terminal/terminal_private_api.cc
@@ -7,6 +7,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/json/json_writer.h"
#include "base/memory/ptr_util.h"
#include "base/sys_info.h"
@@ -14,6 +15,7 @@
#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
+#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/api/terminal_private.h"
#include "chromeos/process_proxy/process_proxy_registry.h"
#include "content/public/browser/browser_context.h"
@@ -40,18 +42,22 @@ const char kCroshCommand[] = "/usr/bin/crosh";
// We make stubbed crosh just echo back input.
const char kStubbedCroshCommand[] = "cat";
-const char* GetCroshPath() {
+std::string GetCroshPath() {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(switches::kCroshCommand))
+ return command_line->GetSwitchValueASCII(switches::kCroshCommand);
+
if (base::SysInfo::IsRunningOnChromeOS())
- return kCroshCommand;
- else
- return kStubbedCroshCommand;
+ return std::string(kCroshCommand);
+
+ return std::string(kStubbedCroshCommand);
}
-const char* GetProcessCommandForName(const std::string& name) {
+std::string GetProcessCommandForName(const std::string& name) {
if (name == kCroshName)
return GetCroshPath();
else
- return NULL;
+ return std::string();
}
void NotifyProcessOutput(content::BrowserContext* browser_context,
@@ -101,7 +107,7 @@ int GetTabOrWindowSessionId(content::BrowserContext* browser_context,
namespace extensions {
TerminalPrivateOpenTerminalProcessFunction::
- TerminalPrivateOpenTerminalProcessFunction() : command_(NULL) {}
+ TerminalPrivateOpenTerminalProcessFunction() {}
TerminalPrivateOpenTerminalProcessFunction::
~TerminalPrivateOpenTerminalProcessFunction() {}
@@ -113,7 +119,7 @@ TerminalPrivateOpenTerminalProcessFunction::Run() {
EXTENSION_FUNCTION_VALIDATE(params.get());
command_ = GetProcessCommandForName(params->process_name);
- if (!command_)
+ if (command_.empty())
return RespondNow(Error("Invalid process name."));
content::WebContents* caller_contents = GetSenderWebContents();
@@ -150,12 +156,12 @@ TerminalPrivateOpenTerminalProcessFunction::Run() {
void TerminalPrivateOpenTerminalProcessFunction::OpenOnFileThread(
const ProcessOutputCallback& output_callback,
const OpenProcessCallback& callback) {
- DCHECK(command_);
+ DCHECK(!command_.empty());
chromeos::ProcessProxyRegistry* registry =
chromeos::ProcessProxyRegistry::Get();
- int terminal_id = registry->OpenProcess(command_, output_callback);
+ int terminal_id = registry->OpenProcess(command_.c_str(), output_callback);
content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
base::Bind(callback, terminal_id));
« no previous file with comments | « chrome/browser/extensions/api/terminal/terminal_private_api.h ('k') | chrome/common/chrome_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698