I turned on the print preview build flags. And updated the CefPrintViewManger according to the newer version of it in chromium, to have the support for sending out PrintMsg_InitiatePrintPreview message to the render frame.
- Code: Select all
class CefPrintViewManager :
public CefPrintViewManagerBase,
public content::WebContentsUserData<CefPrintViewManager> {
The message is received by the render process in PrintWebViewHelper(which has base class content::RenderFrameObserver, content::RenderFrameObserverTracker<PrintWebViewHelper>) and then it will try to send a PrintHostMsg_RequestPrintPreview message to the render frame
- Code: Select all
Send(new PrintHostMsg_RequestPrintPreview(routing_id(), params));
- Code: Select all
class PrintWebViewHelper
: public content::RenderFrameObserver,
public content::RenderFrameObserverTracker<PrintWebViewHelper> {
Read through chromium code. the PrintHostMsg_RequestPrintPreview Message should be handled in
- Code: Select all
class PrintPreviewMessageHandler
: public content::WebContentsObserver,
public content::WebContentsUserData<PrintPreviewMessageHandler>
I searched for PrintPreviewMessageHandler, found out that "print_preview_message_handler" is attached in "src/chrome/browser/ui/tab_helpers.cc", "src/chrome/browser/ui/apps/chrome_app_delegate.cc", "src/chrome/browser/extensions/api/chrome_extensions_api_client.cc".
Since the behavior right now is that the message is lost, it might because 1. the print_preview_message_handler is not attached at the time we tries to create the print preview. 2. the print_preview_message_handler is not attached to the right webcontent.
I am new to chromium and Cef code, sorry if I didn't understand them correctly. Here are my confusions : 1.why there are three places that tries to attach this handler? 2. when will each class be attaching this handler?
Please let me know if I misunderstood or if you have any suggestions. Any comment will be appreciated!