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 "ash/wm/system_modal_container_layout_manager.h" | 5 #include "ash/wm/system_modal_container_layout_manager.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | |
8 #include "ash/shell.h" | 7 #include "ash/shell.h" |
9 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
10 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
11 #include "ash/wm/system_modal_container_event_filter.h" | 10 #include "ash/wm/system_modal_container_event_filter.h" |
12 #include "ash/wm/window_animations.h" | 11 #include "ash/wm/window_animations.h" |
13 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
14 #include "base/bind.h" | 13 #include "base/bind.h" |
15 #include "base/command_line.h" | 14 #include "base/command_line.h" |
16 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
17 #include "ui/aura/client/capture_client.h" | 16 #include "ui/aura/client/capture_client.h" |
18 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
19 #include "ui/views/corewm/compound_event_filter.h" | 18 #include "ui/views/corewm/compound_event_filter.h" |
20 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
21 #include "ui/base/events/event.h" | 20 #include "ui/base/events/event.h" |
| 21 #include "ui/base/ui_base_switches.h" |
22 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
23 #include "ui/compositor/layer_animator.h" | 23 #include "ui/compositor/layer_animator.h" |
24 #include "ui/compositor/scoped_layer_animation_settings.h" | 24 #include "ui/compositor/scoped_layer_animation_settings.h" |
25 #include "ui/gfx/canvas.h" | |
26 #include "ui/gfx/screen.h" | 25 #include "ui/gfx/screen.h" |
27 #include "ui/views/view.h" | 26 #include "ui/views/view.h" |
28 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
29 | 28 |
30 namespace ash { | 29 namespace ash { |
31 namespace internal { | 30 namespace internal { |
32 | 31 |
33 namespace { | |
34 | |
35 class ModalBackgroundView : public views::View { | |
36 public: | |
37 ModalBackgroundView() {} | |
38 virtual ~ModalBackgroundView() {} | |
39 | |
40 // Overridden from views::View: | |
41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | |
42 canvas->FillRect(GetLocalBounds(), GetOverlayColor()); | |
43 } | |
44 | |
45 private: | |
46 SkColor GetOverlayColor() { | |
47 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
48 switches::kAuraGoogleDialogFrames)) { | |
49 return SK_ColorWHITE; | |
50 } | |
51 return SK_ColorBLACK; | |
52 } | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(ModalBackgroundView); | |
55 }; | |
56 | |
57 } // namespace | |
58 | |
59 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
60 // SystemModalContainerLayoutManager, public: | 33 // SystemModalContainerLayoutManager, public: |
61 | 34 |
62 SystemModalContainerLayoutManager::SystemModalContainerLayoutManager( | 35 SystemModalContainerLayoutManager::SystemModalContainerLayoutManager( |
63 aura::Window* container) | 36 aura::Window* container) |
64 : container_(container), | 37 : container_(container), |
65 modal_background_(NULL) { | 38 modal_background_(NULL) { |
66 } | 39 } |
67 | 40 |
68 SystemModalContainerLayoutManager::~SystemModalContainerLayoutManager() { | 41 SystemModalContainerLayoutManager::~SystemModalContainerLayoutManager() { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 void SystemModalContainerLayoutManager::CreateModalBackground() { | 154 void SystemModalContainerLayoutManager::CreateModalBackground() { |
182 if (!modal_background_) { | 155 if (!modal_background_) { |
183 modal_background_ = new views::Widget; | 156 modal_background_ = new views::Widget; |
184 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); | 157 views::Widget::InitParams params(views::Widget::InitParams::TYPE_CONTROL); |
185 params.parent = container_; | 158 params.parent = container_; |
186 params.bounds = Shell::GetScreen()->GetDisplayNearestWindow( | 159 params.bounds = Shell::GetScreen()->GetDisplayNearestWindow( |
187 container_).bounds(); | 160 container_).bounds(); |
188 modal_background_->Init(params); | 161 modal_background_->Init(params); |
189 modal_background_->GetNativeView()->SetName( | 162 modal_background_->GetNativeView()->SetName( |
190 "SystemModalContainerLayoutManager.ModalBackground"); | 163 "SystemModalContainerLayoutManager.ModalBackground"); |
191 modal_background_->SetContentsView(new ModalBackgroundView); | 164 views::View* contents_view = new views::View(); |
| 165 contents_view->set_background(views::Background::CreateSolidBackground( |
| 166 CommandLine::ForCurrentProcess()->HasSwitch( |
| 167 switches::kEnableNewDialogStyle) ? SK_ColorWHITE : SK_ColorBLACK)); |
| 168 modal_background_->SetContentsView(contents_view); |
192 modal_background_->GetNativeView()->layer()->SetOpacity(0.0f); | 169 modal_background_->GetNativeView()->layer()->SetOpacity(0.0f); |
193 } | 170 } |
194 | 171 |
195 ui::ScopedLayerAnimationSettings settings( | 172 ui::ScopedLayerAnimationSettings settings( |
196 modal_background_->GetNativeView()->layer()->GetAnimator()); | 173 modal_background_->GetNativeView()->layer()->GetAnimator()); |
197 modal_background_->Show(); | 174 modal_background_->Show(); |
198 modal_background_->GetNativeView()->layer()->SetOpacity(0.5f); | 175 modal_background_->GetNativeView()->layer()->SetOpacity(0.5f); |
199 container_->StackChildAtTop(modal_background_->GetNativeView()); | 176 container_->StackChildAtTop(modal_background_->GetNativeView()); |
200 } | 177 } |
201 | 178 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 void SystemModalContainerLayoutManager::RemoveModalWindow( | 221 void SystemModalContainerLayoutManager::RemoveModalWindow( |
245 aura::Window* window) { | 222 aura::Window* window) { |
246 aura::Window::Windows::iterator it = | 223 aura::Window::Windows::iterator it = |
247 std::find(modal_windows_.begin(), modal_windows_.end(), window); | 224 std::find(modal_windows_.begin(), modal_windows_.end(), window); |
248 if (it != modal_windows_.end()) | 225 if (it != modal_windows_.end()) |
249 modal_windows_.erase(it); | 226 modal_windows_.erase(it); |
250 } | 227 } |
251 | 228 |
252 } // namespace internal | 229 } // namespace internal |
253 } // namespace ash | 230 } // namespace ash |
OLD | NEW |