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

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

Powered by Google App Engine
This is Rietveld 408576698