Chromium Code Reviews| 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/views/bubble/bubble_border.h" | 10 #include "ui/views/bubble/bubble_border.h" |
| 11 #include "ui/views/bubble/bubble_frame_view.h" | 11 #include "ui/views/bubble/bubble_frame_view.h" |
| 12 #include "ui/views/controls/button/label_button.h" | 12 #include "ui/views/controls/button/label_button.h" |
| 13 #include "ui/views/widget/widget.h" | 13 #include "ui/views/widget/widget.h" |
| 14 #include "ui/views/widget/widget_observer.h" | 14 #include "ui/views/widget/widget_observer.h" |
| 15 #include "ui/views/window/dialog_client_view.h" | 15 #include "ui/views/window/dialog_client_view.h" |
| 16 | |
| 17 #if defined(USE_AURA) | |
| 18 #include "ui/views/corewm/shadow_types.h" | 16 #include "ui/views/corewm/shadow_types.h" |
|
Mike Wittman
2014/02/07 15:02:44
include order
Lei Zhang
2014/02/07 22:55:21
Done.
| |
| 19 #endif | |
| 20 | 17 |
| 21 namespace views { | 18 namespace views { |
| 22 | 19 |
| 23 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
| 24 // DialogDelegate: | 21 // DialogDelegate: |
| 25 | 22 |
| 26 DialogDelegate::~DialogDelegate() { | 23 DialogDelegate::~DialogDelegate() { |
| 27 } | 24 } |
| 28 | 25 |
| 29 // static | 26 // static |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 } | 148 } |
| 152 | 149 |
| 153 NonClientFrameView* DialogDelegate::CreateNonClientFrameView(Widget* widget) { | 150 NonClientFrameView* DialogDelegate::CreateNonClientFrameView(Widget* widget) { |
| 154 if (UseNewStyleForThisDialog()) | 151 if (UseNewStyleForThisDialog()) |
| 155 return CreateDialogFrameView(widget); | 152 return CreateDialogFrameView(widget); |
| 156 return WidgetDelegate::CreateNonClientFrameView(widget); | 153 return WidgetDelegate::CreateNonClientFrameView(widget); |
| 157 } | 154 } |
| 158 | 155 |
| 159 // static | 156 // static |
| 160 NonClientFrameView* DialogDelegate::CreateDialogFrameView(Widget* widget) { | 157 NonClientFrameView* DialogDelegate::CreateDialogFrameView(Widget* widget) { |
| 161 return CreateDialogFrameView(widget, false); | |
| 162 } | |
| 163 | |
| 164 // static | |
| 165 NonClientFrameView* DialogDelegate::CreateDialogFrameView( | |
| 166 Widget* widget, | |
| 167 bool force_opaque_border) { | |
| 168 BubbleFrameView* frame = new BubbleFrameView(gfx::Insets()); | 158 BubbleFrameView* frame = new BubbleFrameView(gfx::Insets()); |
| 169 const SkColor color = widget->GetNativeTheme()->GetSystemColor( | 159 const SkColor color = widget->GetNativeTheme()->GetSystemColor( |
| 170 ui::NativeTheme::kColorId_DialogBackground); | 160 ui::NativeTheme::kColorId_DialogBackground); |
| 171 if (force_opaque_border) { | 161 frame->SetBubbleBorder(scoped_ptr<BubbleBorder>(new BubbleBorder( |
| 172 frame->SetBubbleBorder(scoped_ptr<BubbleBorder>(new BubbleBorder( | 162 BubbleBorder::FLOAT, BubbleBorder::SMALL_SHADOW, color))); |
| 173 BubbleBorder::NONE, BubbleBorder::NO_SHADOW_OPAQUE_BORDER, color))); | |
| 174 } else { | |
| 175 frame->SetBubbleBorder(scoped_ptr<BubbleBorder>(new BubbleBorder( | |
| 176 BubbleBorder::FLOAT, BubbleBorder::SMALL_SHADOW, color))); | |
| 177 } | |
| 178 DialogDelegate* delegate = widget->widget_delegate()->AsDialogDelegate(); | 163 DialogDelegate* delegate = widget->widget_delegate()->AsDialogDelegate(); |
| 179 if (delegate) { | 164 if (delegate) { |
| 180 View* titlebar_view = delegate->CreateTitlebarExtraView(); | 165 View* titlebar_view = delegate->CreateTitlebarExtraView(); |
| 181 if (titlebar_view) | 166 if (titlebar_view) |
| 182 frame->SetTitlebarExtraView(titlebar_view); | 167 frame->SetTitlebarExtraView(titlebar_view); |
| 183 } | 168 } |
| 184 if (force_opaque_border) | |
| 185 widget->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM); | |
| 186 #if defined(USE_AURA) | |
| 187 // TODO(msw): Add a matching shadow type and remove the bubble frame border? | 169 // TODO(msw): Add a matching shadow type and remove the bubble frame border? |
| 188 corewm::SetShadowType(widget->GetNativeWindow(), corewm::SHADOW_TYPE_NONE); | 170 corewm::SetShadowType(widget->GetNativeWindow(), corewm::SHADOW_TYPE_NONE); |
| 189 #endif | |
| 190 return frame; | 171 return frame; |
| 191 } | 172 } |
| 192 | 173 |
| 193 bool DialogDelegate::UseNewStyleForThisDialog() const { | 174 bool DialogDelegate::UseNewStyleForThisDialog() const { |
| 194 return true; | 175 return true; |
| 195 } | 176 } |
| 196 | 177 |
| 197 const DialogClientView* DialogDelegate::GetDialogClientView() const { | 178 const DialogClientView* DialogDelegate::GetDialogClientView() const { |
| 198 return GetWidget()->client_view()->AsDialogClientView(); | 179 return GetWidget()->client_view()->AsDialogClientView(); |
| 199 } | 180 } |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 226 | 207 |
| 227 const Widget* DialogDelegateView::GetWidget() const { | 208 const Widget* DialogDelegateView::GetWidget() const { |
| 228 return View::GetWidget(); | 209 return View::GetWidget(); |
| 229 } | 210 } |
| 230 | 211 |
| 231 View* DialogDelegateView::GetContentsView() { | 212 View* DialogDelegateView::GetContentsView() { |
| 232 return this; | 213 return this; |
| 233 } | 214 } |
| 234 | 215 |
| 235 } // namespace views | 216 } // namespace views |
| OLD | NEW |