| 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/utf_string_conversions.h" | 7 #include "base/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_contents/tab_contents.h" | |
| 12 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
| 13 #include "chrome/browser/ui/views/constrained_window_views.h" | 12 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 14 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 15 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/views/controls/message_box_view.h" | 16 #include "ui/views/controls/message_box_view.h" |
| 18 #include "ui/views/window/dialog_client_view.h" | 17 #include "ui/views/window/dialog_client_view.h" |
| 19 | 18 |
| 20 // static | 19 // static |
| 21 TabModalConfirmDialog* TabModalConfirmDialog::Create( | 20 TabModalConfirmDialog* TabModalConfirmDialog::Create( |
| 22 TabModalConfirmDialogDelegate* delegate, | 21 TabModalConfirmDialogDelegate* delegate, |
| 23 TabContents* tab_contents) { | 22 content::WebContents* web_contents) { |
| 24 return new TabModalConfirmDialogViews( | 23 return new TabModalConfirmDialogViews( |
| 25 delegate, | 24 delegate, |
| 26 tab_contents, | 25 web_contents, |
| 27 chrome::IsFramelessConstrainedDialogEnabled()); | 26 chrome::IsFramelessConstrainedDialogEnabled()); |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace { | 29 namespace { |
| 31 | 30 |
| 32 const int kChromeStyleInterRowVerticalSpacing = 17; | 31 const int kChromeStyleInterRowVerticalSpacing = 17; |
| 33 | 32 |
| 34 views::MessageBoxView::InitParams CreateMessageBoxViewInitParams( | 33 views::MessageBoxView::InitParams CreateMessageBoxViewInitParams( |
| 35 const string16& message, | 34 const string16& message, |
| 36 bool enable_chrome_style) { | 35 bool enable_chrome_style) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 return params; | 47 return params; |
| 49 } | 48 } |
| 50 | 49 |
| 51 } // namespace | 50 } // namespace |
| 52 | 51 |
| 53 ////////////////////////////////////////////////////////////////////////////// | 52 ////////////////////////////////////////////////////////////////////////////// |
| 54 // TabModalConfirmDialogViews, constructor & destructor: | 53 // TabModalConfirmDialogViews, constructor & destructor: |
| 55 | 54 |
| 56 TabModalConfirmDialogViews::TabModalConfirmDialogViews( | 55 TabModalConfirmDialogViews::TabModalConfirmDialogViews( |
| 57 TabModalConfirmDialogDelegate* delegate, | 56 TabModalConfirmDialogDelegate* delegate, |
| 58 TabContents* tab_contents, | 57 content::WebContents* web_contents, |
| 59 bool enable_chrome_style) | 58 bool enable_chrome_style) |
| 60 : delegate_(delegate), | 59 : delegate_(delegate), |
| 61 message_box_view_(new views::MessageBoxView( | 60 message_box_view_(new views::MessageBoxView( |
| 62 CreateMessageBoxViewInitParams(delegate->GetMessage(), | 61 CreateMessageBoxViewInitParams(delegate->GetMessage(), |
| 63 enable_chrome_style))), | 62 enable_chrome_style))), |
| 64 enable_chrome_style_(enable_chrome_style) { | 63 enable_chrome_style_(enable_chrome_style) { |
| 65 delegate_->set_window(new ConstrainedWindowViews( | 64 delegate_->set_window(new ConstrainedWindowViews( |
| 66 tab_contents->web_contents(), this, enable_chrome_style, | 65 web_contents, this, enable_chrome_style, |
| 67 ConstrainedWindowViews::DEFAULT_INSETS)); | 66 ConstrainedWindowViews::DEFAULT_INSETS)); |
| 68 } | 67 } |
| 69 | 68 |
| 70 TabModalConfirmDialogViews::~TabModalConfirmDialogViews() { | 69 TabModalConfirmDialogViews::~TabModalConfirmDialogViews() { |
| 71 } | 70 } |
| 72 | 71 |
| 73 void TabModalConfirmDialogViews::AcceptTabModalDialog() { | 72 void TabModalConfirmDialogViews::AcceptTabModalDialog() { |
| 74 GetDialogClientView()->AcceptWindow(); | 73 GetDialogClientView()->AcceptWindow(); |
| 75 } | 74 } |
| 76 | 75 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 return message_box_view_->GetWidget(); | 118 return message_box_view_->GetWidget(); |
| 120 } | 119 } |
| 121 | 120 |
| 122 const views::Widget* TabModalConfirmDialogViews::GetWidget() const { | 121 const views::Widget* TabModalConfirmDialogViews::GetWidget() const { |
| 123 return message_box_view_->GetWidget(); | 122 return message_box_view_->GetWidget(); |
| 124 } | 123 } |
| 125 | 124 |
| 126 void TabModalConfirmDialogViews::DeleteDelegate() { | 125 void TabModalConfirmDialogViews::DeleteDelegate() { |
| 127 delete this; | 126 delete this; |
| 128 } | 127 } |
| OLD | NEW |