Commit fe436d6b authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Hook up OOPIF printing for Android.

Initialize printing on Android the same way as other platforms, instead
of in TabAndroid::Print(). By calling printing::InitializePrinting()
like other platforms, the PDF compositor will be created as needs.

Also implement PrintCrossProcessSubframe() in
TabWebContentsDelegateAndroid to redirect the subframe print request,
since the Browser class does not exist on Android.

BUG=890417

Change-Id: I7195cf2afe2560dd56a56b5a769acf9e51bbb41b
Reviewed-on: https://chromium-review.googlesource.com/c/1420302
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Reviewed-by: default avatarWei Li <weili@chromium.org>
Reviewed-by: default avatarShimi Zhang <ctzsm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625362}
parent 709b1fd9
...@@ -642,7 +642,6 @@ bool TabAndroid::Print(JNIEnv* env, ...@@ -642,7 +642,6 @@ bool TabAndroid::Print(JNIEnv* env,
content::WebContents* contents = content::WebContents* contents =
content::WebContents::FromRenderFrameHost(rfh); content::WebContents::FromRenderFrameHost(rfh);
printing::PrintViewManagerBasic::CreateForWebContents(contents);
printing::PrintViewManagerBasic* print_view_manager = printing::PrintViewManagerBasic* print_view_manager =
printing::PrintViewManagerBasic::FromWebContents(contents); printing::PrintViewManagerBasic::FromWebContents(contents);
return print_view_manager && print_view_manager->PrintNow(rfh); return print_view_manager && print_view_manager->PrintNow(rfh);
......
...@@ -61,6 +61,10 @@ ...@@ -61,6 +61,10 @@
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/geometry/rect_f.h"
#if BUILDFLAG(ENABLE_PRINTING)
#include "components/printing/browser/print_composite_client.h"
#endif
using base::android::AttachCurrentThread; using base::android::AttachCurrentThread;
using base::android::JavaParamRef; using base::android::JavaParamRef;
using base::android::ScopedJavaLocalRef; using base::android::ScopedJavaLocalRef;
...@@ -185,6 +189,17 @@ bool TabWebContentsDelegateAndroid::ShouldFocusLocationBarByDefault( ...@@ -185,6 +189,17 @@ bool TabWebContentsDelegateAndroid::ShouldFocusLocationBarByDefault(
return false; return false;
} }
#if BUILDFLAG(ENABLE_PRINTING)
void TabWebContentsDelegateAndroid::PrintCrossProcessSubframe(
content::WebContents* web_contents,
const gfx::Rect& rect,
int document_cookie,
content::RenderFrameHost* subframe_host) const {
auto* client = printing::PrintCompositeClient::FromWebContents(web_contents);
if (client)
client->PrintCrossProcessSubframe(rect, document_cookie, subframe_host);
}
#endif
void TabWebContentsDelegateAndroid::Observe( void TabWebContentsDelegateAndroid::Observe(
int type, int type,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "content/public/browser/bluetooth_chooser.h" #include "content/public/browser/bluetooth_chooser.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h" #include "content/public/browser/notification_registrar.h"
#include "printing/buildflags/buildflags.h"
class FindNotificationDetails; class FindNotificationDetails;
...@@ -96,6 +97,14 @@ class TabWebContentsDelegateAndroid ...@@ -96,6 +97,14 @@ class TabWebContentsDelegateAndroid
bool did_start_load, bool did_start_load,
bool did_finish_load) override; bool did_finish_load) override;
#if BUILDFLAG(ENABLE_PRINTING)
void PrintCrossProcessSubframe(
content::WebContents* web_contents,
const gfx::Rect& rect,
int document_cookie,
content::RenderFrameHost* subframe_host) const override;
#endif
private: private:
// NotificationObserver implementation. // NotificationObserver implementation.
void Observe(int type, void Observe(int type,
......
...@@ -343,7 +343,7 @@ offline_pages::AutoFetchPageLoadWatcher::CreateForWebContents(web_contents); ...@@ -343,7 +343,7 @@ offline_pages::AutoFetchPageLoadWatcher::CreateForWebContents(web_contents);
SupervisedUserNavigationObserver::CreateForWebContents(web_contents); SupervisedUserNavigationObserver::CreateForWebContents(web_contents);
#endif #endif
#if BUILDFLAG(ENABLE_PRINTING) && !defined(OS_ANDROID) #if BUILDFLAG(ENABLE_PRINTING)
printing::InitializePrinting(web_contents); printing::InitializePrinting(web_contents);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment