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
5package org.chromium.chrome.browser.dom_distiller;
6
7import org.chromium.base.JNINamespace;
8import org.chromium.content_public.browser.WebContents;
9
10/**
11 * A helper class for using the DOM Distiller.
12 */
13@JNINamespace("android")
14public class DomDistillerTabUtils {
15
16    private DomDistillerTabUtils() {
17    }
18
19    /**
20     * Creates a new WebContents and navigates the {@link WebContents} to view the URL of the
21     * current page, while in the background starts distilling the current page. This method takes
22     * ownership over the old WebContents after swapping in the new one.
23     *
24     * @param webContents the WebContents to distill.
25     */
26    public static void distillCurrentPageAndView(WebContents webContents) {
27        nativeDistillCurrentPageAndView(webContents);
28    }
29
30    /**
31     * Returns the formatted version of the original URL of a distillation, given the original URL.
32     *
33     * @param url The original URL.
34     * @return the formatted URL of the original page.
35     */
36    public static String getFormattedUrlFromOriginalDistillerUrl(String url) {
37        return nativeGetFormattedUrlFromOriginalDistillerUrl(url);
38    }
39
40    private static native void nativeDistillCurrentPageAndView(WebContents webContents);
41    private static native String nativeGetFormattedUrlFromOriginalDistillerUrl(String url);
42}
43