| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/views/constrained_window_views.h" | 7 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 8 #include "components/web_modal/web_contents_modal_dialog_host.h" | 8 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 9 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 9 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 10 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 10 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 12 #include "content/public/browser/web_contents_view.h" | |
| 13 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/views/controls/message_box_view.h" | 14 #include "ui/views/controls/message_box_view.h" |
| 16 #include "ui/views/controls/textfield/textfield.h" | 15 #include "ui/views/controls/textfield/textfield.h" |
| 17 #include "ui/views/layout/layout_constants.h" | 16 #include "ui/views/layout/layout_constants.h" |
| 18 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 19 #include "ui/views/window/dialog_delegate.h" | 18 #include "ui/views/window/dialog_delegate.h" |
| 20 | 19 |
| 21 namespace { | 20 namespace { |
| 22 | 21 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 message_box_view_ = new views::MessageBoxView(init_params); | 72 message_box_view_ = new views::MessageBoxView(init_params); |
| 74 | 73 |
| 75 message_box_view_->text_box()->SetObscured(true); | 74 message_box_view_->text_box()->SetObscured(true); |
| 76 | 75 |
| 77 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 76 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 78 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); | 77 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); |
| 79 web_modal::WebContentsModalDialogManagerDelegate* modal_delegate = | 78 web_modal::WebContentsModalDialogManagerDelegate* modal_delegate = |
| 80 web_contents_modal_dialog_manager->delegate(); | 79 web_contents_modal_dialog_manager->delegate(); |
| 81 DCHECK(modal_delegate); | 80 DCHECK(modal_delegate); |
| 82 dialog_ = views::Widget::CreateWindowAsFramelessChild( | 81 dialog_ = views::Widget::CreateWindowAsFramelessChild( |
| 83 this, | 82 this, modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); |
| 84 web_contents->GetView()->GetNativeView(), | |
| 85 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); | |
| 86 web_contents_modal_dialog_manager->ShowDialog(dialog_->GetNativeView()); | 83 web_contents_modal_dialog_manager->ShowDialog(dialog_->GetNativeView()); |
| 87 } | 84 } |
| 88 | 85 |
| 89 PDFPasswordDialogViews::~PDFPasswordDialogViews() { | 86 PDFPasswordDialogViews::~PDFPasswordDialogViews() { |
| 90 if (!callback_.is_null()) { | 87 if (!callback_.is_null()) { |
| 91 // This dialog was torn down without either OK or cancel being clicked; be | 88 // This dialog was torn down without either OK or cancel being clicked; be |
| 92 // considerate and at least do the callback. | 89 // considerate and at least do the callback. |
| 93 callback_.Run(false, base::string16()); | 90 callback_.Run(false, base::string16()); |
| 94 } | 91 } |
| 95 } | 92 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 #endif | 157 #endif |
| 161 } | 158 } |
| 162 | 159 |
| 163 } // namespace | 160 } // namespace |
| 164 | 161 |
| 165 void ShowPDFPasswordDialog(content::WebContents* web_contents, | 162 void ShowPDFPasswordDialog(content::WebContents* web_contents, |
| 166 const base::string16& prompt, | 163 const base::string16& prompt, |
| 167 const PasswordDialogClosedCallback& callback) { | 164 const PasswordDialogClosedCallback& callback) { |
| 168 new PDFPasswordDialogViews(web_contents, prompt, callback); | 165 new PDFPasswordDialogViews(web_contents, prompt, callback); |
| 169 } | 166 } |
| OLD | NEW |