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