1 // Copyright 2014 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.components.dom_distiller.core; 6 7 import org.chromium.base.JNINamespace; 8 9 /** 10 * Wrapper for the dom_distiller::url_utils. 11 */ 12 @JNINamespace("dom_distiller::url_utils::android") 13 public final class DomDistillerUrlUtils { 14 private DomDistillerUrlUtils() { 15 } 16 17 /** 18 * Returns the URL for viewing distilled content for a URL. 19 * 20 * @param scheme The scheme for the DOM Distiller source. 21 * @param url The URL to distill. 22 * @return the URL to load to get the distilled version of a page. 23 */ 24 public static String getDistillerViewUrlFromUrl(String scheme, String url) { 25 return nativeGetDistillerViewUrlFromUrl(scheme, url); 26 } 27 28 /** 29 * Returns the original URL of a distillation given the viewer URL. 30 * 31 * @param url The current viewer URL. 32 * @return the URL of the original page. 33 */ 34 public static String getOriginalUrlFromDistillerUrl(String url) { 35 return nativeGetOriginalUrlFromDistillerUrl(url); 36 } 37 38 /** 39 * Returns whether the url is for a distilled page. 40 * 41 * @param url The url of the page. 42 * @return whether the url is for a distilled page. 43 */ 44 public static boolean isDistilledPage(String url) { 45 return nativeIsDistilledPage(url); 46 } 47 48 public static boolean isUrlDistillable(String url) { 49 return nativeIsUrlDistillable(url); 50 } 51 52 // TODO(yfriedman): Change method so that it takes in a WebContents and a 53 // callback. 54 public static String getIsDistillableJs() { 55 return nativeGetIsDistillableJs(); 56 } 57 58 public static String getValueForKeyInUrl(String url, String key) { 59 return nativeGetValueForKeyInUrl(url, key); 60 } 61 62 private static native String nativeGetDistillerViewUrlFromUrl(String scheme, String url); 63 private static native String nativeGetIsDistillableJs(); 64 private static native String nativeGetOriginalUrlFromDistillerUrl(String viewerUrl); 65 private static native boolean nativeIsDistilledPage(String url); 66 private static native boolean nativeIsUrlDistillable(String url); 67 private static native String nativeGetValueForKeyInUrl(String url, String key); 68 } 69