1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/api/command_line_private/command_line_private_api.h"
9 #include "base/command_line.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/values.h"
12 #include "chrome/common/extensions/api/command_line_private.h"
15 // This should be consistent with
16 // chrome/test/data/extensions/api_test/command_line/basics/test.js.
17 const char kEmptySwitchName
[] = "Switch name is empty.";
20 namespace extensions
{
22 namespace command_line_private
= api::command_line_private
;
24 bool CommandLinePrivateHasSwitchFunction::RunSync() {
25 scoped_ptr
<command_line_private::HasSwitch::Params
> params(
26 command_line_private::HasSwitch::Params::Create(*args_
));
27 EXTENSION_FUNCTION_VALIDATE(params
);
29 if (params
->name
.empty()) {
30 error_
= kEmptySwitchName
;
34 results_
= command_line_private::HasSwitch::Results::Create(
35 base::CommandLine::ForCurrentProcess()->HasSwitch(params
->name
));
39 } // namespace extensions