1/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.webkit;
18
19import android.util.Log;
20
21import java.net.MalformedURLException;
22import java.net.URL;
23
24// TODO: Move these to a better place.
25/* package */ abstract class WebTextView {
26
27    private static final String LOGTAG = "WebTextView";
28
29    // Types used with setType.  Keep in sync with CachedInput.h
30    static final int NORMAL_TEXT_FIELD = 0;
31    static final int TEXT_AREA = 1;
32    static final int PASSWORD = 2;
33    static final int SEARCH = 3;
34    static final int EMAIL = 4;
35    static final int NUMBER = 5;
36    static final int TELEPHONE = 6;
37    static final int URL = 7;
38
39    static final int FORM_NOT_AUTOFILLABLE = -1;
40
41    static String urlForAutoCompleteData(String urlString) {
42        // Remove any fragment or query string.
43        URL url = null;
44        try {
45            url = new URL(urlString);
46        } catch (MalformedURLException e) {
47            Log.e(LOGTAG, "Unable to parse URL "+url);
48        }
49
50        return url != null ? url.getProtocol() + "://" + url.getHost() + url.getPath() : null;
51    }
52
53}
54