| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/pdf_web_contents_helper.h" | 5 #include "components/pdf/browser/pdf_web_contents_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h" | 9 #include "components/pdf/browser/open_pdf_in_reader_prompt_client.h" |
| 10 #include "components/pdf/browser/pdf_web_contents_helper_client.h" | 10 #include "components/pdf/browser/pdf_web_contents_helper_client.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool PDFWebContentsHelper::OnMessageReceived(const IPC::Message& message) { | 43 bool PDFWebContentsHelper::OnMessageReceived(const IPC::Message& message) { |
| 44 bool handled = true; | 44 bool handled = true; |
| 45 IPC_BEGIN_MESSAGE_MAP(PDFWebContentsHelper, message) | 45 IPC_BEGIN_MESSAGE_MAP(PDFWebContentsHelper, message) |
| 46 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFHasUnsupportedFeature, | 46 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFHasUnsupportedFeature, |
| 47 OnHasUnsupportedFeature) | 47 OnHasUnsupportedFeature) |
| 48 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFSaveURLAs, OnSaveURLAs) | 48 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFSaveURLAs, OnSaveURLAs) |
| 49 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFUpdateContentRestrictions, | 49 IPC_MESSAGE_HANDLER(PDFHostMsg_PDFUpdateContentRestrictions, |
| 50 OnUpdateContentRestrictions) | 50 OnUpdateContentRestrictions) |
| 51 IPC_MESSAGE_HANDLER_DELAY_REPLY(PDFHostMsg_PDFModalPromptForPassword, | |
| 52 OnModalPromptForPassword) | |
| 53 IPC_MESSAGE_UNHANDLED(handled = false) | 51 IPC_MESSAGE_UNHANDLED(handled = false) |
| 54 IPC_END_MESSAGE_MAP() | 52 IPC_END_MESSAGE_MAP() |
| 55 return handled; | 53 return handled; |
| 56 } | 54 } |
| 57 | 55 |
| 58 void PDFWebContentsHelper::DidNavigateMainFrame( | 56 void PDFWebContentsHelper::DidNavigateMainFrame( |
| 59 const content::LoadCommittedDetails& details, | 57 const content::LoadCommittedDetails& details, |
| 60 const content::FrameNavigateParams& params) { | 58 const content::FrameNavigateParams& params) { |
| 61 if (open_in_reader_prompt_.get() && | 59 if (open_in_reader_prompt_.get() && |
| 62 open_in_reader_prompt_->ShouldExpire(details)) { | 60 open_in_reader_prompt_->ShouldExpire(details)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 77 const content::Referrer& referrer) { | 75 const content::Referrer& referrer) { |
| 78 client_->OnSaveURL(web_contents()); | 76 client_->OnSaveURL(web_contents()); |
| 79 web_contents()->SaveFrame(url, referrer); | 77 web_contents()->SaveFrame(url, referrer); |
| 80 } | 78 } |
| 81 | 79 |
| 82 void PDFWebContentsHelper::OnUpdateContentRestrictions( | 80 void PDFWebContentsHelper::OnUpdateContentRestrictions( |
| 83 int content_restrictions) { | 81 int content_restrictions) { |
| 84 client_->UpdateContentRestrictions(web_contents(), content_restrictions); | 82 client_->UpdateContentRestrictions(web_contents(), content_restrictions); |
| 85 } | 83 } |
| 86 | 84 |
| 87 void PDFWebContentsHelper::OnModalPromptForPasswordClosed( | |
| 88 IPC::Message* reply_message, | |
| 89 bool success, | |
| 90 const base::string16& actual_value) { | |
| 91 PDFHostMsg_PDFModalPromptForPassword::WriteReplyParams( | |
| 92 reply_message, base::UTF16ToUTF8(actual_value)); | |
| 93 Send(reply_message); | |
| 94 } | |
| 95 | |
| 96 void PDFWebContentsHelper::OnModalPromptForPassword( | |
| 97 const std::string& prompt, | |
| 98 IPC::Message* reply_message) { | |
| 99 base::Callback<void(bool, const base::string16&)> callback = | |
| 100 base::Bind(&PDFWebContentsHelper::OnModalPromptForPasswordClosed, | |
| 101 base::Unretained(this), | |
| 102 reply_message); | |
| 103 client_->OnShowPDFPasswordDialog( | |
| 104 web_contents(), base::UTF8ToUTF16(prompt), callback); | |
| 105 } | |
| 106 | |
| 107 } // namespace pdf | 85 } // namespace pdf |
| OLD | NEW |