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.
4 
5 package org.chromium.content.common;
6 
7 /**
8  * Util class that handles command line switches that are specific to the content/
9  * portion of Chromium on Android.
10  */
11 public final class ContentSwitchUtils {
12     // Prevent instantiation.
ContentSwitchUtils()13     private ContentSwitchUtils() {}
14 
getSwitchValue(final String[] commandLine, String switchKey)15     public static String getSwitchValue(final String[] commandLine, String switchKey) {
16         if (commandLine == null || switchKey == null) {
17             return null;
18         }
19         // This format should be matched with the one defined in command_line.h.
20         final String switchKeyPrefix = "--" + switchKey + "=";
21         for (String command : commandLine) {
22             if (command != null && command.startsWith(switchKeyPrefix)) {
23                 return command.substring(switchKeyPrefix.length());
24             }
25         }
26         return null;
27     }
28 }
29