Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: ash/system/status_area_widget.cc

Issue 1996563002: Add ImeMenuTray element. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove kStatusTrayShelfID. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/common/shelf/wm_shelf.h" 7 #include "ash/common/shelf/wm_shelf.h"
8 #include "ash/common/shell_window_ids.h" 8 #include "ash/common/shell_window_ids.h"
9 #include "ash/common/system/tray/system_tray_delegate.h" 9 #include "ash/common/system/tray/system_tray_delegate.h"
10 #include "ash/common/wm_root_window_controller.h" 10 #include "ash/common/wm_root_window_controller.h"
11 #include "ash/common/wm_shell.h" 11 #include "ash/common/wm_shell.h"
12 #include "ash/common/wm_window.h" 12 #include "ash/common/wm_window.h"
13 #include "ash/system/overview/overview_button_tray.h" 13 #include "ash/system/overview/overview_button_tray.h"
14 #include "ash/system/status_area_widget_delegate.h" 14 #include "ash/system/status_area_widget_delegate.h"
15 #include "ash/system/tray/system_tray.h" 15 #include "ash/system/tray/system_tray.h"
16 #include "ash/system/web_notification/web_notification_tray.h" 16 #include "ash/system/web_notification/web_notification_tray.h"
17 #include "ash/wm/window_properties.h" 17 #include "ash/wm/window_properties.h"
18 #include "base/i18n/time_formatting.h" 18 #include "base/i18n/time_formatting.h"
19 19
20 #if defined(OS_CHROMEOS) 20 #if defined(OS_CHROMEOS)
21 #include "ash/system/chromeos/ime_menu/ime_menu_tray.h"
21 #include "ash/system/chromeos/session/logout_button_tray.h" 22 #include "ash/system/chromeos/session/logout_button_tray.h"
22 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" 23 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
23 #endif 24 #endif
24 25
25 namespace ash { 26 namespace ash {
26 27
27 StatusAreaWidget::StatusAreaWidget(WmWindow* status_container, 28 StatusAreaWidget::StatusAreaWidget(WmWindow* status_container,
28 WmShelf* wm_shelf) 29 WmShelf* wm_shelf)
29 : status_area_widget_delegate_(new StatusAreaWidgetDelegate), 30 : status_area_widget_delegate_(new StatusAreaWidgetDelegate),
30 overview_button_tray_(NULL), 31 overview_button_tray_(NULL),
31 system_tray_(NULL), 32 system_tray_(NULL),
32 web_notification_tray_(NULL), 33 web_notification_tray_(NULL),
33 #if defined(OS_CHROMEOS) 34 #if defined(OS_CHROMEOS)
34 logout_button_tray_(NULL), 35 logout_button_tray_(NULL),
35 virtual_keyboard_tray_(NULL), 36 virtual_keyboard_tray_(NULL),
37 ime_menu_tray_(nullptr),
36 #endif 38 #endif
37 login_status_(LoginStatus::NOT_LOGGED_IN), 39 login_status_(LoginStatus::NOT_LOGGED_IN),
38 wm_shelf_(wm_shelf) { 40 wm_shelf_(wm_shelf) {
39 views::Widget::InitParams params( 41 views::Widget::InitParams params(
40 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 42 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
41 params.delegate = status_area_widget_delegate_; 43 params.delegate = status_area_widget_delegate_;
42 params.name = "StatusAreaWidget"; 44 params.name = "StatusAreaWidget";
43 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 45 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
44 status_container->GetRootWindowController() 46 status_container->GetRootWindowController()
45 ->ConfigureWidgetInitParamsForContainer( 47 ->ConfigureWidgetInitParamsForContainer(
46 this, status_container->GetShellWindowId(), &params); 48 this, status_container->GetShellWindowId(), &params);
47 Init(params); 49 Init(params);
48 set_focus_on_creation(false); 50 set_focus_on_creation(false);
49 SetContentsView(status_area_widget_delegate_); 51 SetContentsView(status_area_widget_delegate_);
50 } 52 }
51 53
52 StatusAreaWidget::~StatusAreaWidget() { 54 StatusAreaWidget::~StatusAreaWidget() {
53 } 55 }
54 56
55 void StatusAreaWidget::CreateTrayViews() { 57 void StatusAreaWidget::CreateTrayViews() {
56 AddOverviewButtonTray(); 58 AddOverviewButtonTray();
57 AddSystemTray(); 59 AddSystemTray();
58 AddWebNotificationTray(); 60 AddWebNotificationTray();
59 #if defined(OS_CHROMEOS) 61 #if defined(OS_CHROMEOS)
60 AddLogoutButtonTray(); 62 AddLogoutButtonTray();
61 AddVirtualKeyboardTray(); 63 AddVirtualKeyboardTray();
64 AddImeMenuTray();
62 #endif 65 #endif
63 66
64 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate(); 67 SystemTrayDelegate* delegate = WmShell::Get()->system_tray_delegate();
65 DCHECK(delegate); 68 DCHECK(delegate);
66 // Initialize after all trays have been created. 69 // Initialize after all trays have been created.
67 system_tray_->InitializeTrayItems(delegate); 70 system_tray_->InitializeTrayItems(delegate);
68 web_notification_tray_->Initialize(); 71 web_notification_tray_->Initialize();
69 #if defined(OS_CHROMEOS) 72 #if defined(OS_CHROMEOS)
70 logout_button_tray_->Initialize(); 73 logout_button_tray_->Initialize();
71 virtual_keyboard_tray_->Initialize(); 74 virtual_keyboard_tray_->Initialize();
75 ime_menu_tray_->Initialize();
72 #endif 76 #endif
73 overview_button_tray_->Initialize(); 77 overview_button_tray_->Initialize();
74 SetShelfAlignment(system_tray_->shelf_alignment()); 78 SetShelfAlignment(system_tray_->shelf_alignment());
75 UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus()); 79 UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus());
76 } 80 }
77 81
78 void StatusAreaWidget::Shutdown() { 82 void StatusAreaWidget::Shutdown() {
79 // Destroy the trays early, causing them to be removed from the view 83 // Destroy the trays early, causing them to be removed from the view
80 // hierarchy. Do not used scoped pointers since we don't want to destroy them 84 // hierarchy. Do not used scoped pointers since we don't want to destroy them
81 // in the destructor if Shutdown() is not called (e.g. in tests). 85 // in the destructor if Shutdown() is not called (e.g. in tests).
82 delete web_notification_tray_; 86 delete web_notification_tray_;
83 web_notification_tray_ = NULL; 87 web_notification_tray_ = NULL;
84 delete system_tray_; 88 delete system_tray_;
85 system_tray_ = NULL; 89 system_tray_ = NULL;
86 #if defined(OS_CHROMEOS) 90 #if defined(OS_CHROMEOS)
87 delete virtual_keyboard_tray_; 91 delete virtual_keyboard_tray_;
88 virtual_keyboard_tray_ = NULL; 92 virtual_keyboard_tray_ = NULL;
89 delete logout_button_tray_; 93 delete logout_button_tray_;
90 logout_button_tray_ = NULL; 94 logout_button_tray_ = NULL;
95 delete ime_menu_tray_;
96 ime_menu_tray_ = nullptr;
91 #endif 97 #endif
92 delete overview_button_tray_; 98 delete overview_button_tray_;
93 overview_button_tray_ = NULL; 99 overview_button_tray_ = NULL;
94 } 100 }
95 101
96 bool StatusAreaWidget::ShouldShowShelf() const { 102 bool StatusAreaWidget::ShouldShowShelf() const {
97 if ((system_tray_ && system_tray_->ShouldShowShelf()) || 103 if ((system_tray_ && system_tray_->ShouldShowShelf()) ||
98 (web_notification_tray_ && 104 (web_notification_tray_ &&
99 web_notification_tray_->ShouldBlockShelfAutoHide())) 105 web_notification_tray_->ShouldBlockShelfAutoHide()))
100 return true; 106 return true;
(...skipping 14 matching lines...) Expand all
115 web_notification_tray_->IsMessageCenterBubbleVisible())); 121 web_notification_tray_->IsMessageCenterBubbleVisible()));
116 } 122 }
117 123
118 void StatusAreaWidget::SchedulePaint() { 124 void StatusAreaWidget::SchedulePaint() {
119 status_area_widget_delegate_->SchedulePaint(); 125 status_area_widget_delegate_->SchedulePaint();
120 web_notification_tray_->SchedulePaint(); 126 web_notification_tray_->SchedulePaint();
121 system_tray_->SchedulePaint(); 127 system_tray_->SchedulePaint();
122 #if defined(OS_CHROMEOS) 128 #if defined(OS_CHROMEOS)
123 virtual_keyboard_tray_->SchedulePaint(); 129 virtual_keyboard_tray_->SchedulePaint();
124 logout_button_tray_->SchedulePaint(); 130 logout_button_tray_->SchedulePaint();
131 ime_menu_tray_->SchedulePaint();
125 #endif 132 #endif
126 overview_button_tray_->SchedulePaint(); 133 overview_button_tray_->SchedulePaint();
127 } 134 }
128 135
129 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) { 136 void StatusAreaWidget::OnNativeWidgetActivationChanged(bool active) {
130 Widget::OnNativeWidgetActivationChanged(active); 137 Widget::OnNativeWidgetActivationChanged(active);
131 if (active) 138 if (active)
132 status_area_widget_delegate_->SetPaneFocusAndFocusDefault(); 139 status_area_widget_delegate_->SetPaneFocusAndFocusDefault();
133 } 140 }
134 141
(...skipping 20 matching lines...) Expand all
155 #if defined(OS_CHROMEOS) 162 #if defined(OS_CHROMEOS)
156 void StatusAreaWidget::AddLogoutButtonTray() { 163 void StatusAreaWidget::AddLogoutButtonTray() {
157 logout_button_tray_ = new LogoutButtonTray(this); 164 logout_button_tray_ = new LogoutButtonTray(this);
158 status_area_widget_delegate_->AddTray(logout_button_tray_); 165 status_area_widget_delegate_->AddTray(logout_button_tray_);
159 } 166 }
160 167
161 void StatusAreaWidget::AddVirtualKeyboardTray() { 168 void StatusAreaWidget::AddVirtualKeyboardTray() {
162 virtual_keyboard_tray_ = new VirtualKeyboardTray(this); 169 virtual_keyboard_tray_ = new VirtualKeyboardTray(this);
163 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_); 170 status_area_widget_delegate_->AddTray(virtual_keyboard_tray_);
164 } 171 }
172
173 void StatusAreaWidget::AddImeMenuTray() {
174 ime_menu_tray_ = new ImeMenuTray(this);
175 status_area_widget_delegate_->AddTray(ime_menu_tray_);
176 }
165 #endif 177 #endif
166 178
167 void StatusAreaWidget::AddOverviewButtonTray() { 179 void StatusAreaWidget::AddOverviewButtonTray() {
168 overview_button_tray_ = new OverviewButtonTray(this); 180 overview_button_tray_ = new OverviewButtonTray(this);
169 status_area_widget_delegate_->AddTray(overview_button_tray_); 181 status_area_widget_delegate_->AddTray(overview_button_tray_);
170 } 182 }
171 183
172 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { 184 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
173 status_area_widget_delegate_->set_alignment(alignment); 185 status_area_widget_delegate_->set_alignment(alignment);
174 if (system_tray_) 186 if (system_tray_)
175 system_tray_->SetShelfAlignment(alignment); 187 system_tray_->SetShelfAlignment(alignment);
176 if (web_notification_tray_) 188 if (web_notification_tray_)
177 web_notification_tray_->SetShelfAlignment(alignment); 189 web_notification_tray_->SetShelfAlignment(alignment);
178 #if defined(OS_CHROMEOS) 190 #if defined(OS_CHROMEOS)
179 if (logout_button_tray_) 191 if (logout_button_tray_)
180 logout_button_tray_->SetShelfAlignment(alignment); 192 logout_button_tray_->SetShelfAlignment(alignment);
181 if (virtual_keyboard_tray_) 193 if (virtual_keyboard_tray_)
182 virtual_keyboard_tray_->SetShelfAlignment(alignment); 194 virtual_keyboard_tray_->SetShelfAlignment(alignment);
195 if (ime_menu_tray_)
196 ime_menu_tray_->SetShelfAlignment(alignment);
183 #endif 197 #endif
184 if (overview_button_tray_) 198 if (overview_button_tray_)
185 overview_button_tray_->SetShelfAlignment(alignment); 199 overview_button_tray_->SetShelfAlignment(alignment);
186 status_area_widget_delegate_->UpdateLayout(); 200 status_area_widget_delegate_->UpdateLayout();
187 } 201 }
188 202
189 void StatusAreaWidget::SetHideSystemNotifications(bool hide) { 203 void StatusAreaWidget::SetHideSystemNotifications(bool hide) {
190 if (system_tray_) 204 if (system_tray_)
191 system_tray_->SetHideNotifications(hide); 205 system_tray_->SetHideNotifications(hide);
192 } 206 }
193 207
194 void StatusAreaWidget::UpdateAfterLoginStatusChange(LoginStatus login_status) { 208 void StatusAreaWidget::UpdateAfterLoginStatusChange(LoginStatus login_status) {
195 if (login_status_ == login_status) 209 if (login_status_ == login_status)
196 return; 210 return;
197 login_status_ = login_status; 211 login_status_ = login_status;
198 if (system_tray_) 212 if (system_tray_)
199 system_tray_->UpdateAfterLoginStatusChange(login_status); 213 system_tray_->UpdateAfterLoginStatusChange(login_status);
200 if (web_notification_tray_) 214 if (web_notification_tray_)
201 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 215 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
202 #if defined(OS_CHROMEOS) 216 #if defined(OS_CHROMEOS)
203 if (logout_button_tray_) 217 if (logout_button_tray_)
204 logout_button_tray_->UpdateAfterLoginStatusChange(login_status); 218 logout_button_tray_->UpdateAfterLoginStatusChange(login_status);
205 #endif 219 #endif
206 if (overview_button_tray_) 220 if (overview_button_tray_)
207 overview_button_tray_->UpdateAfterLoginStatusChange(login_status); 221 overview_button_tray_->UpdateAfterLoginStatusChange(login_status);
208 } 222 }
209 223
210 } // namespace ash 224 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698