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

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

Issue 10546125: Add WebNotificationTray to the status area (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 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 | Annotate | Revision Log
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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/shell_window_ids.h" 9 #include "ash/shell_window_ids.h"
10 #include "ash/system/bluetooth/bluetooth_observer.h" 10 #include "ash/system/bluetooth/bluetooth_observer.h"
11 #include "ash/system/network/network_observer.h" 11 #include "ash/system/network/network_observer.h"
12 #include "ash/system/status_area_widget_delegate.h" 12 #include "ash/system/status_area_widget_delegate.h"
13 #include "ash/system/tray/system_tray.h" 13 #include "ash/system/tray/system_tray.h"
14 #include "ash/system/tray/system_tray_delegate.h" 14 #include "ash/system/tray/system_tray_delegate.h"
15 #include "ash/system/web_notification/web_notification_tray.h"
15 #include "base/i18n/time_formatting.h" 16 #include "base/i18n/time_formatting.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 19
19 namespace ash { 20 namespace ash {
20 21
21 namespace { 22 namespace {
22 23
23 class DummySystemTrayDelegate : public SystemTrayDelegate { 24 class DummySystemTrayDelegate : public SystemTrayDelegate {
24 public: 25 public:
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 275
275 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate); 276 DISALLOW_COPY_AND_ASSIGN(DummySystemTrayDelegate);
276 }; 277 };
277 278
278 } // namespace 279 } // namespace
279 280
280 namespace internal { 281 namespace internal {
281 282
282 StatusAreaWidget::StatusAreaWidget() 283 StatusAreaWidget::StatusAreaWidget()
283 : widget_delegate_(new internal::StatusAreaWidgetDelegate), 284 : widget_delegate_(new internal::StatusAreaWidgetDelegate),
284 system_tray_(NULL) { 285 system_tray_(NULL),
286 web_notification_tray_(NULL) {
285 views::Widget::InitParams params( 287 views::Widget::InitParams params(
286 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 288 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
287 params.delegate = widget_delegate_; 289 params.delegate = widget_delegate_;
288 params.parent = Shell::GetContainer( 290 params.parent = Shell::GetContainer(
289 Shell::GetPrimaryRootWindow(), 291 Shell::GetPrimaryRootWindow(),
290 ash::internal::kShellWindowId_StatusContainer); 292 ash::internal::kShellWindowId_StatusContainer);
291 params.transparent = true; 293 params.transparent = true;
292 Init(params); 294 Init(params);
293 set_focus_on_creation(false); 295 set_focus_on_creation(false);
294 SetContentsView(widget_delegate_); 296 SetContentsView(widget_delegate_);
295 GetNativeView()->SetName("StatusAreaWidget"); 297 GetNativeView()->SetName("StatusAreaWidget");
296 } 298 }
297 299
298 StatusAreaWidget::~StatusAreaWidget() { 300 StatusAreaWidget::~StatusAreaWidget() {
299 } 301 }
300 302
301 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) { 303 void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) {
304 AddWebNotificationTray(new WebNotificationTray(this));
302 AddSystemTray(new SystemTray(), shell_delegate); 305 AddSystemTray(new SystemTray(), shell_delegate);
303 } 306 }
304 307
305 void StatusAreaWidget::Shutdown() { 308 void StatusAreaWidget::Shutdown() {
306 // Destroy the trays early, causing them to be removed from the view 309 // Destroy the trays early, causing them to be removed from the view
307 // hierarchy. Do not used scoped pointers since we don't want to destroy them 310 // hierarchy. Do not used scoped pointers since we don't want to destroy them
308 // in the destructor if Shutdown() is not called (e.g. in tests). 311 // in the destructor if Shutdown() is not called (e.g. in tests).
309 delete system_tray_; 312 delete system_tray_;
310 system_tray_ = NULL; 313 system_tray_ = NULL;
314 delete web_notification_tray_;
315 web_notification_tray_ = NULL;
311 } 316 }
312 317
313 void StatusAreaWidget::AddSystemTray(SystemTray* system_tray, 318 void StatusAreaWidget::AddSystemTray(SystemTray* system_tray,
314 ShellDelegate* shell_delegate) { 319 ShellDelegate* shell_delegate) {
315 system_tray_ = system_tray; 320 system_tray_ = system_tray;
316 widget_delegate_->AddTray(system_tray); 321 widget_delegate_->AddTray(system_tray);
317 system_tray_->Initialize(); // Called after added to widget. 322 system_tray_->Initialize(); // Called after added to widget.
318 323
319 if (shell_delegate) { 324 if (shell_delegate) {
320 system_tray_delegate_.reset( 325 system_tray_delegate_.reset(
321 shell_delegate->CreateSystemTrayDelegate(system_tray)); 326 shell_delegate->CreateSystemTrayDelegate(system_tray));
322 } 327 }
323 if (!system_tray_delegate_.get()) 328 if (!system_tray_delegate_.get())
324 system_tray_delegate_.reset(new DummySystemTrayDelegate()); 329 system_tray_delegate_.reset(new DummySystemTrayDelegate());
325 330
326 system_tray->CreateItems(); // Called after delegate is created. 331 system_tray->CreateItems(); // Called after delegate is created.
327 } 332 }
328 333
334 void StatusAreaWidget::AddWebNotificationTray(
335 WebNotificationTray* web_notification_tray) {
336 web_notification_tray_ = web_notification_tray;
337 widget_delegate_->AddTray(web_notification_tray);
338 }
339
329 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { 340 void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
330 widget_delegate_->set_alignment(alignment); 341 widget_delegate_->set_alignment(alignment);
331 widget_delegate_->UpdateLayout(); 342 widget_delegate_->UpdateLayout();
343 if (system_tray_)
344 system_tray_->SetShelfAlignment(alignment);
345 if (web_notification_tray_)
346 web_notification_tray_->SetShelfAlignment(alignment);
347 }
348
349 void StatusAreaWidget::SetPaintsBackground(
350 bool value,
sadrul 2012/06/13 16:37:56 less indentation
stevenjb 2012/06/13 19:05:02 Done.
351 internal::BackgroundAnimator::ChangeType change_type) {
352 if (system_tray_)
353 system_tray_->SetPaintsBackground(value, change_type);
354 if (web_notification_tray_)
355 web_notification_tray_->SetPaintsBackground(value, change_type);
356 }
357
358 void StatusAreaWidget::ShowWebNotificationBubble(UserAction user_action) {
359 // If not triggered by a user action, only show the web notification bubble
360 // if the system tray is not visible.
361 if (user_action == USER_ACTION &&
362 system_tray_ && system_tray_->IsBubbleVisible()) {
363 return;
364 }
365 DCHECK(web_notification_tray_);
366 web_notification_tray_->ShowBubble();
367 // Disable showing system notifications while viewing web notifications.
368 if (system_tray_)
369 system_tray_->SetHideNotifications(true);
sadrul 2012/06/13 16:37:56 Just to clarify: with this change, both the system
stevenjb 2012/06/13 19:05:02 No, only one should be visible at a time, but that
370 }
371
372 void StatusAreaWidget::HideWebNotificationBubble() {
373 DCHECK(web_notification_tray_);
374 web_notification_tray_->HideBubble();
375 // Show any hidden or suppressed system notifications.
376 if (system_tray_)
377 system_tray_->SetHideNotifications(false);
332 } 378 }
333 379
334 } // namespace internal 380 } // namespace internal
335 } // namespace ash 381 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698