| 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/views/tab_modal_confirm_dialog_views.h" | 5 #include "chrome/browser/ui/views/tab_modal_confirm_dialog_views.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser_dialogs.h" | 8 #include "chrome/browser/ui/browser_dialogs.h" |
| 9 #include "chrome/browser/ui/browser_list.h" | 9 #include "chrome/browser/ui/browser_list.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
| 12 #include "chrome/browser/ui/views/constrained_window_views.h" | |
| 13 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 14 #include "components/web_modal/web_contents_modal_dialog_host.h" | 13 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 15 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 14 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 16 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 15 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 17 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 18 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/window_open_disposition.h" | 19 #include "ui/base/window_open_disposition.h" |
| 21 #include "ui/views/controls/message_box_view.h" | 20 #include "ui/views/controls/message_box_view.h" |
| 22 #include "ui/views/layout/layout_constants.h" | 21 #include "ui/views/layout/layout_constants.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 34 delegate, web_contents); | 33 delegate, web_contents); |
| 35 } | 34 } |
| 36 | 35 |
| 37 ////////////////////////////////////////////////////////////////////////////// | 36 ////////////////////////////////////////////////////////////////////////////// |
| 38 // TabModalConfirmDialogViews, constructor & destructor: | 37 // TabModalConfirmDialogViews, constructor & destructor: |
| 39 | 38 |
| 40 TabModalConfirmDialogViews::TabModalConfirmDialogViews( | 39 TabModalConfirmDialogViews::TabModalConfirmDialogViews( |
| 41 TabModalConfirmDialogDelegate* delegate, | 40 TabModalConfirmDialogDelegate* delegate, |
| 42 content::WebContents* web_contents) | 41 content::WebContents* web_contents) |
| 43 : delegate_(delegate), | 42 : delegate_(delegate), |
| 44 dialog_(NULL), | 43 dialog_(NULL) { |
| 45 browser_context_(web_contents->GetBrowserContext()) { | |
| 46 views::MessageBoxView::InitParams init_params(delegate->GetDialogMessage()); | 44 views::MessageBoxView::InitParams init_params(delegate->GetDialogMessage()); |
| 47 init_params.inter_row_vertical_spacing = | 45 init_params.inter_row_vertical_spacing = |
| 48 views::kUnrelatedControlVerticalSpacing; | 46 views::kUnrelatedControlVerticalSpacing; |
| 49 message_box_view_ = new views::MessageBoxView(init_params); | 47 message_box_view_ = new views::MessageBoxView(init_params); |
| 50 | 48 |
| 51 base::string16 link_text(delegate->GetLinkText()); | 49 base::string16 link_text(delegate->GetLinkText()); |
| 52 if (!link_text.empty()) | 50 if (!link_text.empty()) |
| 53 message_box_view_->SetLink(link_text, this); | 51 message_box_view_->SetLink(link_text, this); |
| 54 | 52 |
| 55 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 53 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return true; | 115 return true; |
| 118 } | 116 } |
| 119 | 117 |
| 120 /////////////////////////////////////////////////////////////////////////////// | 118 /////////////////////////////////////////////////////////////////////////////// |
| 121 // TabModalConfirmDialogViews, views::WidgetDelegate implementation: | 119 // TabModalConfirmDialogViews, views::WidgetDelegate implementation: |
| 122 | 120 |
| 123 views::View* TabModalConfirmDialogViews::GetContentsView() { | 121 views::View* TabModalConfirmDialogViews::GetContentsView() { |
| 124 return message_box_view_; | 122 return message_box_view_; |
| 125 } | 123 } |
| 126 | 124 |
| 127 // TODO(wittman): Remove this override once we move to the new style frame view | |
| 128 // on all dialogs. | |
| 129 views::NonClientFrameView* TabModalConfirmDialogViews::CreateNonClientFrameView( | |
| 130 views::Widget* widget) { | |
| 131 return CreateConstrainedStyleNonClientFrameView(widget, browser_context_); | |
| 132 } | |
| 133 | |
| 134 views::Widget* TabModalConfirmDialogViews::GetWidget() { | 125 views::Widget* TabModalConfirmDialogViews::GetWidget() { |
| 135 return message_box_view_->GetWidget(); | 126 return message_box_view_->GetWidget(); |
| 136 } | 127 } |
| 137 | 128 |
| 138 const views::Widget* TabModalConfirmDialogViews::GetWidget() const { | 129 const views::Widget* TabModalConfirmDialogViews::GetWidget() const { |
| 139 return message_box_view_->GetWidget(); | 130 return message_box_view_->GetWidget(); |
| 140 } | 131 } |
| 141 | 132 |
| 142 void TabModalConfirmDialogViews::DeleteDelegate() { | 133 void TabModalConfirmDialogViews::DeleteDelegate() { |
| 143 delete this; | 134 delete this; |
| 144 } | 135 } |
| 145 | 136 |
| 146 ui::ModalType TabModalConfirmDialogViews::GetModalType() const { | 137 ui::ModalType TabModalConfirmDialogViews::GetModalType() const { |
| 147 #if defined(USE_ASH) | 138 #if defined(USE_ASH) |
| 148 return ui::MODAL_TYPE_CHILD; | 139 return ui::MODAL_TYPE_CHILD; |
| 149 #else | 140 #else |
| 150 return views::WidgetDelegate::GetModalType(); | 141 return views::WidgetDelegate::GetModalType(); |
| 151 #endif | 142 #endif |
| 152 } | 143 } |
| OLD | NEW |