Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "components/pdf/common/pdf_messages.h" | 7 #include "components/pdf/common/pdf_messages.h" |
| 8 #include "components/pdf/renderer/pdf_accessibility_tree.h" | 8 #include "components/pdf/renderer/pdf_accessibility_tree.h" |
| 9 #include "content/public/common/referrer.h" | 9 #include "content/public/common/referrer.h" |
| 10 #include "content/public/renderer/pepper_plugin_instance.h" | 10 #include "content/public/renderer/pepper_plugin_instance.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 return PP_OK; | 135 return PP_OK; |
| 136 } | 136 } |
| 137 | 137 |
| 138 int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature( | 138 int32_t PepperPDFHost::OnHostMsgHasUnsupportedFeature( |
| 139 ppapi::host::HostMessageContext* context) { | 139 ppapi::host::HostMessageContext* context) { |
| 140 content::PepperPluginInstance* instance = | 140 content::PepperPluginInstance* instance = |
| 141 host_->GetPluginInstance(pp_instance()); | 141 host_->GetPluginInstance(pp_instance()); |
| 142 if (!instance) | 142 if (!instance) |
| 143 return PP_ERROR_FAILED; | 143 return PP_ERROR_FAILED; |
| 144 | 144 |
| 145 // TODO(thestig): Turn CHECKs into the proper if statement after figuring out | 145 content::RenderView* render_view = instance->GetRenderView(); |
| 146 // what's wrong for https://crbug.com/627814 | 146 if (!render_view) |
| 147 CHECK(instance->GetContainer()); | 147 return PP_ERROR_FAILED; |
| 148 CHECK(instance->GetContainer()->document().frame()); | 148 |
|
Lei Zhang
2016/07/22 20:35:37
I found this CHECK() failed, but then I looked bel
| |
| 149 CHECK(instance->GetContainer()->document().frame()->view()); | |
| 150 blink::WebView* view = | |
| 151 instance->GetContainer()->document().frame()->view(); | |
| 152 content::RenderView* render_view = content::RenderView::FromWebView(view); | |
| 153 render_view->Send( | 149 render_view->Send( |
| 154 new PDFHostMsg_PDFHasUnsupportedFeature(render_view->GetRoutingID())); | 150 new PDFHostMsg_PDFHasUnsupportedFeature(render_view->GetRoutingID())); |
| 155 return PP_OK; | 151 return PP_OK; |
| 156 } | 152 } |
| 157 | 153 |
| 158 int32_t PepperPDFHost::OnHostMsgPrint( | 154 int32_t PepperPDFHost::OnHostMsgPrint( |
| 159 ppapi::host::HostMessageContext* context) { | 155 ppapi::host::HostMessageContext* context) { |
| 160 return InvokePrintingForInstance(pp_instance()) ? PP_OK : PP_ERROR_FAILED; | 156 return InvokePrintingForInstance(pp_instance()) ? PP_OK : PP_ERROR_FAILED; |
| 161 } | 157 } |
| 162 | 158 |
| 163 int32_t PepperPDFHost::OnHostMsgSaveAs( | 159 int32_t PepperPDFHost::OnHostMsgSaveAs( |
| 164 ppapi::host::HostMessageContext* context) { | 160 ppapi::host::HostMessageContext* context) { |
| 165 content::PepperPluginInstance* instance = | 161 content::PepperPluginInstance* instance = |
| 166 host_->GetPluginInstance(pp_instance()); | 162 host_->GetPluginInstance(pp_instance()); |
| 167 if (!instance) | 163 if (!instance) |
| 168 return PP_ERROR_FAILED; | 164 return PP_ERROR_FAILED; |
| 165 | |
| 166 content::RenderView* render_view = instance->GetRenderView(); | |
| 167 if (!render_view) | |
| 168 return PP_ERROR_FAILED; | |
| 169 | |
| 169 GURL url = instance->GetPluginURL(); | 170 GURL url = instance->GetPluginURL(); |
| 170 content::RenderView* render_view = instance->GetRenderView(); | |
|
Lei Zhang
2016/07/22 20:35:37
This can also return a nullptr and crash later dow
| |
| 171 content::Referrer referrer; | 171 content::Referrer referrer; |
| 172 referrer.url = url; | 172 referrer.url = url; |
| 173 referrer.policy = blink::WebReferrerPolicyDefault; | 173 referrer.policy = blink::WebReferrerPolicyDefault; |
| 174 referrer = content::Referrer::SanitizeForRequest(url, referrer); | 174 referrer = content::Referrer::SanitizeForRequest(url, referrer); |
| 175 render_view->Send( | 175 render_view->Send( |
| 176 new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); | 176 new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); |
| 177 return PP_OK; | 177 return PP_OK; |
| 178 } | 178 } |
| 179 | 179 |
| 180 int32_t PepperPDFHost::OnHostMsgSetSelectedText( | 180 int32_t PepperPDFHost::OnHostMsgSetSelectedText( |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 } | 233 } |
| 234 | 234 |
| 235 void PepperPDFHost::CreatePdfAccessibilityTreeIfNeeded() { | 235 void PepperPDFHost::CreatePdfAccessibilityTreeIfNeeded() { |
| 236 if (!pdf_accessibility_tree_) { | 236 if (!pdf_accessibility_tree_) { |
| 237 pdf_accessibility_tree_.reset(new PdfAccessibilityTree( | 237 pdf_accessibility_tree_.reset(new PdfAccessibilityTree( |
| 238 host_, pp_instance())); | 238 host_, pp_instance())); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace pdf | 242 } // namespace pdf |
| OLD | NEW |