mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
[printing] Mojofy PrintHostMsg_PrintPreviewCancelled
https://chromium-review.googlesource.com/c/chromium/src/+/2198331
This commit is contained in:
@@ -140,12 +140,11 @@ void PrintPreviewMessageHandler::PrintPreviewFailed(int32_t document_cookie,
|
||||
RejectPromise(request_id);
|
||||
}
|
||||
|
||||
void PrintPreviewMessageHandler::OnPrintPreviewCancelled(
|
||||
int document_cookie,
|
||||
const PrintHostMsg_PreviewIds& ids) {
|
||||
void PrintPreviewMessageHandler::PrintPreviewCancelled(int32_t document_cookie,
|
||||
int32_t request_id) {
|
||||
StopWorker(document_cookie);
|
||||
|
||||
RejectPromise(ids.request_id);
|
||||
RejectPromise(request_id);
|
||||
}
|
||||
|
||||
void PrintPreviewMessageHandler::PrintToPDF(
|
||||
@@ -160,8 +159,13 @@ void PrintPreviewMessageHandler::PrintToPDF(
|
||||
? focused_frame
|
||||
: web_contents()->GetMainFrame();
|
||||
|
||||
if (!print_render_frame_.is_bound())
|
||||
if (!print_render_frame_.is_bound()) {
|
||||
rfh->GetRemoteAssociatedInterfaces()->GetInterface(&print_render_frame_);
|
||||
}
|
||||
if (!receiver_.is_bound()) {
|
||||
print_render_frame_->SetPrintPreviewUI(
|
||||
receiver_.BindNewEndpointAndPassRemote());
|
||||
}
|
||||
print_render_frame_->PrintPreview(options.Clone());
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "components/services/print_compositor/public/mojom/print_compositor.mojom.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "content/public/browser/web_contents_user_data.h"
|
||||
#include "mojo/public/cpp/bindings/associated_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/associated_remote.h"
|
||||
#include "shell/common/gin_helper/promise.h"
|
||||
#include "v8/include/v8.h"
|
||||
@@ -55,14 +56,14 @@ class PrintPreviewMessageHandler
|
||||
const PrintHostMsg_PreviewIds& ids,
|
||||
printing::mojom::PrintCompositor::Status status,
|
||||
base::ReadOnlySharedMemoryRegion region);
|
||||
void OnPrintPreviewCancelled(int document_cookie,
|
||||
const PrintHostMsg_PreviewIds& ids);
|
||||
|
||||
// printing::mojo::PrintPreviewUI:
|
||||
void SetOptionsFromDocument(
|
||||
const printing::mojom::OptionsFromDocumentParamsPtr params,
|
||||
int32_t request_id) override {}
|
||||
void PrintPreviewFailed(int32_t document_cookie, int32_t request_id) override;
|
||||
void PrintPreviewCancelled(int32_t document_cookie,
|
||||
int32_t request_id) override;
|
||||
|
||||
gin_helper::Promise<v8::Local<v8::Value>> GetPromise(int request_id);
|
||||
|
||||
@@ -75,6 +76,8 @@ class PrintPreviewMessageHandler
|
||||
|
||||
mojo::AssociatedRemote<printing::mojom::PrintRenderFrame> print_render_frame_;
|
||||
|
||||
mojo::AssociatedReceiver<printing::mojom::PrintPreviewUI> receiver_{this};
|
||||
|
||||
base::WeakPtrFactory<PrintPreviewMessageHandler> weak_ptr_factory_;
|
||||
|
||||
WEB_CONTENTS_USER_DATA_KEY_DECL();
|
||||
|
||||
Reference in New Issue
Block a user