OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Draws the view for the balloons. | 5 // Draws the view for the balloons. |
6 | 6 |
7 #include "chrome/browser/chromeos/notifications/notification_panel.h" | 7 #include "chrome/browser/chromeos/notifications/notification_panel.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" | 11 #include "chrome/browser/chromeos/notifications/balloon_collection_impl.h" |
12 #include "chrome/browser/chromeos/notifications/balloon_view.h" | 12 #include "chrome/browser/chromeos/notifications/balloon_view.h" |
| 13 #include "chrome/common/chrome_notification_types.h" |
13 #include "content/common/notification_details.h" | 14 #include "content/common/notification_details.h" |
14 #include "content/common/notification_source.h" | 15 #include "content/common/notification_source.h" |
15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
16 #include "third_party/cros/chromeos_wm_ipc_enums.h" | 17 #include "third_party/cros/chromeos_wm_ipc_enums.h" |
17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
20 #include "views/background.h" | 21 #include "views/background.h" |
21 #include "views/controls/native/native_view_host.h" | 22 #include "views/controls/native/native_view_host.h" |
22 #include "views/controls/scroll_view.h" | 23 #include "views/controls/scroll_view.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 // so that window_contents does not get deleted when detached. | 460 // so that window_contents does not get deleted when detached. |
460 g_object_ref(viewport_widget->GetNativeView()); | 461 g_object_ref(viewport_widget->GetNativeView()); |
461 native->Attach(viewport_widget->GetNativeView()); | 462 native->Attach(viewport_widget->GetNativeView()); |
462 | 463 |
463 UnregisterNotification(); | 464 UnregisterNotification(); |
464 panel_controller_.reset( | 465 panel_controller_.reset( |
465 new PanelController(this, GTK_WINDOW(panel_widget_->GetNativeView()))); | 466 new PanelController(this, GTK_WINDOW(panel_widget_->GetNativeView()))); |
466 panel_controller_->Init(false /* don't focus when opened */, | 467 panel_controller_->Init(false /* don't focus when opened */, |
467 gfx::Rect(0, 0, kBalloonMinWidth, 1), 0, | 468 gfx::Rect(0, 0, kBalloonMinWidth, 1), 0, |
468 WM_IPC_PANEL_USER_RESIZE_VERTICALLY); | 469 WM_IPC_PANEL_USER_RESIZE_VERTICALLY); |
469 registrar_.Add(this, NotificationType::PANEL_STATE_CHANGED, | 470 registrar_.Add(this, chrome::NOTIFICATION_PANEL_STATE_CHANGED, |
470 Source<PanelController>(panel_controller_.get())); | 471 Source<PanelController>(panel_controller_.get())); |
471 } | 472 } |
472 panel_widget_->Show(); | 473 panel_widget_->Show(); |
473 } | 474 } |
474 | 475 |
475 void NotificationPanel::Hide() { | 476 void NotificationPanel::Hide() { |
476 balloon_container_->DismissAllNonSticky(); | 477 balloon_container_->DismissAllNonSticky(); |
477 if (panel_widget_) { | 478 if (panel_widget_) { |
478 container_host_->GetRootView()->RemoveChildView(balloon_container_.get()); | 479 container_host_->GetRootView()->RemoveChildView(balloon_container_.get()); |
479 | 480 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 610 } |
610 | 611 |
611 void NotificationPanel::ActivatePanel() { | 612 void NotificationPanel::ActivatePanel() { |
612 if (active_) | 613 if (active_) |
613 active_->Activated(); | 614 active_->Activated(); |
614 } | 615 } |
615 | 616 |
616 //////////////////////////////////////////////////////////////////////////////// | 617 //////////////////////////////////////////////////////////////////////////////// |
617 // NotificationObserver overrides. | 618 // NotificationObserver overrides. |
618 | 619 |
619 void NotificationPanel::Observe(NotificationType type, | 620 void NotificationPanel::Observe(int type, |
620 const NotificationSource& source, | 621 const NotificationSource& source, |
621 const NotificationDetails& details) { | 622 const NotificationDetails& details) { |
622 DCHECK(type == NotificationType::PANEL_STATE_CHANGED); | 623 DCHECK(type == chrome::NOTIFICATION_PANEL_STATE_CHANGED); |
623 PanelController::State* state = | 624 PanelController::State* state = |
624 reinterpret_cast<PanelController::State*>(details.map_key()); | 625 reinterpret_cast<PanelController::State*>(details.map_key()); |
625 switch (*state) { | 626 switch (*state) { |
626 case PanelController::EXPANDED: | 627 case PanelController::EXPANDED: |
627 // Geting expanded in STICKY_AND_NEW or in KEEP_SIZE state means | 628 // Geting expanded in STICKY_AND_NEW or in KEEP_SIZE state means |
628 // that a new notification is added, so just leave the | 629 // that a new notification is added, so just leave the |
629 // state. Otherwise, expand to full. | 630 // state. Otherwise, expand to full. |
630 if (state_ != STICKY_AND_NEW && state_ != KEEP_SIZE) | 631 if (state_ != STICKY_AND_NEW && state_ != KEEP_SIZE) |
631 SET_STATE(FULL); | 632 SET_STATE(FULL); |
632 // When the panel is to be expanded, we either show all, or | 633 // When the panel is to be expanded, we either show all, or |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 | 681 |
681 scroll_view_.reset(new views::ScrollView()); | 682 scroll_view_.reset(new views::ScrollView()); |
682 scroll_view_->set_focusable(true); | 683 scroll_view_->set_focusable(true); |
683 scroll_view_->set_parent_owned(false); | 684 scroll_view_->set_parent_owned(false); |
684 scroll_view_->set_background( | 685 scroll_view_->set_background( |
685 views::Background::CreateSolidBackground(SK_ColorWHITE)); | 686 views::Background::CreateSolidBackground(SK_ColorWHITE)); |
686 } | 687 } |
687 | 688 |
688 void NotificationPanel::UnregisterNotification() { | 689 void NotificationPanel::UnregisterNotification() { |
689 if (panel_controller_.get()) | 690 if (panel_controller_.get()) |
690 registrar_.Remove(this, NotificationType::PANEL_STATE_CHANGED, | 691 registrar_.Remove(this, chrome::NOTIFICATION_PANEL_STATE_CHANGED, |
691 Source<PanelController>(panel_controller_.get())); | 692 Source<PanelController>(panel_controller_.get())); |
692 } | 693 } |
693 | 694 |
694 void NotificationPanel::ScrollBalloonToVisible(Balloon* balloon) { | 695 void NotificationPanel::ScrollBalloonToVisible(Balloon* balloon) { |
695 BalloonViewImpl* view = GetBalloonViewOf(balloon); | 696 BalloonViewImpl* view = GetBalloonViewOf(balloon); |
696 if (!view->closed()) { | 697 if (!view->closed()) { |
697 // We can't use View::ScrollRectToVisible because the viewport is not | 698 // We can't use View::ScrollRectToVisible because the viewport is not |
698 // ancestor of the BalloonViewImpl. | 699 // ancestor of the BalloonViewImpl. |
699 // Use Widget's coordinate which is same as viewport's coordinates. | 700 // Use Widget's coordinate which is same as viewport's coordinates. |
700 gfx::Point p(0, 0); | 701 gfx::Point p(0, 0); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 &origin); | 867 &origin); |
867 return rect.Contains(gfx::Rect(origin, view->size())); | 868 return rect.Contains(gfx::Rect(origin, view->size())); |
868 } | 869 } |
869 | 870 |
870 | 871 |
871 bool NotificationPanelTester::IsActive(const BalloonViewImpl* view) const { | 872 bool NotificationPanelTester::IsActive(const BalloonViewImpl* view) const { |
872 return panel_->active_ == view; | 873 return panel_->active_ == view; |
873 } | 874 } |
874 | 875 |
875 } // namespace chromeos | 876 } // namespace chromeos |
OLD | NEW |