• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 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 package org.chromium.content.browser;
6 
7 import android.content.Context;
8 
9 import org.chromium.base.CommandLine;
10 import org.chromium.content.common.ContentSwitches;
11 import org.chromium.ui.base.DeviceFormFactor;
12 
13 /**
14  * A utility class that has helper methods for device configuration.
15  */
16 public class DeviceUtils {
17 
18     /**
19      * @param context Android's context
20      * @return        Whether the app is should treat the device as a tablet for layout.
21      */
22     // TODO(tedchoc): Transition all call sites to use DeviceFormFactor directly.  Then
23     //                remove this method.
isTablet(Context context)24     public static boolean isTablet(Context context) {
25         return DeviceFormFactor.isTablet(context);
26     }
27 
28     /**
29      * Appends the switch specifying which user agent should be used for this device.
30      * @param context The context for the caller activity.
31      */
addDeviceSpecificUserAgentSwitch(Context context)32     public static void addDeviceSpecificUserAgentSwitch(Context context) {
33         if (!isTablet(context)) {
34             CommandLine.getInstance().appendSwitch(ContentSwitches.USE_MOBILE_UA);
35         }
36     }
37 }
38