| 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/views/harmony/chrome_layout_provider.h" |
| 11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 12 #include "components/constrained_window/constrained_window_views.h" | 13 #include "components/constrained_window/constrained_window_views.h" |
| 13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 14 #include "ui/base/window_open_disposition.h" | 15 #include "ui/base/window_open_disposition.h" |
| 15 #include "ui/views/controls/message_box_view.h" | 16 #include "ui/views/controls/message_box_view.h" |
| 16 #include "ui/views/layout/layout_constants.h" | |
| 17 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 18 #include "ui/views/window/dialog_client_view.h" | 18 #include "ui/views/window/dialog_client_view.h" |
| 19 | 19 |
| 20 // static | 20 // static |
| 21 TabModalConfirmDialog* TabModalConfirmDialog::Create( | 21 TabModalConfirmDialog* TabModalConfirmDialog::Create( |
| 22 TabModalConfirmDialogDelegate* delegate, | 22 TabModalConfirmDialogDelegate* delegate, |
| 23 content::WebContents* web_contents) { | 23 content::WebContents* web_contents) { |
| 24 return new TabModalConfirmDialogViews(delegate, web_contents); | 24 return new TabModalConfirmDialogViews(delegate, web_contents); |
| 25 } | 25 } |
| 26 | 26 |
| 27 ////////////////////////////////////////////////////////////////////////////// | 27 ////////////////////////////////////////////////////////////////////////////// |
| 28 // TabModalConfirmDialogViews, constructor & destructor: | 28 // TabModalConfirmDialogViews, constructor & destructor: |
| 29 | 29 |
| 30 TabModalConfirmDialogViews::TabModalConfirmDialogViews( | 30 TabModalConfirmDialogViews::TabModalConfirmDialogViews( |
| 31 TabModalConfirmDialogDelegate* delegate, | 31 TabModalConfirmDialogDelegate* delegate, |
| 32 content::WebContents* web_contents) | 32 content::WebContents* web_contents) |
| 33 : delegate_(delegate) { | 33 : delegate_(delegate) { |
| 34 views::MessageBoxView::InitParams init_params(delegate->GetDialogMessage()); | 34 views::MessageBoxView::InitParams init_params(delegate->GetDialogMessage()); |
| 35 init_params.inter_row_vertical_spacing = | 35 init_params.inter_row_vertical_spacing = |
| 36 views::kUnrelatedControlVerticalSpacing; | 36 ChromeLayoutProvider::Get()->GetDistanceMetric( |
| 37 DISTANCE_UNRELATED_CONTROL_VERTICAL); |
| 37 message_box_view_ = new views::MessageBoxView(init_params); | 38 message_box_view_ = new views::MessageBoxView(init_params); |
| 38 | 39 |
| 39 base::string16 link_text(delegate->GetLinkText()); | 40 base::string16 link_text(delegate->GetLinkText()); |
| 40 if (!link_text.empty()) | 41 if (!link_text.empty()) |
| 41 message_box_view_->SetLink(link_text, this); | 42 message_box_view_->SetLink(link_text, this); |
| 42 | 43 |
| 43 constrained_window::ShowWebModalDialogViews(this, web_contents); | 44 constrained_window::ShowWebModalDialogViews(this, web_contents); |
| 44 delegate_->set_close_delegate(this); | 45 delegate_->set_close_delegate(this); |
| 45 } | 46 } |
| 46 | 47 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 return message_box_view_->GetWidget(); | 114 return message_box_view_->GetWidget(); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void TabModalConfirmDialogViews::DeleteDelegate() { | 117 void TabModalConfirmDialogViews::DeleteDelegate() { |
| 117 delete this; | 118 delete this; |
| 118 } | 119 } |
| 119 | 120 |
| 120 ui::ModalType TabModalConfirmDialogViews::GetModalType() const { | 121 ui::ModalType TabModalConfirmDialogViews::GetModalType() const { |
| 121 return ui::MODAL_TYPE_CHILD; | 122 return ui::MODAL_TYPE_CHILD; |
| 122 } | 123 } |
| OLD | NEW |