OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.text.TextUtils; | 7 import android.text.TextUtils; |
8 | 8 |
9 import org.chromium.base.CalledByNative; | |
9 import org.chromium.base.CollectionUtil; | 10 import org.chromium.base.CollectionUtil; |
10 | 11 |
11 import java.net.URI; | 12 import java.net.URI; |
12 import java.net.URISyntaxException; | 13 import java.net.URISyntaxException; |
13 import java.util.HashSet; | 14 import java.util.HashSet; |
14 | 15 |
15 /** | 16 /** |
16 * Utilities for working with URIs (and URLs). These methods may be used in secu rity-sensitive | 17 * Utilities for working with URIs (and URLs). These methods may be used in secu rity-sensitive |
17 * contexts (after all, origins are the security boundary on the web), and so th e correctness bar | 18 * contexts (after all, origins are the security boundary on the web), and so th e correctness bar |
18 * must be high. | 19 * must be high. |
19 */ | 20 */ |
20 public class UrlUtilities { | 21 public class UrlUtilities { |
21 /** | 22 /** |
22 * URI schemes that ContentView can handle. | 23 * URI schemes that ContentView can handle. |
23 */ | 24 */ |
24 private static final HashSet<String> ACCEPTED_SCHEMES = CollectionUtil.newHa shSet( | 25 private static final HashSet<String> ACCEPTED_SCHEMES = CollectionUtil.newHa shSet( |
25 "about", "data", "file", "http", "https", "inline", "javascript"); | 26 "about", "data", "file", "http", "https", "inline", "javascript"); |
davidben
2014/09/29 21:40:44
This list seems incomplete. Chrome can handle quit
Jaekyun Seok (inactive)
2014/09/29 22:17:18
I don't know well about this list. But most of oth
| |
26 | 27 |
27 /** | 28 /** |
28 * URI schemes that Chrome can download. | 29 * URI schemes that Chrome can download. |
29 */ | 30 */ |
30 private static final HashSet<String> DOWNLOADABLE_SCHEMES = CollectionUtil.n ewHashSet( | 31 private static final HashSet<String> DOWNLOADABLE_SCHEMES = CollectionUtil.n ewHashSet( |
31 "data", "filesystem", "http", "https"); | 32 "data", "filesystem", "http", "https"); |
32 | 33 |
33 /** | 34 /** |
34 * @param uri A URI. | 35 * @param uri A URI. |
35 * | 36 * |
36 * @return True if the URI's scheme is one that ContentView can handle. | 37 * @return True if the URI's scheme is one that ContentView can handle. |
37 */ | 38 */ |
38 public static boolean isAcceptedScheme(URI uri) { | 39 public static boolean isAcceptedScheme(URI uri) { |
39 return ACCEPTED_SCHEMES.contains(uri.getScheme()); | 40 return ACCEPTED_SCHEMES.contains(uri.getScheme()); |
40 } | 41 } |
41 | 42 |
42 /** | 43 /** |
43 * @param uri A URI. | 44 * @param uri A URI. |
44 * | 45 * |
45 * @return True if the URI's scheme is one that ContentView can handle. | 46 * @return True if the URI's scheme is one that ContentView can handle. |
46 */ | 47 */ |
48 @CalledByNative | |
47 public static boolean isAcceptedScheme(String uri) { | 49 public static boolean isAcceptedScheme(String uri) { |
48 try { | 50 try { |
49 return isAcceptedScheme(new URI(uri)); | 51 return isAcceptedScheme(new URI(uri)); |
50 } catch (URISyntaxException e) { | 52 } catch (URISyntaxException e) { |
51 return false; | 53 return false; |
52 } | 54 } |
53 } | 55 } |
54 | 56 |
55 /** | 57 /** |
56 * @param uri A URI. | 58 * @param uri A URI. |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 | 210 |
209 private static native boolean nativeSameDomainOrHost(String primaryUrl, Stri ng secondaryUrl, | 211 private static native boolean nativeSameDomainOrHost(String primaryUrl, Stri ng secondaryUrl, |
210 boolean includePrivateRegistries); | 212 boolean includePrivateRegistries); |
211 private static native String nativeGetDomainAndRegistry(String url, | 213 private static native String nativeGetDomainAndRegistry(String url, |
212 boolean includePrivateRegistries); | 214 boolean includePrivateRegistries); |
213 public static native boolean nativeIsGoogleSearchUrl(String url); | 215 public static native boolean nativeIsGoogleSearchUrl(String url); |
214 public static native boolean nativeIsGoogleHomePageUrl(String url); | 216 public static native boolean nativeIsGoogleHomePageUrl(String url); |
215 public static native String nativeFixupUrl(String url, String desiredTld); | 217 public static native String nativeFixupUrl(String url, String desiredTld); |
216 private static native boolean nativeIsGooglePropertyUrl(String url); | 218 private static native boolean nativeIsGooglePropertyUrl(String url); |
217 } | 219 } |
OLD | NEW |