| 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 "ui/views/window/dialog_delegate.h" | 5 #include "ui/views/window/dialog_delegate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "grit/ui_strings.h" | 8 #include "grit/ui_strings.h" |
| 9 #include "ui/base/l10n/l10n_util.h" | 9 #include "ui/base/l10n/l10n_util.h" |
| 10 #include "ui/base/ui_base_switches_util.h" | 10 #include "ui/base/ui_base_switches_util.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 bool DialogDelegate::Accept() { | 84 bool DialogDelegate::Accept() { |
| 85 return true; | 85 return true; |
| 86 } | 86 } |
| 87 | 87 |
| 88 base::string16 DialogDelegate::GetDialogLabel() const { | 88 base::string16 DialogDelegate::GetDialogLabel() const { |
| 89 return base::string16(); | 89 return base::string16(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 base::string16 DialogDelegate::GetDialogTitle() const { | 92 base::string16 DialogDelegate::GetDialogTitle() const { |
| 93 return base::string16(); | 93 return GetWindowTitle(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 int DialogDelegate::GetDialogButtons() const { | 96 int DialogDelegate::GetDialogButtons() const { |
| 97 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; | 97 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; |
| 98 } | 98 } |
| 99 | 99 |
| 100 int DialogDelegate::GetDefaultDialogButton() const { | 100 int DialogDelegate::GetDefaultDialogButton() const { |
| 101 if (GetDialogButtons() & ui::DIALOG_BUTTON_OK) | 101 if (GetDialogButtons() & ui::DIALOG_BUTTON_OK) |
| 102 return ui::DIALOG_BUTTON_OK; | 102 return ui::DIALOG_BUTTON_OK; |
| 103 if (GetDialogButtons() & ui::DIALOG_BUTTON_CANCEL) | 103 if (GetDialogButtons() & ui::DIALOG_BUTTON_CANCEL) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 if (UseNewStyleForThisDialog()) | 158 if (UseNewStyleForThisDialog()) |
| 159 return CreateNewStyleFrameView(widget); | 159 return CreateNewStyleFrameView(widget); |
| 160 return WidgetDelegate::CreateNonClientFrameView(widget); | 160 return WidgetDelegate::CreateNonClientFrameView(widget); |
| 161 } | 161 } |
| 162 | 162 |
| 163 // static | 163 // static |
| 164 NonClientFrameView* DialogDelegate::CreateNewStyleFrameView(Widget* widget) { | 164 NonClientFrameView* DialogDelegate::CreateNewStyleFrameView(Widget* widget) { |
| 165 return CreateNewStyleFrameView(widget, false); | 165 return CreateNewStyleFrameView(widget, false); |
| 166 } | 166 } |
| 167 | 167 |
| 168 // static |
| 168 NonClientFrameView* DialogDelegate::CreateNewStyleFrameView( | 169 NonClientFrameView* DialogDelegate::CreateNewStyleFrameView( |
| 169 Widget* widget, | 170 Widget* widget, |
| 170 bool force_opaque_border) { | 171 bool force_opaque_border) { |
| 171 BubbleFrameView* frame = new BubbleFrameView(gfx::Insets()); | 172 BubbleFrameView* frame = new BubbleFrameView(gfx::Insets()); |
| 172 const SkColor color = widget->GetNativeTheme()->GetSystemColor( | 173 const SkColor color = widget->GetNativeTheme()->GetSystemColor( |
| 173 ui::NativeTheme::kColorId_DialogBackground); | 174 ui::NativeTheme::kColorId_DialogBackground); |
| 174 if (force_opaque_border) { | 175 if (force_opaque_border) { |
| 175 frame->SetBubbleBorder(new BubbleBorder( | 176 frame->SetBubbleBorder(new BubbleBorder( |
| 176 BubbleBorder::NONE, | 177 BubbleBorder::NONE, |
| 177 BubbleBorder::NO_SHADOW_OPAQUE_BORDER, | 178 BubbleBorder::NO_SHADOW_OPAQUE_BORDER, |
| 178 color)); | 179 color)); |
| 179 } else { | 180 } else { |
| 180 frame->SetBubbleBorder(new BubbleBorder(BubbleBorder::FLOAT, | 181 frame->SetBubbleBorder(new BubbleBorder(BubbleBorder::FLOAT, |
| 181 BubbleBorder::SMALL_SHADOW, | 182 BubbleBorder::SMALL_SHADOW, |
| 182 color)); | 183 color)); |
| 183 } | 184 } |
| 184 frame->SetTitle(widget->widget_delegate()->GetWindowTitle()); | |
| 185 DialogDelegate* delegate = widget->widget_delegate()->AsDialogDelegate(); | 185 DialogDelegate* delegate = widget->widget_delegate()->AsDialogDelegate(); |
| 186 if (delegate) { | 186 if (delegate) { |
| 187 View* titlebar_view = delegate->CreateTitlebarExtraView(); | 187 View* titlebar_view = delegate->CreateTitlebarExtraView(); |
| 188 if (titlebar_view) | 188 if (titlebar_view) |
| 189 frame->SetTitlebarExtraView(titlebar_view); | 189 frame->SetTitlebarExtraView(titlebar_view); |
| 190 } | 190 } |
| 191 frame->SetShowCloseButton(widget->widget_delegate()->ShouldShowCloseButton()); | |
| 192 if (force_opaque_border) | 191 if (force_opaque_border) |
| 193 widget->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM); | 192 widget->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM); |
| 194 return frame; | 193 return frame; |
| 195 } | 194 } |
| 196 | 195 |
| 197 bool DialogDelegate::UseNewStyleForThisDialog() const { | 196 bool DialogDelegate::UseNewStyleForThisDialog() const { |
| 198 return UseNewStyle(); | 197 return UseNewStyle(); |
| 199 } | 198 } |
| 200 | 199 |
| 201 const DialogClientView* DialogDelegate::GetDialogClientView() const { | 200 const DialogClientView* DialogDelegate::GetDialogClientView() const { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 230 | 229 |
| 231 const Widget* DialogDelegateView::GetWidget() const { | 230 const Widget* DialogDelegateView::GetWidget() const { |
| 232 return View::GetWidget(); | 231 return View::GetWidget(); |
| 233 } | 232 } |
| 234 | 233 |
| 235 View* DialogDelegateView::GetContentsView() { | 234 View* DialogDelegateView::GetContentsView() { |
| 236 return this; | 235 return this; |
| 237 } | 236 } |
| 238 | 237 |
| 239 } // namespace views | 238 } // namespace views |
| OLD | NEW |