1 /******************************************************************************* |
|
2 * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Symbian Foundation - initial contribution. |
|
11 * Contributors: |
|
12 * Description: |
|
13 * Overview: |
|
14 * Details: |
|
15 * Platforms/Drives/Compatibility: |
|
16 * Assumptions/Requirement/Pre-requisites: |
|
17 * Failures and causes: |
|
18 *******************************************************************************/ |
|
19 package org.symbian.tools.wrttools.debug.internal; |
|
20 |
|
21 import java.io.File; |
|
22 |
|
23 import org.symbian.tools.wrttools.util.CoreUtil; |
|
24 |
|
25 public final class ChromeDebugUtils { |
|
26 public static String getExecutablePath(String folder) { |
|
27 File file = new File(folder); |
|
28 if (file.isDirectory()) { |
|
29 File chromeExecutable = new File(file, getExecutable()); |
|
30 if (chromeExecutable.isFile()) { |
|
31 return chromeExecutable.getAbsolutePath(); |
|
32 } else if (CoreUtil.isMac() && file.getName().equals("Google Chrome.app")) { |
|
33 return getExecutablePath(file.getParent()); |
|
34 } |
|
35 } else if (file.isFile()) { |
|
36 if (file.getName().equalsIgnoreCase(getExecutable())) { |
|
37 return file.getAbsolutePath(); |
|
38 } |
|
39 } |
|
40 return null; |
|
41 } |
|
42 |
|
43 private static String getExecutable() { |
|
44 // Add more ifs as we add support for new platforms |
|
45 if (CoreUtil.isMac()) { |
|
46 return "Google Chrome.app/Contents/MacOS/Google Chrome"; |
|
47 } else if (CoreUtil.isLinux()) { |
|
48 return "chrome"; |
|
49 } else { |
|
50 return "chrome.exe"; |
|
51 } |
|
52 } |
|
53 |
|
54 private ChromeDebugUtils() { |
|
55 // No instantiating |
|
56 } |
|
57 |
|
58 public static String getChromeExecutible() { |
|
59 return getExecutablePath(Activator.getDefault().getPreferenceStore().getString(IConstants.PREF_NAME_CHROME_LOCATION)); |
|
60 } |
|
61 |
|
62 } |
|