| 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 "chrome/browser/ui/pdf/pdf_tab_helper.h" | 5 #include "chrome/browser/ui/pdf/pdf_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/download/download_stats.h" | 8 #include "chrome/browser/download/download_stats.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
| 11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "chrome/browser/ui/omnibox/location_bar.h" | 12 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 13 #include "chrome/browser/ui/pdf/open_pdf_in_reader_prompt_delegate.h" | 13 #include "chrome/browser/ui/pdf/open_pdf_in_reader_prompt_delegate.h" |
| 14 #include "chrome/browser/ui/pdf/pdf_unsupported_feature.h" | 14 #include "chrome/browser/ui/pdf/pdf_unsupported_feature.h" |
| 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 15 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
| 16 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
| 17 #include "content/public/browser/navigation_details.h" | 17 #include "content/public/browser/navigation_details.h" |
| 18 | 18 |
| 19 #if defined(TOOLKIT_GTK) | |
| 20 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" | |
| 21 #include "content/public/browser/javascript_dialog_manager.h" | |
| 22 #endif | |
| 23 | |
| 24 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PDFTabHelper); | 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PDFTabHelper); |
| 25 | 20 |
| 26 PDFTabHelper::PDFTabHelper(content::WebContents* web_contents) | 21 PDFTabHelper::PDFTabHelper(content::WebContents* web_contents) |
| 27 : content::WebContentsObserver(web_contents) { | 22 : content::WebContentsObserver(web_contents) { |
| 28 } | 23 } |
| 29 | 24 |
| 30 PDFTabHelper::~PDFTabHelper() { | 25 PDFTabHelper::~PDFTabHelper() { |
| 31 } | 26 } |
| 32 | 27 |
| 33 void PDFTabHelper::ShowOpenInReaderPrompt( | 28 void PDFTabHelper::ShowOpenInReaderPrompt( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 ChromeViewHostMsg_PDFModalPromptForPassword::WriteReplyParams( | 95 ChromeViewHostMsg_PDFModalPromptForPassword::WriteReplyParams( |
| 101 reply_message, base::UTF16ToUTF8(actual_value)); | 96 reply_message, base::UTF16ToUTF8(actual_value)); |
| 102 Send(reply_message); | 97 Send(reply_message); |
| 103 } | 98 } |
| 104 | 99 |
| 105 void PDFTabHelper::OnModalPromptForPassword(const std::string& prompt, | 100 void PDFTabHelper::OnModalPromptForPassword(const std::string& prompt, |
| 106 IPC::Message* reply_message) { | 101 IPC::Message* reply_message) { |
| 107 base::Callback<void(bool, const base::string16&)> callback = | 102 base::Callback<void(bool, const base::string16&)> callback = |
| 108 base::Bind(&PDFTabHelper::OnModalPromptForPasswordClosed, | 103 base::Bind(&PDFTabHelper::OnModalPromptForPasswordClosed, |
| 109 base::Unretained(this), reply_message); | 104 base::Unretained(this), reply_message); |
| 110 #if !defined(TOOLKIT_GTK) | |
| 111 ShowPDFPasswordDialog(web_contents(), base::UTF8ToUTF16(prompt), callback); | 105 ShowPDFPasswordDialog(web_contents(), base::UTF8ToUTF16(prompt), callback); |
| 112 #else | |
| 113 // GTK is going away, so it's not worth the effort to create a password dialog | |
| 114 // for it. Cheat (for now) until the GTK code is removed. | |
| 115 bool did_suppress_message; | |
| 116 GetJavaScriptDialogManagerInstance()->RunJavaScriptDialog( | |
| 117 web_contents(), | |
| 118 GURL(), | |
| 119 std::string(), | |
| 120 content::JAVASCRIPT_MESSAGE_TYPE_PROMPT, | |
| 121 base::UTF8ToUTF16(prompt), | |
| 122 base::string16(), | |
| 123 callback, | |
| 124 &did_suppress_message); | |
| 125 #endif // TOOLKIT_GTK | |
| 126 } | 106 } |
| OLD | NEW |