| 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" | |
| 8 #include "components/web_modal/web_contents_modal_dialog_host.h" | 7 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 9 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 8 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 10 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 9 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 11 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 12 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/views/controls/message_box_view.h" | 13 #include "ui/views/controls/message_box_view.h" |
| 15 #include "ui/views/controls/textfield/textfield.h" | 14 #include "ui/views/controls/textfield/textfield.h" |
| 16 #include "ui/views/layout/layout_constants.h" | 15 #include "ui/views/layout/layout_constants.h" |
| 17 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 31 // views::DialogDelegate: | 30 // views::DialogDelegate: |
| 32 virtual base::string16 GetWindowTitle() const OVERRIDE; | 31 virtual base::string16 GetWindowTitle() const OVERRIDE; |
| 33 virtual base::string16 GetDialogButtonLabel( | 32 virtual base::string16 GetDialogButtonLabel( |
| 34 ui::DialogButton button) const OVERRIDE; | 33 ui::DialogButton button) const OVERRIDE; |
| 35 virtual bool Cancel() OVERRIDE; | 34 virtual bool Cancel() OVERRIDE; |
| 36 virtual bool Accept() OVERRIDE; | 35 virtual bool Accept() OVERRIDE; |
| 37 | 36 |
| 38 // views::WidgetDelegate: | 37 // views::WidgetDelegate: |
| 39 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 38 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
| 40 virtual views::View* GetContentsView() OVERRIDE; | 39 virtual views::View* GetContentsView() OVERRIDE; |
| 41 virtual views::NonClientFrameView* CreateNonClientFrameView( | |
| 42 views::Widget* widget) OVERRIDE; | |
| 43 virtual views::Widget* GetWidget() OVERRIDE; | 40 virtual views::Widget* GetWidget() OVERRIDE; |
| 44 virtual const views::Widget* GetWidget() const OVERRIDE; | 41 virtual const views::Widget* GetWidget() const OVERRIDE; |
| 45 virtual void DeleteDelegate() OVERRIDE; | 42 virtual void DeleteDelegate() OVERRIDE; |
| 46 virtual ui::ModalType GetModalType() const OVERRIDE; | 43 virtual ui::ModalType GetModalType() const OVERRIDE; |
| 47 | 44 |
| 48 private: | 45 private: |
| 49 // The message box view whose commands we handle. | 46 // The message box view whose commands we handle. |
| 50 views::MessageBoxView* message_box_view_; | 47 views::MessageBoxView* message_box_view_; |
| 51 | 48 |
| 52 views::Widget* dialog_; | 49 views::Widget* dialog_; |
| 53 content::BrowserContext* browser_context_; | |
| 54 | 50 |
| 55 PasswordDialogClosedCallback callback_; | 51 PasswordDialogClosedCallback callback_; |
| 56 | 52 |
| 57 DISALLOW_COPY_AND_ASSIGN(PDFPasswordDialogViews); | 53 DISALLOW_COPY_AND_ASSIGN(PDFPasswordDialogViews); |
| 58 }; | 54 }; |
| 59 | 55 |
| 60 PDFPasswordDialogViews::PDFPasswordDialogViews( | 56 PDFPasswordDialogViews::PDFPasswordDialogViews( |
| 61 content::WebContents* web_contents, | 57 content::WebContents* web_contents, |
| 62 const base::string16& prompt, | 58 const base::string16& prompt, |
| 63 const PasswordDialogClosedCallback& callback) | 59 const PasswordDialogClosedCallback& callback) |
| 64 : message_box_view_(NULL), | 60 : message_box_view_(NULL), |
| 65 dialog_(NULL), | 61 dialog_(NULL), |
| 66 browser_context_(web_contents->GetBrowserContext()), | |
| 67 callback_(callback) { | 62 callback_(callback) { |
| 68 views::MessageBoxView::InitParams init_params(prompt); | 63 views::MessageBoxView::InitParams init_params(prompt); |
| 69 init_params.options = views::MessageBoxView::HAS_PROMPT_FIELD; | 64 init_params.options = views::MessageBoxView::HAS_PROMPT_FIELD; |
| 70 init_params.inter_row_vertical_spacing = | 65 init_params.inter_row_vertical_spacing = |
| 71 views::kUnrelatedControlVerticalSpacing; | 66 views::kUnrelatedControlVerticalSpacing; |
| 72 message_box_view_ = new views::MessageBoxView(init_params); | 67 message_box_view_ = new views::MessageBoxView(init_params); |
| 73 message_box_view_->text_box()->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 68 message_box_view_->text_box()->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 74 | 69 |
| 75 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 70 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 76 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); | 71 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // PDFPasswordDialogViews, views::WidgetDelegate implementation: | 117 // PDFPasswordDialogViews, views::WidgetDelegate implementation: |
| 123 | 118 |
| 124 views::View* PDFPasswordDialogViews::GetInitiallyFocusedView() { | 119 views::View* PDFPasswordDialogViews::GetInitiallyFocusedView() { |
| 125 return message_box_view_->text_box(); | 120 return message_box_view_->text_box(); |
| 126 } | 121 } |
| 127 | 122 |
| 128 views::View* PDFPasswordDialogViews::GetContentsView() { | 123 views::View* PDFPasswordDialogViews::GetContentsView() { |
| 129 return message_box_view_; | 124 return message_box_view_; |
| 130 } | 125 } |
| 131 | 126 |
| 132 // TODO(wittman): Remove this override once we move to the new style frame view | |
| 133 // on all dialogs. | |
| 134 views::NonClientFrameView* PDFPasswordDialogViews::CreateNonClientFrameView( | |
| 135 views::Widget* widget) { | |
| 136 return CreateConstrainedStyleNonClientFrameView(widget, browser_context_); | |
| 137 } | |
| 138 | |
| 139 views::Widget* PDFPasswordDialogViews::GetWidget() { | 127 views::Widget* PDFPasswordDialogViews::GetWidget() { |
| 140 return message_box_view_->GetWidget(); | 128 return message_box_view_->GetWidget(); |
| 141 } | 129 } |
| 142 | 130 |
| 143 const views::Widget* PDFPasswordDialogViews::GetWidget() const { | 131 const views::Widget* PDFPasswordDialogViews::GetWidget() const { |
| 144 return message_box_view_->GetWidget(); | 132 return message_box_view_->GetWidget(); |
| 145 } | 133 } |
| 146 | 134 |
| 147 void PDFPasswordDialogViews::DeleteDelegate() { | 135 void PDFPasswordDialogViews::DeleteDelegate() { |
| 148 delete this; | 136 delete this; |
| 149 } | 137 } |
| 150 | 138 |
| 151 ui::ModalType PDFPasswordDialogViews::GetModalType() const { | 139 ui::ModalType PDFPasswordDialogViews::GetModalType() const { |
| 152 #if defined(USE_ASH) | 140 #if defined(USE_ASH) |
| 153 return ui::MODAL_TYPE_CHILD; | 141 return ui::MODAL_TYPE_CHILD; |
| 154 #else | 142 #else |
| 155 return views::WidgetDelegate::GetModalType(); | 143 return views::WidgetDelegate::GetModalType(); |
| 156 #endif | 144 #endif |
| 157 } | 145 } |
| 158 | 146 |
| 159 } // namespace | 147 } // namespace |
| 160 | 148 |
| 161 void ShowPDFPasswordDialog(content::WebContents* web_contents, | 149 void ShowPDFPasswordDialog(content::WebContents* web_contents, |
| 162 const base::string16& prompt, | 150 const base::string16& prompt, |
| 163 const PasswordDialogClosedCallback& callback) { | 151 const PasswordDialogClosedCallback& callback) { |
| 164 new PDFPasswordDialogViews(web_contents, prompt, callback); | 152 new PDFPasswordDialogViews(web_contents, prompt, callback); |
| 165 } | 153 } |
| OLD | NEW |