summaryrefslogtreecommitdiff
path: root/chromium/chrome/android/java/src/org/chromium/chrome/browser/printing/TabPrinter.java
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/chrome/android/java/src/org/chromium/chrome/browser/printing/TabPrinter.java')
-rw-r--r--chromium/chrome/android/java/src/org/chromium/chrome/browser/printing/TabPrinter.java82
1 files changed, 0 insertions, 82 deletions
diff --git a/chromium/chrome/android/java/src/org/chromium/chrome/browser/printing/TabPrinter.java b/chromium/chrome/android/java/src/org/chromium/chrome/browser/printing/TabPrinter.java
deleted file mode 100644
index ffa94ee1a6f..00000000000
--- a/chromium/chrome/android/java/src/org/chromium/chrome/browser/printing/TabPrinter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.printing;
-
-import android.text.TextUtils;
-
-import org.chromium.base.ContextUtils;
-import org.chromium.base.Log;
-import org.chromium.base.annotations.CalledByNative;
-import org.chromium.base.annotations.JNINamespace;
-import org.chromium.base.annotations.NativeMethods;
-import org.chromium.chrome.R;
-import org.chromium.chrome.browser.tab.Tab;
-import org.chromium.content_public.browser.WebContents;
-import org.chromium.printing.Printable;
-
-import java.lang.ref.WeakReference;
-
-/**
- * Wraps printing related functionality of a {@link Tab} object.
- *
- * This class doesn't have any lifetime expectations with regards to Tab, since we keep a weak
- * reference.
- */
-@JNINamespace("printing")
-public class TabPrinter implements Printable {
- private static final String TAG = "printing";
-
- private final WeakReference<Tab> mTab;
- private final String mDefaultTitle;
-
- @CalledByNative
- private static TabPrinter getPrintable(Tab tab) {
- return new TabPrinter(tab);
- }
-
- public TabPrinter(Tab tab) {
- mTab = new WeakReference<Tab>(tab);
- mDefaultTitle = ContextUtils.getApplicationContext().getResources().getString(
- R.string.menu_print);
- }
-
- @Override
- public boolean print(int renderProcessId, int renderFrameId) {
- if (!canPrint()) return false;
- Tab tab = mTab.get();
- assert tab != null && tab.isInitialized();
- return TabPrinterJni.get().print(tab.getWebContents(), renderProcessId, renderFrameId);
- }
-
- @Override
- public String getTitle() {
- Tab tab = mTab.get();
- if (tab == null) return mDefaultTitle;
-
- String title = tab.getTitle();
- if (!TextUtils.isEmpty(title)) return title;
-
- String url = tab.getUrl();
- if (!TextUtils.isEmpty(url)) return url;
-
- return mDefaultTitle;
- }
-
- @Override
- public boolean canPrint() {
- Tab tab = mTab.get();
- if (tab == null || !tab.isInitialized()) {
- // tab.isInitialized() will be false if tab is in destroy process.
- Log.d(TAG, "Tab is not avaliable for printing.");
- return false;
- }
- return true;
- }
-
- @NativeMethods
- interface Natives {
- boolean print(WebContents webContents, int renderProcessId, int renderFrameId);
- }
-}