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

Unified Diff: chrome/browser/extensions/api/command_line_private/command_line_private_api.cc

Issue 14027005: Implement Command Line Private extension API (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Fix paths in gyp and compile errors Created 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/command_line_private/command_line_private_api.cc
===================================================================
--- chrome/browser/extensions/api/command_line_private/command_line_private_api.cc (revision 0)
+++ chrome/browser/extensions/api/command_line_private/command_line_private_api.cc (revision 0)
@@ -0,0 +1,32 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/command_line_private/command_line_private_api.h"
+
+#include <string>
+
+#include "base/command_line.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "chrome/common/extensions/api/command_line_private.h"
+
+namespace command_line_private = extensions::api::command_line_private;
not at google - send to devlin 2013/04/15 06:08:45 can go inside the extensions { namespace below
方觉(Fang Jue) 2013/04/15 06:25:03 Done.
+
+namespace extensions {
+
+bool CommandLinePrivateHasSwitchFunction::RunImpl() {
+ scoped_ptr<command_line_private::HasSwitch::Params> params(
+ command_line_private::HasSwitch::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE(params.get());
not at google - send to devlin 2013/04/15 06:08:45 don't need .get()
方觉(Fang Jue) 2013/04/15 06:25:03 I looked at other API implementations (such as ala
not at google - send to devlin 2013/04/15 06:26:52 Nevertheless, you don't need .get().
+
+ if (params->name.empty())
+ return false;
not at google - send to devlin 2013/04/15 06:08:45 should also set error_ here
方觉(Fang Jue) 2013/04/15 06:25:03 Done.
+
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ bool result = command_line->HasSwitch(params->name);
+ SetResult(base::Value::CreateBooleanValue(result));
not at google - send to devlin 2013/04/15 06:08:45 typically I'd (a) inline most of this and (b) use
方觉(Fang Jue) 2013/04/15 06:25:03 Done.
+ return true;
+}
+
+} // namespace extensions
Property changes on: chrome/browser/extensions/api/command_line_private/command_line_private_api.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698