| 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_; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // PDFPasswordDialogViews, views::WidgetDelegate implementation: | 119 // PDFPasswordDialogViews, views::WidgetDelegate implementation: |
| 123 | 120 |
| 124 views::View* PDFPasswordDialogViews::GetInitiallyFocusedView() { | 121 views::View* PDFPasswordDialogViews::GetInitiallyFocusedView() { |
| 125 return message_box_view_->text_box(); | 122 return message_box_view_->text_box(); |
| 126 } | 123 } |
| 127 | 124 |
| 128 views::View* PDFPasswordDialogViews::GetContentsView() { | 125 views::View* PDFPasswordDialogViews::GetContentsView() { |
| 129 return message_box_view_; | 126 return message_box_view_; |
| 130 } | 127 } |
| 131 | 128 |
| 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() { | 129 views::Widget* PDFPasswordDialogViews::GetWidget() { |
| 140 return message_box_view_->GetWidget(); | 130 return message_box_view_->GetWidget(); |
| 141 } | 131 } |
| 142 | 132 |
| 143 const views::Widget* PDFPasswordDialogViews::GetWidget() const { | 133 const views::Widget* PDFPasswordDialogViews::GetWidget() const { |
| 144 return message_box_view_->GetWidget(); | 134 return message_box_view_->GetWidget(); |
| 145 } | 135 } |
| 146 | 136 |
| 147 void PDFPasswordDialogViews::DeleteDelegate() { | 137 void PDFPasswordDialogViews::DeleteDelegate() { |
| 148 delete this; | 138 delete this; |
| 149 } | 139 } |
| 150 | 140 |
| 151 ui::ModalType PDFPasswordDialogViews::GetModalType() const { | 141 ui::ModalType PDFPasswordDialogViews::GetModalType() const { |
| 152 #if defined(USE_ASH) | 142 #if defined(USE_ASH) |
| 153 return ui::MODAL_TYPE_CHILD; | 143 return ui::MODAL_TYPE_CHILD; |
| 154 #else | 144 #else |
| 155 return views::WidgetDelegate::GetModalType(); | 145 return views::WidgetDelegate::GetModalType(); |
| 156 #endif | 146 #endif |
| 157 } | 147 } |
| 158 | 148 |
| 159 } // namespace | 149 } // namespace |
| 160 | 150 |
| 161 void ShowPDFPasswordDialog(content::WebContents* web_contents, | 151 void ShowPDFPasswordDialog(content::WebContents* web_contents, |
| 162 const base::string16& prompt, | 152 const base::string16& prompt, |
| 163 const PasswordDialogClosedCallback& callback) { | 153 const PasswordDialogClosedCallback& callback) { |
| 164 new PDFPasswordDialogViews(web_contents, prompt, callback); | 154 new PDFPasswordDialogViews(web_contents, prompt, callback); |
| 165 } | 155 } |
| OLD | NEW |