Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Unified Diff: components/pdf/renderer/pepper_pdf_host.cc

Issue 2455543002: Convert PDF component IPC to mojo. (Closed)
Patch Set: Feedback Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/pdf/renderer/pepper_pdf_host.h ('k') | content/public/common/referrer_struct_traits.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/pdf/renderer/pepper_pdf_host.cc
diff --git a/components/pdf/renderer/pepper_pdf_host.cc b/components/pdf/renderer/pepper_pdf_host.cc
index af5469363a0f1487833bbabc8790333decf1ef1a..08e80e6341e38785b5470b928528bb433232c3bd 100644
--- a/components/pdf/renderer/pepper_pdf_host.cc
+++ b/components/pdf/renderer/pepper_pdf_host.cc
@@ -5,8 +5,8 @@
#include "components/pdf/renderer/pepper_pdf_host.h"
#include "base/memory/ptr_util.h"
-#include "components/pdf/common/pdf_messages.h"
#include "components/pdf/renderer/pdf_accessibility_tree.h"
+#include "content/public/common/associated_interface_provider.h"
#include "content/public/common/referrer.h"
#include "content/public/renderer/pepper_plugin_instance.h"
#include "content/public/renderer/render_frame.h"
@@ -118,12 +118,11 @@ int32_t PepperPDFHost::OnHostMsgDidStopLoading(
int32_t PepperPDFHost::OnHostMsgSetContentRestriction(
ppapi::host::HostMessageContext* context,
int restrictions) {
- content::RenderFrame* render_frame = GetRenderFrame();
- if (!render_frame)
+ mojom::PdfService* service = GetRemotePdfService();
+ if (!service)
return PP_ERROR_FAILED;
- render_frame->Send(new PDFHostMsg_PDFUpdateContentRestrictions(
- render_frame->GetRoutingID(), restrictions));
+ service->UpdateContentRestrictions(restrictions);
return PP_OK;
}
@@ -138,12 +137,11 @@ int32_t PepperPDFHost::OnHostMsgUserMetricsRecordAction(
int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature(
ppapi::host::HostMessageContext* context) {
- content::RenderFrame* render_frame = GetRenderFrame();
- if (!render_frame)
+ mojom::PdfService* service = GetRemotePdfService();
+ if (!service)
return PP_ERROR_FAILED;
- render_frame->Send(
- new PDFHostMsg_PDFHasUnsupportedFeature(render_frame->GetRoutingID()));
+ service->HasUnsupportedFeature();
return PP_OK;
}
@@ -159,17 +157,17 @@ int32_t PepperPDFHost::OnHostMsgSaveAs(
if (!instance)
return PP_ERROR_FAILED;
- content::RenderFrame* render_frame = instance->GetRenderFrame();
- if (!render_frame)
- return PP_ERROR_FAILED;
-
GURL url = instance->GetPluginURL();
content::Referrer referrer;
referrer.url = url;
referrer.policy = blink::WebReferrerPolicyDefault;
referrer = content::Referrer::SanitizeForRequest(url, referrer);
- render_frame->Send(
- new PDFHostMsg_PDFSaveURLAs(render_frame->GetRoutingID(), url, referrer));
+
+ mojom::PdfService* service = GetRemotePdfService();
+ if (!service)
+ return PP_ERROR_FAILED;
+
+ service->SaveUrlAs(url, referrer);
return PP_OK;
}
@@ -241,4 +239,16 @@ content::RenderFrame* PepperPDFHost::GetRenderFrame() {
return instance ? instance->GetRenderFrame() : nullptr;
}
+mojom::PdfService* PepperPDFHost::GetRemotePdfService() {
+ content::RenderFrame* render_frame = GetRenderFrame();
+ if (!render_frame)
+ return nullptr;
+
+ if (!remote_pdf_service_) {
+ render_frame->GetRemoteAssociatedInterfaces()->GetInterface(
+ &remote_pdf_service_);
+ }
+ return remote_pdf_service_.get();
+}
+
} // namespace pdf
« no previous file with comments | « components/pdf/renderer/pepper_pdf_host.h ('k') | content/public/common/referrer_struct_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698