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/system/status_area_widget.h" | 5 #include "ash/system/status_area_widget.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shelf/shelf_layout_manager.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
9 #include "ash/shelf/shelf_widget.h" | 9 #include "ash/shelf/shelf_widget.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/shell_delegate.h" | 11 #include "ash/shell_delegate.h" |
12 #include "ash/shell_window_ids.h" | 12 #include "ash/shell_window_ids.h" |
13 #include "ash/system/bluetooth/bluetooth_observer.h" | 13 #include "ash/system/bluetooth/bluetooth_observer.h" |
14 #include "ash/system/logout_button/logout_button_tray.h" | 14 #include "ash/system/logout_button/logout_button_tray.h" |
15 #include "ash/system/status_area_widget_delegate.h" | 15 #include "ash/system/status_area_widget_delegate.h" |
16 #include "ash/system/tray/system_tray.h" | 16 #include "ash/system/tray/system_tray.h" |
17 #include "ash/system/tray/system_tray_delegate.h" | 17 #include "ash/system/tray/system_tray_delegate.h" |
| 18 #include "ash/system/virtual_keyboard/virtual_keyboard_tray.h" |
18 #include "ash/system/web_notification/web_notification_tray.h" | 19 #include "ash/system/web_notification/web_notification_tray.h" |
19 #include "ash/wm/window_properties.h" | 20 #include "ash/wm/window_properties.h" |
20 #include "base/i18n/time_formatting.h" | 21 #include "base/i18n/time_formatting.h" |
21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
22 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
23 | 24 |
24 namespace ash { | 25 namespace ash { |
25 | 26 |
26 namespace internal { | 27 namespace internal { |
27 | 28 |
28 const char StatusAreaWidget::kNativeViewName[] = "StatusAreaWidget"; | 29 const char StatusAreaWidget::kNativeViewName[] = "StatusAreaWidget"; |
29 | 30 |
30 StatusAreaWidget::StatusAreaWidget(aura::Window* status_container) | 31 StatusAreaWidget::StatusAreaWidget(aura::Window* status_container) |
31 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), | 32 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), |
32 system_tray_(NULL), | 33 system_tray_(NULL), |
33 web_notification_tray_(NULL), | 34 web_notification_tray_(NULL), |
34 logout_button_tray_(NULL), | 35 logout_button_tray_(NULL), |
| 36 virtual_keyboard_tray_(NULL), |
35 login_status_(user::LOGGED_IN_NONE) { | 37 login_status_(user::LOGGED_IN_NONE) { |
36 views::Widget::InitParams params( | 38 views::Widget::InitParams params( |
37 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 39 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
38 params.delegate = status_area_widget_delegate_; | 40 params.delegate = status_area_widget_delegate_; |
39 params.parent = status_container; | 41 params.parent = status_container; |
40 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 42 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
41 Init(params); | 43 Init(params); |
42 set_focus_on_creation(false); | 44 set_focus_on_creation(false); |
43 SetContentsView(status_area_widget_delegate_); | 45 SetContentsView(status_area_widget_delegate_); |
44 GetNativeView()->SetName(kNativeViewName); | 46 GetNativeView()->SetName(kNativeViewName); |
45 } | 47 } |
46 | 48 |
47 StatusAreaWidget::~StatusAreaWidget() { | 49 StatusAreaWidget::~StatusAreaWidget() { |
48 } | 50 } |
49 | 51 |
50 void StatusAreaWidget::CreateTrayViews() { | 52 void StatusAreaWidget::CreateTrayViews() { |
51 AddSystemTray(); | 53 AddSystemTray(); |
52 AddWebNotificationTray(); | 54 AddWebNotificationTray(); |
53 AddLogoutButtonTray(); | 55 AddLogoutButtonTray(); |
| 56 AddVirtualKeyboardTray(); |
54 SystemTrayDelegate* delegate = | 57 SystemTrayDelegate* delegate = |
55 ash::Shell::GetInstance()->system_tray_delegate(); | 58 ash::Shell::GetInstance()->system_tray_delegate(); |
56 DCHECK(delegate); | 59 DCHECK(delegate); |
57 // Initialize after all trays have been created. | 60 // Initialize after all trays have been created. |
58 if (system_tray_) | 61 if (system_tray_) |
59 system_tray_->InitializeTrayItems(delegate); | 62 system_tray_->InitializeTrayItems(delegate); |
60 if (web_notification_tray_) | 63 if (web_notification_tray_) |
61 web_notification_tray_->Initialize(); | 64 web_notification_tray_->Initialize(); |
62 if (logout_button_tray_) | 65 if (logout_button_tray_) |
63 logout_button_tray_->Initialize(); | 66 logout_button_tray_->Initialize(); |
| 67 if (virtual_keyboard_tray_) |
| 68 virtual_keyboard_tray_->Initialize(); |
64 UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus()); | 69 UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus()); |
65 } | 70 } |
66 | 71 |
67 void StatusAreaWidget::Shutdown() { | 72 void StatusAreaWidget::Shutdown() { |
68 // Destroy the trays early, causing them to be removed from the view | 73 // Destroy the trays early, causing them to be removed from the view |
69 // hierarchy. Do not used scoped pointers since we don't want to destroy them | 74 // hierarchy. Do not used scoped pointers since we don't want to destroy them |
70 // in the destructor if Shutdown() is not called (e.g. in tests). | 75 // in the destructor if Shutdown() is not called (e.g. in tests). |
71 delete logout_button_tray_; | 76 delete logout_button_tray_; |
72 logout_button_tray_ = NULL; | 77 logout_button_tray_ = NULL; |
73 delete web_notification_tray_; | 78 delete web_notification_tray_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 void StatusAreaWidget::AddWebNotificationTray() { | 117 void StatusAreaWidget::AddWebNotificationTray() { |
113 web_notification_tray_ = new WebNotificationTray(this); | 118 web_notification_tray_ = new WebNotificationTray(this); |
114 status_area_widget_delegate_->AddTray(web_notification_tray_); | 119 status_area_widget_delegate_->AddTray(web_notification_tray_); |
115 } | 120 } |
116 | 121 |
117 void StatusAreaWidget::AddLogoutButtonTray() { | 122 void StatusAreaWidget::AddLogoutButtonTray() { |
118 logout_button_tray_ = new LogoutButtonTray(this); | 123 logout_button_tray_ = new LogoutButtonTray(this); |
119 status_area_widget_delegate_->AddTray(logout_button_tray_); | 124 status_area_widget_delegate_->AddTray(logout_button_tray_); |
120 } | 125 } |
121 | 126 |
| 127 void StatusAreaWidget::AddVirtualKeyboardTray() { |
| 128 virtual_keyboard_tray_ = new VirtualKeyboardTray(this); |
| 129 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_); |
| 130 } |
| 131 |
122 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { | 132 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { |
123 status_area_widget_delegate_->set_alignment(alignment); | 133 status_area_widget_delegate_->set_alignment(alignment); |
124 if (system_tray_) | 134 if (system_tray_) |
125 system_tray_->SetShelfAlignment(alignment); | 135 system_tray_->SetShelfAlignment(alignment); |
126 if (web_notification_tray_) | 136 if (web_notification_tray_) |
127 web_notification_tray_->SetShelfAlignment(alignment); | 137 web_notification_tray_->SetShelfAlignment(alignment); |
128 if (logout_button_tray_) | 138 if (logout_button_tray_) |
129 logout_button_tray_->SetShelfAlignment(alignment); | 139 logout_button_tray_->SetShelfAlignment(alignment); |
| 140 if (virtual_keyboard_tray_) |
| 141 virtual_keyboard_tray_->SetShelfAlignment(alignment); |
130 status_area_widget_delegate_->UpdateLayout(); | 142 status_area_widget_delegate_->UpdateLayout(); |
131 } | 143 } |
132 | 144 |
133 void StatusAreaWidget::SetHideSystemNotifications(bool hide) { | 145 void StatusAreaWidget::SetHideSystemNotifications(bool hide) { |
134 if (system_tray_) | 146 if (system_tray_) |
135 system_tray_->SetHideNotifications(hide); | 147 system_tray_->SetHideNotifications(hide); |
136 } | 148 } |
137 | 149 |
138 void StatusAreaWidget::UpdateAfterLoginStatusChange( | 150 void StatusAreaWidget::UpdateAfterLoginStatusChange( |
139 user::LoginStatus login_status) { | 151 user::LoginStatus login_status) { |
140 if (login_status_ == login_status) | 152 if (login_status_ == login_status) |
141 return; | 153 return; |
142 login_status_ = login_status; | 154 login_status_ = login_status; |
143 if (system_tray_) | 155 if (system_tray_) |
144 system_tray_->UpdateAfterLoginStatusChange(login_status); | 156 system_tray_->UpdateAfterLoginStatusChange(login_status); |
145 if (web_notification_tray_) | 157 if (web_notification_tray_) |
146 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); | 158 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); |
147 if (logout_button_tray_) | 159 if (logout_button_tray_) |
148 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); | 160 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); |
149 } | 161 } |
150 | 162 |
151 } // namespace internal | 163 } // namespace internal |
152 } // namespace ash | 164 } // namespace ash |
OLD | NEW |