This source file includes following definitions.
- setDefaultTitle
- print
- getTitle
package org.chromium.chrome.browser.printing;
import android.text.TextUtils;
import org.chromium.chrome.browser.Tab;
import org.chromium.printing.Printable;
import java.lang.ref.WeakReference;
public class TabPrinter implements Printable {
private static String sDefaultTitle;
private final WeakReference<Tab> mTab;
public TabPrinter(Tab tab) {
mTab = new WeakReference<Tab>(tab);
}
public static void setDefaultTitle(String defaultTitle) {
sDefaultTitle = defaultTitle;
}
@Override
public boolean print() {
Tab tab = mTab.get();
return tab != null && tab.print();
}
@Override
public String getTitle() {
Tab tab = mTab.get();
if (tab == null) return sDefaultTitle;
String title = tab.getTitle();
if (!TextUtils.isEmpty(title)) return title;
String url = tab.getUrl();
if (!TextUtils.isEmpty(url)) return url;
return sDefaultTitle;
}
}