Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / pdf_password_dialog.cc
index b012d4f..f444fab 100644 (file)
@@ -2,13 +2,10 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "chrome/browser/ui/pdf/pdf_tab_helper.h"
-
-#include "components/web_modal/web_contents_modal_dialog_host.h"
-#include "components/web_modal/web_contents_modal_dialog_manager.h"
-#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
+#include "chrome/browser/ui/views/constrained_window_views.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/pdf/browser/pdf_web_contents_helper_client.h"
 #include "content/public/browser/web_contents.h"
-#include "grit/generated_resources.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/views/controls/message_box_view.h"
 #include "ui/views/controls/textfield/textfield.h"
 
 namespace {
 
-// PDFPasswordDialogViews runs a tab-modal dialog that asks the user for a
-// password.
+// Runs a tab-modal dialog that asks the user for a password.
 class PDFPasswordDialogViews : public views::DialogDelegate {
  public:
   PDFPasswordDialogViews(content::WebContents* web_contents,
                          const base::string16& prompt,
-                         const PasswordDialogClosedCallback& callback);
+                         const pdf::PasswordDialogClosedCallback& callback);
   virtual ~PDFPasswordDialogViews();
 
   // views::DialogDelegate:
@@ -46,9 +42,7 @@ class PDFPasswordDialogViews : public views::DialogDelegate {
   // The message box view whose commands we handle.
   views::MessageBoxView* message_box_view_;
 
-  views::Widget* dialog_;
-
-  PasswordDialogClosedCallback callback_;
+  pdf::PasswordDialogClosedCallback callback_;
 
   DISALLOW_COPY_AND_ASSIGN(PDFPasswordDialogViews);
 };
@@ -56,26 +50,15 @@ class PDFPasswordDialogViews : public views::DialogDelegate {
 PDFPasswordDialogViews::PDFPasswordDialogViews(
     content::WebContents* web_contents,
     const base::string16& prompt,
-    const PasswordDialogClosedCallback& callback)
-    : message_box_view_(NULL),
-      dialog_(NULL),
-      callback_(callback) {
+    const pdf::PasswordDialogClosedCallback& callback)
+    : message_box_view_(NULL), callback_(callback) {
   views::MessageBoxView::InitParams init_params(prompt);
   init_params.options = views::MessageBoxView::HAS_PROMPT_FIELD;
   init_params.inter_row_vertical_spacing =
       views::kUnrelatedControlVerticalSpacing;
   message_box_view_ = new views::MessageBoxView(init_params);
   message_box_view_->text_box()->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
-
-  web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager =
-      web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
-  web_modal::WebContentsModalDialogManagerDelegate* modal_delegate =
-      web_contents_modal_dialog_manager->delegate();
-  DCHECK(modal_delegate);
-  dialog_ = views::Widget::CreateWindowAsFramelessChild(
-      this, modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
-  web_contents_modal_dialog_manager->ShowModalDialog(
-      dialog_->GetNativeView());
+  ShowWebModalDialogViews(this, web_contents);
 }
 
 PDFPasswordDialogViews::~PDFPasswordDialogViews() {
@@ -138,17 +121,13 @@ void PDFPasswordDialogViews::DeleteDelegate() {
 }
 
 ui::ModalType PDFPasswordDialogViews::GetModalType() const {
-#if defined(USE_ASH)
   return ui::MODAL_TYPE_CHILD;
-#else
-  return views::WidgetDelegate::GetModalType();
-#endif
 }
 
 }  // namespace
 
 void ShowPDFPasswordDialog(content::WebContents* web_contents,
                            const base::string16& prompt,
-                           const PasswordDialogClosedCallback& callback) {
+                           const pdf::PasswordDialogClosedCallback& callback) {
   new PDFPasswordDialogViews(web_contents, prompt, callback);
 }