| 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 "content/public/common/referrer.h" | 8 #include "content/public/common/referrer.h" |
| 9 #include "content/public/renderer/pepper_plugin_instance.h" | 9 #include "content/public/renderer/pepper_plugin_instance.h" |
| 10 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 146 } |
| 147 | 147 |
| 148 int32_t PepperPDFHost::OnHostMsgSaveAs( | 148 int32_t PepperPDFHost::OnHostMsgSaveAs( |
| 149 ppapi::host::HostMessageContext* context) { | 149 ppapi::host::HostMessageContext* context) { |
| 150 content::PepperPluginInstance* instance = | 150 content::PepperPluginInstance* instance = |
| 151 host_->GetPluginInstance(pp_instance()); | 151 host_->GetPluginInstance(pp_instance()); |
| 152 if (!instance) | 152 if (!instance) |
| 153 return PP_ERROR_FAILED; | 153 return PP_ERROR_FAILED; |
| 154 GURL url = instance->GetPluginURL(); | 154 GURL url = instance->GetPluginURL(); |
| 155 content::RenderView* render_view = instance->GetRenderView(); | 155 content::RenderView* render_view = instance->GetRenderView(); |
| 156 blink::WebLocalFrame* frame = | 156 content::Referrer referrer; |
| 157 render_view->GetWebView()->mainFrame()->toWebLocalFrame(); | 157 referrer.url = url; |
| 158 content::Referrer referrer = content::Referrer::SanitizeForRequest( | 158 referrer.policy = blink::WebReferrerPolicyDefault; |
| 159 url, content::Referrer(frame->document().url(), | 159 referrer = content::Referrer::SanitizeForRequest(url, referrer); |
| 160 frame->document().referrerPolicy())); | |
| 161 render_view->Send( | 160 render_view->Send( |
| 162 new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); | 161 new PDFHostMsg_PDFSaveURLAs(render_view->GetRoutingID(), url, referrer)); |
| 163 return PP_OK; | 162 return PP_OK; |
| 164 } | 163 } |
| 165 | 164 |
| 166 int32_t PepperPDFHost::OnHostMsgSetSelectedText( | 165 int32_t PepperPDFHost::OnHostMsgSetSelectedText( |
| 167 ppapi::host::HostMessageContext* context, | 166 ppapi::host::HostMessageContext* context, |
| 168 const base::string16& selected_text) { | 167 const base::string16& selected_text) { |
| 169 content::PepperPluginInstance* instance = | 168 content::PepperPluginInstance* instance = |
| 170 host_->GetPluginInstance(pp_instance()); | 169 host_->GetPluginInstance(pp_instance()); |
| 171 if (!instance) | 170 if (!instance) |
| 172 return PP_ERROR_FAILED; | 171 return PP_ERROR_FAILED; |
| 173 instance->SetSelectedText(selected_text); | 172 instance->SetSelectedText(selected_text); |
| 174 return PP_OK; | 173 return PP_OK; |
| 175 } | 174 } |
| 176 | 175 |
| 177 int32_t PepperPDFHost::OnHostMsgSetLinkUnderCursor( | 176 int32_t PepperPDFHost::OnHostMsgSetLinkUnderCursor( |
| 178 ppapi::host::HostMessageContext* context, | 177 ppapi::host::HostMessageContext* context, |
| 179 const std::string& url) { | 178 const std::string& url) { |
| 180 content::PepperPluginInstance* instance = | 179 content::PepperPluginInstance* instance = |
| 181 host_->GetPluginInstance(pp_instance()); | 180 host_->GetPluginInstance(pp_instance()); |
| 182 if (!instance) | 181 if (!instance) |
| 183 return PP_ERROR_FAILED; | 182 return PP_ERROR_FAILED; |
| 184 instance->SetLinkUnderCursor(url); | 183 instance->SetLinkUnderCursor(url); |
| 185 return PP_OK; | 184 return PP_OK; |
| 186 } | 185 } |
| 187 | 186 |
| 188 } // namespace pdf | 187 } // namespace pdf |
| OLD | NEW |