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

Side by Side Diff: content/browser/android/command_line.cc

Issue 10377059: Android content shell bringup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix deps so builds on clean machine Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/android/command_line.h ('k') | content/browser/android/content_jni_registrar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/android/command_line.h"
6
7 #include "base/android/jni_string.h"
8 #include "base/command_line.h"
9 #include "base/logging.h"
10 #include "jni/command_line_jni.h"
11 #include "content/browser/android/jni_helper.h"
12
13 using base::android::ConvertJavaStringToUTF8;
14
15 namespace {
16
17 void AppendJavaStringArrayToCommandLine(JNIEnv* env,
18 jobjectArray array,
19 bool includes_program) {
20 CommandLine::StringVector vec;
21 if (array)
22 ConvertJavaArrayOfStringsToVectorOfStrings(env, array, &vec);
23 if (!includes_program)
24 vec.insert(vec.begin(), "");
25 CommandLine extra_command_line(vec);
26 CommandLine::ForCurrentProcess()->AppendArguments(extra_command_line,
27 includes_program);
28 }
29
30 } // namespace
31
32 static void Reset(JNIEnv* env, jclass clazz) {
33 CommandLine::Reset();
34 }
35
36 static jboolean HasSwitch(JNIEnv* env, jclass clazz, jstring jswitch) {
37 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch));
38 return CommandLine::ForCurrentProcess()->HasSwitch(switch_string);
39 }
40
41 static jstring GetSwitchValue(JNIEnv* env, jclass clazz, jstring jswitch) {
42 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch));
43 std::string value(CommandLine::ForCurrentProcess()->GetSwitchValueNative(
44 switch_string));
45 if (value.empty())
46 return 0;
47 // OK to release, JNI binding.
48 return base::android::ConvertUTF8ToJavaString(env, value).Release();
49 }
50
51 static void AppendSwitch(JNIEnv* env, jclass clazz, jstring jswitch) {
52 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch));
53 CommandLine::ForCurrentProcess()->AppendSwitch(switch_string);
54 }
55
56 static void AppendSwitchWithValue(JNIEnv* env, jclass clazz,
57 jstring jswitch, jstring jvalue) {
58 std::string switch_string(ConvertJavaStringToUTF8(env, jswitch));
59 std::string value_string (ConvertJavaStringToUTF8(env, jvalue));
60 CommandLine::ForCurrentProcess()->AppendSwitchASCII(switch_string,
61 value_string);
62 }
63
64 static void AppendSwitchesAndArguments(JNIEnv* env, jclass clazz,
65 jobjectArray array) {
66 AppendJavaStringArrayToCommandLine(env, array, false);
67 }
68
69 void InitNativeCommandLineFromJavaArray(JNIEnv* env, jobjectArray array) {
70 // TODO(port): Make an overload of Init() that takes StringVector rather than
71 // have to round-trip via AppendArguments.
72 CommandLine::Init(0, NULL);
73 AppendJavaStringArrayToCommandLine(env, array, true);
74 }
75
76 bool RegisterCommandLine(JNIEnv* env) {
77 return RegisterNativesImpl(env);
78 }
OLDNEW
« no previous file with comments | « content/browser/android/command_line.h ('k') | content/browser/android/content_jni_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698