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

Side by Side Diff: components/pdf/renderer/pepper_pdf_host.cc

Issue 2455543002: Convert PDF component IPC to mojo. (Closed)
Patch Set: Fix date 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/pdf/renderer/pepper_pdf_host.h" 5 #include "components/pdf/renderer/pepper_pdf_host.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "components/pdf/common/pdf_messages.h"
9 #include "components/pdf/renderer/pdf_accessibility_tree.h" 8 #include "components/pdf/renderer/pdf_accessibility_tree.h"
9 #include "content/public/common/associated_interface_provider.h"
10 #include "content/public/common/referrer.h" 10 #include "content/public/common/referrer.h"
11 #include "content/public/renderer/pepper_plugin_instance.h" 11 #include "content/public/renderer/pepper_plugin_instance.h"
12 #include "content/public/renderer/render_frame.h" 12 #include "content/public/renderer/render_frame.h"
13 #include "content/public/renderer/render_thread.h" 13 #include "content/public/renderer/render_thread.h"
14 #include "content/public/renderer/renderer_ppapi_host.h" 14 #include "content/public/renderer/renderer_ppapi_host.h"
15 #include "ppapi/host/dispatch_host_message.h" 15 #include "ppapi/host/dispatch_host_message.h"
16 #include "ppapi/host/host_message_context.h" 16 #include "ppapi/host/host_message_context.h"
17 #include "ppapi/host/ppapi_host.h" 17 #include "ppapi/host/ppapi_host.h"
18 #include "ppapi/proxy/host_dispatcher.h" 18 #include "ppapi/proxy/host_dispatcher.h"
19 #include "ppapi/proxy/ppapi_messages.h" 19 #include "ppapi/proxy/ppapi_messages.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 if (!render_frame) 111 if (!render_frame)
112 return PP_ERROR_FAILED; 112 return PP_ERROR_FAILED;
113 113
114 render_frame->PluginDidStopLoading(); 114 render_frame->PluginDidStopLoading();
115 return PP_OK; 115 return PP_OK;
116 } 116 }
117 117
118 int32_t PepperPDFHost::OnHostMsgSetContentRestriction( 118 int32_t PepperPDFHost::OnHostMsgSetContentRestriction(
119 ppapi::host::HostMessageContext* context, 119 ppapi::host::HostMessageContext* context,
120 int restrictions) { 120 int restrictions) {
121 content::RenderFrame* render_frame = GetRenderFrame(); 121 content::RenderFrame* render_frame = GetRenderFrame();
Sam McNally 2017/03/23 23:57:00 This should be inside GetRemotePDFService().
benwells 2017/03/29 04:18:03 Done.
122 if (!render_frame) 122 if (!render_frame)
123 return PP_ERROR_FAILED; 123 return PP_ERROR_FAILED;
124 124
125 render_frame->Send(new PDFHostMsg_PDFUpdateContentRestrictions( 125 GetRemotePDFService()->UpdateContentRestrictions(restrictions);
126 render_frame->GetRoutingID(), restrictions));
127 return PP_OK; 126 return PP_OK;
128 } 127 }
129 128
130 int32_t PepperPDFHost::OnHostMsgUserMetricsRecordAction( 129 int32_t PepperPDFHost::OnHostMsgUserMetricsRecordAction(
131 ppapi::host::HostMessageContext* context, 130 ppapi::host::HostMessageContext* context,
132 const std::string& action) { 131 const std::string& action) {
133 if (action.empty()) 132 if (action.empty())
134 return PP_ERROR_FAILED; 133 return PP_ERROR_FAILED;
135 content::RenderThread::Get()->RecordComputedAction(action); 134 content::RenderThread::Get()->RecordComputedAction(action);
136 return PP_OK; 135 return PP_OK;
137 } 136 }
138 137
139 int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature( 138 int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature(
140 ppapi::host::HostMessageContext* context) { 139 ppapi::host::HostMessageContext* context) {
141 content::RenderFrame* render_frame = GetRenderFrame(); 140 content::RenderFrame* render_frame = GetRenderFrame();
142 if (!render_frame) 141 if (!render_frame)
143 return PP_ERROR_FAILED; 142 return PP_ERROR_FAILED;
144 143
145 render_frame->Send( 144 GetRemotePDFService()->HasUnsupportedFeature();
146 new PDFHostMsg_PDFHasUnsupportedFeature(render_frame->GetRoutingID()));
147 return PP_OK; 145 return PP_OK;
148 } 146 }
149 147
150 int32_t PepperPDFHost::OnHostMsgPrint( 148 int32_t PepperPDFHost::OnHostMsgPrint(
151 ppapi::host::HostMessageContext* context) { 149 ppapi::host::HostMessageContext* context) {
152 return InvokePrintingForInstance(pp_instance()) ? PP_OK : PP_ERROR_FAILED; 150 return InvokePrintingForInstance(pp_instance()) ? PP_OK : PP_ERROR_FAILED;
153 } 151 }
154 152
155 int32_t PepperPDFHost::OnHostMsgSaveAs( 153 int32_t PepperPDFHost::OnHostMsgSaveAs(
156 ppapi::host::HostMessageContext* context) { 154 ppapi::host::HostMessageContext* context) {
157 content::PepperPluginInstance* instance = 155 content::PepperPluginInstance* instance =
158 host_->GetPluginInstance(pp_instance()); 156 host_->GetPluginInstance(pp_instance());
159 if (!instance) 157 if (!instance)
160 return PP_ERROR_FAILED; 158 return PP_ERROR_FAILED;
161 159
162 content::RenderFrame* render_frame = instance->GetRenderFrame(); 160 content::RenderFrame* render_frame = instance->GetRenderFrame();
163 if (!render_frame) 161 if (!render_frame)
164 return PP_ERROR_FAILED; 162 return PP_ERROR_FAILED;
165 163
166 GURL url = instance->GetPluginURL(); 164 GURL url = instance->GetPluginURL();
167 content::Referrer referrer; 165 content::Referrer referrer;
168 referrer.url = url; 166 referrer.url = url;
169 referrer.policy = blink::WebReferrerPolicyDefault; 167 referrer.policy = blink::WebReferrerPolicyDefault;
170 referrer = content::Referrer::SanitizeForRequest(url, referrer); 168 referrer = content::Referrer::SanitizeForRequest(url, referrer);
171 render_frame->Send( 169 GetRemotePDFService()->SaveURLAs(url, referrer);
172 new PDFHostMsg_PDFSaveURLAs(render_frame->GetRoutingID(), url, referrer));
173 return PP_OK; 170 return PP_OK;
174 } 171 }
175 172
176 int32_t PepperPDFHost::OnHostMsgSetSelectedText( 173 int32_t PepperPDFHost::OnHostMsgSetSelectedText(
177 ppapi::host::HostMessageContext* context, 174 ppapi::host::HostMessageContext* context,
178 const base::string16& selected_text) { 175 const base::string16& selected_text) {
179 content::PepperPluginInstance* instance = 176 content::PepperPluginInstance* instance =
180 host_->GetPluginInstance(pp_instance()); 177 host_->GetPluginInstance(pp_instance());
181 if (!instance) 178 if (!instance)
182 return PP_ERROR_FAILED; 179 return PP_ERROR_FAILED;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 base::MakeUnique<PdfAccessibilityTree>(host_, pp_instance()); 231 base::MakeUnique<PdfAccessibilityTree>(host_, pp_instance());
235 } 232 }
236 } 233 }
237 234
238 content::RenderFrame* PepperPDFHost::GetRenderFrame() { 235 content::RenderFrame* PepperPDFHost::GetRenderFrame() {
239 content::PepperPluginInstance* instance = 236 content::PepperPluginInstance* instance =
240 host_->GetPluginInstance(pp_instance()); 237 host_->GetPluginInstance(pp_instance());
241 return instance ? instance->GetRenderFrame() : nullptr; 238 return instance ? instance->GetRenderFrame() : nullptr;
242 } 239 }
243 240
241 mojom::PDFService* PepperPDFHost::GetRemotePDFService() {
242 if (!remote_pdf_service_) {
243 GetRenderFrame()->GetRemoteAssociatedInterfaces()->GetInterface(
244 &remote_pdf_service_);
245 }
246 return remote_pdf_service_.get();
247 }
248
244 } // namespace pdf 249 } // namespace pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698