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

Side by Side Diff: chrome/renderer/pepper/pepper_pdf_host.cc

Issue 19744007: Create a public API around webkit::ppapi::PluginInstance and use it in chrome. After this, webkit/p… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: review comments and undo checkdeps change Created 7 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/renderer/pepper/pepper_pdf_host.h" 5 #include "chrome/renderer/pepper/pepper_pdf_host.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/common/render_messages.h" 8 #include "chrome/common/render_messages.h"
9 #include "chrome/renderer/printing/print_web_view_helper.h" 9 #include "chrome/renderer/printing/print_web_view_helper.h"
10 #include "content/public/common/referrer.h" 10 #include "content/public/common/referrer.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 context->reply_msg = PpapiPluginMsg_PDF_GetLocalizedStringReply(rv); 176 context->reply_msg = PpapiPluginMsg_PDF_GetLocalizedStringReply(rv);
177 return PP_OK; 177 return PP_OK;
178 } 178 }
179 179
180 int32_t PepperPDFHost::OnHostMsgDidStartLoading( 180 int32_t PepperPDFHost::OnHostMsgDidStartLoading(
181 ppapi::host::HostMessageContext* context) { 181 ppapi::host::HostMessageContext* context) {
182 PluginInstance* instance = host_->GetPluginInstance(pp_instance()); 182 PluginInstance* instance = host_->GetPluginInstance(pp_instance());
183 if (!instance) 183 if (!instance)
184 return PP_ERROR_FAILED; 184 return PP_ERROR_FAILED;
185 instance->render_view()->DidStartLoading(); 185 instance->GetRenderView()->DidStartLoading();
186 return PP_OK; 186 return PP_OK;
187 } 187 }
188 188
189 int32_t PepperPDFHost::OnHostMsgDidStopLoading( 189 int32_t PepperPDFHost::OnHostMsgDidStopLoading(
190 ppapi::host::HostMessageContext* context) { 190 ppapi::host::HostMessageContext* context) {
191 PluginInstance* instance = host_->GetPluginInstance(pp_instance()); 191 PluginInstance* instance = host_->GetPluginInstance(pp_instance());
192 if (!instance) 192 if (!instance)
193 return PP_ERROR_FAILED; 193 return PP_ERROR_FAILED;
194 instance->render_view()->DidStopLoading(); 194 instance->GetRenderView()->DidStopLoading();
195 return PP_OK; 195 return PP_OK;
196 } 196 }
197 197
198 int32_t PepperPDFHost::OnHostMsgSetContentRestriction( 198 int32_t PepperPDFHost::OnHostMsgSetContentRestriction(
199 ppapi::host::HostMessageContext* context, int restrictions) { 199 ppapi::host::HostMessageContext* context, int restrictions) {
200 PluginInstance* instance = host_->GetPluginInstance(pp_instance()); 200 PluginInstance* instance = host_->GetPluginInstance(pp_instance());
201 if (!instance) 201 if (!instance)
202 return PP_ERROR_FAILED; 202 return PP_ERROR_FAILED;
203 instance->render_view()->Send( 203 instance->GetRenderView()->Send(
204 new ChromeViewHostMsg_PDFUpdateContentRestrictions( 204 new ChromeViewHostMsg_PDFUpdateContentRestrictions(
205 instance->render_view()->GetRoutingID(), restrictions)); 205 instance->GetRenderView()->GetRoutingID(), restrictions));
206 return PP_OK; 206 return PP_OK;
207 } 207 }
208 208
209 int32_t PepperPDFHost::OnHostMsgUserMetricsRecordAction( 209 int32_t PepperPDFHost::OnHostMsgUserMetricsRecordAction(
210 ppapi::host::HostMessageContext* context, 210 ppapi::host::HostMessageContext* context,
211 const std::string& action) { 211 const std::string& action) {
212 bool valid = false; 212 bool valid = false;
213 for (size_t i = 0; i < arraysize(kValidUserMetricsActions); ++i) { 213 for (size_t i = 0; i < arraysize(kValidUserMetricsActions); ++i) {
214 if (action == kValidUserMetricsActions[i]) { 214 if (action == kValidUserMetricsActions[i]) {
215 valid = true; 215 valid = true;
(...skipping 12 matching lines...) Expand all
228 ppapi::host::HostMessageContext* context) { 228 ppapi::host::HostMessageContext* context) {
229 PluginInstance* instance = host_->GetPluginInstance(pp_instance()); 229 PluginInstance* instance = host_->GetPluginInstance(pp_instance());
230 if (!instance) 230 if (!instance)
231 return PP_ERROR_FAILED; 231 return PP_ERROR_FAILED;
232 232
233 // Only want to show an info bar if the pdf is the whole tab. 233 // Only want to show an info bar if the pdf is the whole tab.
234 if (!instance->IsFullPagePlugin()) 234 if (!instance->IsFullPagePlugin())
235 return PP_OK; 235 return PP_OK;
236 236
237 WebKit::WebView* view = 237 WebKit::WebView* view =
238 instance->container()->element().document().frame()->view(); 238 instance->GetContainer()->element().document().frame()->view();
239 content::RenderView* render_view = content::RenderView::FromWebView(view); 239 content::RenderView* render_view = content::RenderView::FromWebView(view);
240 render_view->Send(new ChromeViewHostMsg_PDFHasUnsupportedFeature( 240 render_view->Send(new ChromeViewHostMsg_PDFHasUnsupportedFeature(
241 render_view->GetRoutingID())); 241 render_view->GetRoutingID()));
242 return PP_OK; 242 return PP_OK;
243 } 243 }
244 244
245 int32_t PepperPDFHost::OnHostMsgPrint( 245 int32_t PepperPDFHost::OnHostMsgPrint(
246 ppapi::host::HostMessageContext* context) { 246 ppapi::host::HostMessageContext* context) {
247 #if defined(ENABLE_PRINTING) 247 #if defined(ENABLE_PRINTING)
248 PluginInstance* instance = host_->GetPluginInstance(pp_instance()); 248 PluginInstance* instance = host_->GetPluginInstance(pp_instance());
249 if (!instance) 249 if (!instance)
250 return PP_ERROR_FAILED; 250 return PP_ERROR_FAILED;
251 251
252 WebKit::WebElement element = instance->container()->element(); 252 WebKit::WebElement element = instance->GetContainer()->element();
253 WebKit::WebView* view = element.document().frame()->view(); 253 WebKit::WebView* view = element.document().frame()->view();
254 content::RenderView* render_view = content::RenderView::FromWebView(view); 254 content::RenderView* render_view = content::RenderView::FromWebView(view);
255 255
256 using printing::PrintWebViewHelper; 256 using printing::PrintWebViewHelper;
257 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view); 257 PrintWebViewHelper* print_view_helper = PrintWebViewHelper::Get(render_view);
258 if (print_view_helper) { 258 if (print_view_helper) {
259 print_view_helper->PrintNode(element); 259 print_view_helper->PrintNode(element);
260 return PP_OK; 260 return PP_OK;
261 } 261 }
262 #endif 262 #endif
263 return PP_ERROR_FAILED; 263 return PP_ERROR_FAILED;
264 } 264 }
265 265
266 int32_t PepperPDFHost::OnHostMsgSaveAs( 266 int32_t PepperPDFHost::OnHostMsgSaveAs(
267 ppapi::host::HostMessageContext* context) { 267 ppapi::host::HostMessageContext* context) {
268 PluginInstance* instance = host_->GetPluginInstance(pp_instance()); 268 PluginInstance* instance = host_->GetPluginInstance(pp_instance());
269 if (!instance) 269 if (!instance)
270 return PP_ERROR_FAILED; 270 return PP_ERROR_FAILED;
271 GURL url = instance->plugin_url(); 271 GURL url = instance->GetPluginURL();
272 content::RenderView* render_view = instance->render_view(); 272 content::RenderView* render_view = instance->GetRenderView();
273 WebKit::WebFrame* frame = render_view->GetWebView()->mainFrame(); 273 WebKit::WebFrame* frame = render_view->GetWebView()->mainFrame();
274 content::Referrer referrer(frame->document().url(), 274 content::Referrer referrer(frame->document().url(),
275 frame->document().referrerPolicy()); 275 frame->document().referrerPolicy());
276 render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs( 276 render_view->Send(new ChromeViewHostMsg_PDFSaveURLAs(
277 render_view->GetRoutingID(), url, referrer)); 277 render_view->GetRoutingID(), url, referrer));
278 return PP_OK; 278 return PP_OK;
279 } 279 }
280 280
281 int32_t PepperPDFHost::OnHostMsgGetResourceImage( 281 int32_t PepperPDFHost::OnHostMsgGetResourceImage(
282 ppapi::host::HostMessageContext* context, 282 ppapi::host::HostMessageContext* context,
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 bitmap->getSize(), 390 bitmap->getSize(),
391 bitmap->rowBytes()); 391 bitmap->rowBytes());
392 392
393 if (needs_unmapping) 393 if (needs_unmapping)
394 image_data->Unmap(); 394 image_data->Unmap();
395 395
396 return true; 396 return true;
397 } 397 }
398 398
399 } // namespace chrome 399 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/renderer/pepper/pepper_flash_renderer_host.cc ('k') | chrome/renderer/pepper/ppb_pdf_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698