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

Side by Side Diff: ash/system/tray/system_tray.cc

Issue 10332152: Add TraySms for SMS messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_item.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell/panel_window.h" 8 #include "ash/shell/panel_window.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/system/audio/tray_volume.h" 10 #include "ash/system/audio/tray_volume.h"
11 #include "ash/system/bluetooth/tray_bluetooth.h" 11 #include "ash/system/bluetooth/tray_bluetooth.h"
12 #include "ash/system/brightness/tray_brightness.h" 12 #include "ash/system/brightness/tray_brightness.h"
13 #include "ash/system/date/tray_date.h" 13 #include "ash/system/date/tray_date.h"
14 #include "ash/system/drive/tray_drive.h" 14 #include "ash/system/drive/tray_drive.h"
15 #include "ash/system/ime/tray_ime.h" 15 #include "ash/system/ime/tray_ime.h"
16 #include "ash/system/network/tray_network.h" 16 #include "ash/system/network/tray_network.h"
17 #include "ash/system/network/tray_sms.h"
17 #include "ash/system/power/power_status_observer.h" 18 #include "ash/system/power/power_status_observer.h"
18 #include "ash/system/power/power_supply_status.h" 19 #include "ash/system/power/power_supply_status.h"
19 #include "ash/system/power/tray_power.h" 20 #include "ash/system/power/tray_power.h"
20 #include "ash/system/settings/tray_settings.h" 21 #include "ash/system/settings/tray_settings.h"
21 #include "ash/system/tray/system_tray_bubble.h" 22 #include "ash/system/tray/system_tray_bubble.h"
22 #include "ash/system/tray/system_tray_delegate.h" 23 #include "ash/system/tray/system_tray_delegate.h"
23 #include "ash/system/tray/system_tray_item.h" 24 #include "ash/system/tray/system_tray_item.h"
24 #include "ash/system/tray/system_tray_widget_delegate.h" 25 #include "ash/system/tray/system_tray_widget_delegate.h"
25 #include "ash/system/tray/tray_constants.h" 26 #include "ash/system/tray/tray_constants.h"
26 #include "ash/system/tray_accessibility.h" 27 #include "ash/system/tray_accessibility.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 166 }
166 } 167 }
167 168
168 void SystemTray::CreateItems() { 169 void SystemTray::CreateItems() {
169 internal::TrayVolume* tray_volume = new internal::TrayVolume(); 170 internal::TrayVolume* tray_volume = new internal::TrayVolume();
170 internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth(); 171 internal::TrayBluetooth* tray_bluetooth = new internal::TrayBluetooth();
171 internal::TrayBrightness* tray_brightness = new internal::TrayBrightness(); 172 internal::TrayBrightness* tray_brightness = new internal::TrayBrightness();
172 internal::TrayDate* tray_date = new internal::TrayDate(); 173 internal::TrayDate* tray_date = new internal::TrayDate();
173 internal::TrayPower* tray_power = new internal::TrayPower(); 174 internal::TrayPower* tray_power = new internal::TrayPower();
174 internal::TrayNetwork* tray_network = new internal::TrayNetwork; 175 internal::TrayNetwork* tray_network = new internal::TrayNetwork;
176 internal::TraySms* tray_sms = new internal::TraySms();
175 internal::TrayUser* tray_user = new internal::TrayUser; 177 internal::TrayUser* tray_user = new internal::TrayUser;
176 internal::TrayAccessibility* tray_accessibility = 178 internal::TrayAccessibility* tray_accessibility =
177 new internal::TrayAccessibility; 179 new internal::TrayAccessibility;
178 internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; 180 internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock;
179 internal::TrayDrive* tray_drive = new internal::TrayDrive; 181 internal::TrayDrive* tray_drive = new internal::TrayDrive;
180 internal::TrayIME* tray_ime = new internal::TrayIME; 182 internal::TrayIME* tray_ime = new internal::TrayIME;
181 internal::TrayUpdate* tray_update = new internal::TrayUpdate; 183 internal::TrayUpdate* tray_update = new internal::TrayUpdate;
182 184
183 accessibility_observer_ = tray_accessibility; 185 accessibility_observer_ = tray_accessibility;
184 audio_observer_ = tray_volume; 186 audio_observer_ = tray_volume;
185 bluetooth_observer_ = tray_bluetooth; 187 bluetooth_observer_ = tray_bluetooth;
186 brightness_observer_ = tray_brightness; 188 brightness_observer_ = tray_brightness;
187 caps_lock_observer_ = tray_caps_lock; 189 caps_lock_observer_ = tray_caps_lock;
188 clock_observer_ = tray_date; 190 clock_observer_ = tray_date;
189 drive_observer_ = tray_drive; 191 drive_observer_ = tray_drive;
190 ime_observer_ = tray_ime; 192 ime_observer_ = tray_ime;
191 network_observer_ = tray_network; 193 network_observer_ = tray_network;
192 power_status_observer_ = tray_power; 194 power_status_observer_ = tray_power;
193 update_observer_ = tray_update; 195 update_observer_ = tray_update;
194 user_observer_ = tray_user; 196 user_observer_ = tray_user;
195 197
196 AddTrayItem(tray_user); 198 AddTrayItem(tray_user);
197 AddTrayItem(tray_power); 199 AddTrayItem(tray_power);
198 AddTrayItem(tray_network); 200 AddTrayItem(tray_network);
199 AddTrayItem(tray_bluetooth); 201 AddTrayItem(tray_bluetooth);
202 AddTrayItem(tray_sms);
200 AddTrayItem(tray_drive); 203 AddTrayItem(tray_drive);
201 AddTrayItem(tray_ime); 204 AddTrayItem(tray_ime);
202 AddTrayItem(tray_volume); 205 AddTrayItem(tray_volume);
203 AddTrayItem(tray_brightness); 206 AddTrayItem(tray_brightness);
204 AddTrayItem(tray_update); 207 AddTrayItem(tray_update);
205 AddTrayItem(tray_accessibility); 208 AddTrayItem(tray_accessibility);
206 AddTrayItem(tray_caps_lock); 209 AddTrayItem(tray_caps_lock);
207 AddTrayItem(new internal::TraySettings()); 210 AddTrayItem(new internal::TraySettings());
208 AddTrayItem(tray_date); 211 AddTrayItem(tray_date);
209 SetVisible(ash::Shell::GetInstance()->tray_delegate()-> 212 SetVisible(ash::Shell::GetInstance()->tray_delegate()->
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 259
257 void SystemTray::ShowDetailedView(SystemTrayItem* item, 260 void SystemTray::ShowDetailedView(SystemTrayItem* item,
258 int close_delay, 261 int close_delay,
259 bool activate) { 262 bool activate) {
260 std::vector<SystemTrayItem*> items; 263 std::vector<SystemTrayItem*> items;
261 items.push_back(item); 264 items.push_back(item);
262 ShowItems(items, true, activate); 265 ShowItems(items, true, activate);
263 bubble_->StartAutoCloseTimer(close_delay); 266 bubble_->StartAutoCloseTimer(close_delay);
264 } 267 }
265 268
269 void SystemTray::SetDetailedViewCloseDelay(int close_delay) {
270 if (bubble_.get() &&
271 bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_DETAILED)
272 bubble_->StartAutoCloseTimer(close_delay);
273 }
stevenjb 2012/05/15 02:57:16 Moved from below.
274
275 void SystemTray::HideDetailedView(SystemTrayItem* item) {
276 if (item == detailed_item_) {
277 bubble_.reset();
278 UpdateNotificationBubble();
279 }
280 }
281
266 void SystemTray::ShowNotificationView(SystemTrayItem* item) { 282 void SystemTray::ShowNotificationView(SystemTrayItem* item) {
267 if (std::find(notification_items_.begin(), notification_items_.end(), item) 283 if (std::find(notification_items_.begin(), notification_items_.end(), item)
268 != notification_items_.end()) 284 != notification_items_.end())
269 return; 285 return;
270 notification_items_.push_back(item); 286 notification_items_.push_back(item);
271 UpdateNotificationBubble(); 287 UpdateNotificationBubble();
272 } 288 }
273 289
274 void SystemTray::HideNotificationView(SystemTrayItem* item) { 290 void SystemTray::HideNotificationView(SystemTrayItem* item) {
275 std::vector<SystemTrayItem*>::iterator found_iter = 291 std::vector<SystemTrayItem*>::iterator found_iter =
276 std::find(notification_items_.begin(), notification_items_.end(), item); 292 std::find(notification_items_.begin(), notification_items_.end(), item);
277 if (found_iter == notification_items_.end()) 293 if (found_iter == notification_items_.end())
278 return; 294 return;
279 notification_items_.erase(found_iter); 295 notification_items_.erase(found_iter);
280 UpdateNotificationBubble(); 296 // Only update the notification bubble if visible (i.e. don't create one).
281 } 297 if (notification_bubble_.get())
282 298 UpdateNotificationBubble();
283 void SystemTray::SetDetailedViewCloseDelay(int close_delay) {
284 if (bubble_.get() &&
285 bubble_->bubble_type() == SystemTrayBubble::BUBBLE_TYPE_DETAILED)
286 bubble_->StartAutoCloseTimer(close_delay);
287 } 299 }
288 300
289 void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) { 301 void SystemTray::UpdateAfterLoginStatusChange(user::LoginStatus login_status) {
290 bubble_.reset(); 302 bubble_.reset();
291 303
292 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); 304 for (std::vector<SystemTrayItem*>::iterator it = items_.begin();
293 it != items_.end(); 305 it != items_.end();
294 ++it) { 306 ++it) {
295 (*it)->UpdateAfterLoginStatusChange(login_status); 307 (*it)->UpdateAfterLoginStatusChange(login_status);
296 } 308 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 } 347 }
336 348
337 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items, 349 void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
338 bool detailed, 350 bool detailed,
339 bool can_activate) { 351 bool can_activate) {
340 // Destroy any existing bubble and create a new one. 352 // Destroy any existing bubble and create a new one.
341 SystemTrayBubble::BubbleType bubble_type = detailed ? 353 SystemTrayBubble::BubbleType bubble_type = detailed ?
342 SystemTrayBubble::BUBBLE_TYPE_DETAILED : 354 SystemTrayBubble::BUBBLE_TYPE_DETAILED :
343 SystemTrayBubble::BUBBLE_TYPE_DEFAULT; 355 SystemTrayBubble::BUBBLE_TYPE_DEFAULT;
344 bubble_.reset(new SystemTrayBubble(this, items, bubble_type)); 356 bubble_.reset(new SystemTrayBubble(this, items, bubble_type));
357
358 if (detailed && items.size() > 0)
359 detailed_item_ = items[0];
360 else
361 detailed_item_ = NULL;
362
363 // Destroy the notification bubble here so that it doesn't get rebuilt
364 // while we add items to the main bubble_ (e.g. in HideNotificationView).
365 notification_bubble_.reset();
366
345 ash::SystemTrayDelegate* delegate = 367 ash::SystemTrayDelegate* delegate =
346 ash::Shell::GetInstance()->tray_delegate(); 368 ash::Shell::GetInstance()->tray_delegate();
347 views::View* anchor = tray_container_; 369 views::View* anchor = tray_container_;
348 bubble_->InitView(anchor, SystemTrayBubble::ANCHOR_TYPE_TRAY, 370 bubble_->InitView(anchor, SystemTrayBubble::ANCHOR_TYPE_TRAY,
349 can_activate, delegate->GetUserLoginStatus()); 371 can_activate, delegate->GetUserLoginStatus());
350 // If we have focus the shelf should be visible and we need to continue 372 // If we have focus the shelf should be visible and we need to continue
351 // showing the shelf when the popup is shown. 373 // showing the shelf when the popup is shown.
352 if (GetWidget()->IsActive()) 374 if (GetWidget()->IsActive())
353 should_show_launcher_ = true; 375 should_show_launcher_ = true;
354 UpdateNotificationBubble(); // State changed, re-create notifications. 376 UpdateNotificationBubble(); // State changed, re-create notifications.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 canvas->DrawFocusRect(tray_container_->bounds()); 457 canvas->DrawFocusRect(tray_container_->bounds());
436 } 458 }
437 459
438 void SystemTray::UpdateBackground(int alpha) { 460 void SystemTray::UpdateBackground(int alpha) {
439 background_->set_alpha(hide_background_animator_.alpha() + 461 background_->set_alpha(hide_background_animator_.alpha() +
440 hover_background_animator_.alpha()); 462 hover_background_animator_.alpha());
441 SchedulePaint(); 463 SchedulePaint();
442 } 464 }
443 465
444 } // namespace ash 466 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698