OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/ui/kiosk_external_update_notification.h" | 5 #include "chrome/browser/chromeos/ui/kiosk_external_update_notification.h" |
6 | 6 |
7 #include "ash/shell.h" | |
8 #include "ash/shell_window_ids.h" | |
9 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
10 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/compositor/layer.h" | 9 #include "ui/compositor/layer.h" |
12 #include "ui/compositor/scoped_layer_animation_settings.h" | 10 #include "ui/compositor/scoped_layer_animation_settings.h" |
13 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
14 #include "ui/views/controls/label.h" | 12 #include "ui/views/controls/label.h" |
15 #include "ui/views/layout/fill_layout.h" | 13 #include "ui/views/layout/fill_layout.h" |
16 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
17 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
18 #include "ui/views/widget/widget_delegate.h" | 16 #include "ui/views/widget/widget_delegate.h" |
19 | 17 |
18 #if defined(USE_ASH) | |
19 #include "ash/shell.h" | |
20 #include "ash/shell_window_ids.h" | |
21 #endif | |
22 | |
20 namespace chromeos { | 23 namespace chromeos { |
21 | 24 |
22 namespace { | 25 namespace { |
23 | 26 |
24 const SkColor kTextColor = SK_ColorBLACK; | 27 const SkColor kTextColor = SK_ColorBLACK; |
25 const SkColor kWindowBackgroundColor = SK_ColorWHITE; | 28 const SkColor kWindowBackgroundColor = SK_ColorWHITE; |
26 const int kWindowCornerRadius = 4; | 29 const int kWindowCornerRadius = 4; |
27 const int kPreferredWidth = 600; | 30 const int kPreferredWidth = 600; |
28 const int kPreferredHeight = 250; | 31 const int kPreferredHeight = 250; |
29 | 32 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 const base::string16& message) { | 116 const base::string16& message) { |
114 if (view_) | 117 if (view_) |
115 view_->SetMessage(message); | 118 view_->SetMessage(message); |
116 } | 119 } |
117 | 120 |
118 void KioskExternalUpdateNotification::CreateAndShowNotificationView( | 121 void KioskExternalUpdateNotification::CreateAndShowNotificationView( |
119 const base::string16& message) { | 122 const base::string16& message) { |
120 view_ = new KioskExternalUpdateNotificationView(this); | 123 view_ = new KioskExternalUpdateNotificationView(this); |
121 view_->SetMessage(message); | 124 view_->SetMessage(message); |
122 | 125 |
126 gfx::Size rs; | |
Jun Mukai
2014/10/29 01:03:27
how about CHECK(ash::Shell::HasInstance()) ?
| |
127 aura::Window* parent = NULL; | |
128 #if defined(USE_ASH) | |
123 aura::Window* root_window = ash::Shell::GetTargetRootWindow(); | 129 aura::Window* root_window = ash::Shell::GetTargetRootWindow(); |
124 gfx::Size rs = root_window->bounds().size(); | 130 rs = root_window->bounds().size(); |
131 parent = ash::Shell::GetContainer(root_window, | |
132 ash::kShellWindowId_SettingBubbleContainer); | |
133 #else | |
134 NOTREACHED(); | |
135 #endif | |
136 | |
125 gfx::Size ps = view_->GetPreferredSize(); | 137 gfx::Size ps = view_->GetPreferredSize(); |
126 gfx::Rect bounds((rs.width() - ps.width()) / 2, | 138 gfx::Rect bounds((rs.width() - ps.width()) / 2, |
127 (rs.height() - ps.height()) / 10, | 139 (rs.height() - ps.height()) / 10, |
128 ps.width(), | 140 ps.width(), |
129 ps.height()); | 141 ps.height()); |
130 views::Widget::InitParams params; | 142 views::Widget::InitParams params; |
131 params.type = views::Widget::InitParams::TYPE_POPUP; | 143 params.type = views::Widget::InitParams::TYPE_POPUP; |
132 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 144 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
133 params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; | 145 params.ownership = views::Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET; |
134 params.accept_events = false; | 146 params.accept_events = false; |
135 params.keep_on_top = true; | 147 params.keep_on_top = true; |
136 params.remove_standard_frame = true; | 148 params.remove_standard_frame = true; |
137 params.delegate = view_; | 149 params.delegate = view_; |
138 params.bounds = bounds; | 150 params.bounds = bounds; |
139 params.parent = ash::Shell::GetContainer( | 151 params.parent = parent; |
140 root_window, ash::kShellWindowId_SettingBubbleContainer); | |
141 views::Widget* widget = new views::Widget; | 152 views::Widget* widget = new views::Widget; |
142 widget->Init(params); | 153 widget->Init(params); |
143 widget->SetContentsView(view_); | 154 widget->SetContentsView(view_); |
144 gfx::NativeView native_view = widget->GetNativeView(); | 155 gfx::NativeView native_view = widget->GetNativeView(); |
145 native_view->SetName("KioskExternalUpdateNotification"); | 156 native_view->SetName("KioskExternalUpdateNotification"); |
146 widget->Show(); | 157 widget->Show(); |
147 } | 158 } |
148 | 159 |
149 void KioskExternalUpdateNotification::Dismiss() { | 160 void KioskExternalUpdateNotification::Dismiss() { |
150 if (view_) { | 161 if (view_) { |
151 KioskExternalUpdateNotificationView* view = view_; | 162 KioskExternalUpdateNotificationView* view = view_; |
152 view_ = NULL; | 163 view_ = NULL; |
153 view->CloseByOwner(); | 164 view->CloseByOwner(); |
154 } | 165 } |
155 } | 166 } |
156 | 167 |
157 } // namespace chromeos | 168 } // namespace chromeos |
OLD | NEW |