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

Side by Side Diff: chrome/browser/chromeos/notifications/notification_panel.cc

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
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
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 // so that window_contents does not get deleted when detached. 459 // so that window_contents does not get deleted when detached.
460 g_object_ref(viewport_widget->GetNativeView()); 460 g_object_ref(viewport_widget->GetNativeView());
461 native->Attach(viewport_widget->GetNativeView()); 461 native->Attach(viewport_widget->GetNativeView());
462 462
463 UnregisterNotification(); 463 UnregisterNotification();
464 panel_controller_.reset( 464 panel_controller_.reset(
465 new PanelController(this, GTK_WINDOW(panel_widget_->GetNativeView()))); 465 new PanelController(this, GTK_WINDOW(panel_widget_->GetNativeView())));
466 panel_controller_->Init(false /* don't focus when opened */, 466 panel_controller_->Init(false /* don't focus when opened */,
467 gfx::Rect(0, 0, kBalloonMinWidth, 1), 0, 467 gfx::Rect(0, 0, kBalloonMinWidth, 1), 0,
468 WM_IPC_PANEL_USER_RESIZE_VERTICALLY); 468 WM_IPC_PANEL_USER_RESIZE_VERTICALLY);
469 registrar_.Add(this, NotificationType::PANEL_STATE_CHANGED, 469 registrar_.Add(this, chrome::PANEL_STATE_CHANGED,
470 Source<PanelController>(panel_controller_.get())); 470 Source<PanelController>(panel_controller_.get()));
471 } 471 }
472 panel_widget_->Show(); 472 panel_widget_->Show();
473 } 473 }
474 474
475 void NotificationPanel::Hide() { 475 void NotificationPanel::Hide() {
476 balloon_container_->DismissAllNonSticky(); 476 balloon_container_->DismissAllNonSticky();
477 if (panel_widget_) { 477 if (panel_widget_) {
478 container_host_->GetRootView()->RemoveChildView(balloon_container_.get()); 478 container_host_->GetRootView()->RemoveChildView(balloon_container_.get());
479 479
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 } 609 }
610 610
611 void NotificationPanel::ActivatePanel() { 611 void NotificationPanel::ActivatePanel() {
612 if (active_) 612 if (active_)
613 active_->Activated(); 613 active_->Activated();
614 } 614 }
615 615
616 //////////////////////////////////////////////////////////////////////////////// 616 ////////////////////////////////////////////////////////////////////////////////
617 // NotificationObserver overrides. 617 // NotificationObserver overrides.
618 618
619 void NotificationPanel::Observe(NotificationType type, 619 void NotificationPanel::Observe(int type,
620 const NotificationSource& source, 620 const NotificationSource& source,
621 const NotificationDetails& details) { 621 const NotificationDetails& details) {
622 DCHECK(type == NotificationType::PANEL_STATE_CHANGED); 622 DCHECK(type == chrome::PANEL_STATE_CHANGED);
623 PanelController::State* state = 623 PanelController::State* state =
624 reinterpret_cast<PanelController::State*>(details.map_key()); 624 reinterpret_cast<PanelController::State*>(details.map_key());
625 switch (*state) { 625 switch (*state) {
626 case PanelController::EXPANDED: 626 case PanelController::EXPANDED:
627 // Geting expanded in STICKY_AND_NEW or in KEEP_SIZE state means 627 // Geting expanded in STICKY_AND_NEW or in KEEP_SIZE state means
628 // that a new notification is added, so just leave the 628 // that a new notification is added, so just leave the
629 // state. Otherwise, expand to full. 629 // state. Otherwise, expand to full.
630 if (state_ != STICKY_AND_NEW && state_ != KEEP_SIZE) 630 if (state_ != STICKY_AND_NEW && state_ != KEEP_SIZE)
631 SET_STATE(FULL); 631 SET_STATE(FULL);
632 // When the panel is to be expanded, we either show all, or 632 // When the panel is to be expanded, we either show all, or
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 680
681 scroll_view_.reset(new views::ScrollView()); 681 scroll_view_.reset(new views::ScrollView());
682 scroll_view_->set_focusable(true); 682 scroll_view_->set_focusable(true);
683 scroll_view_->set_parent_owned(false); 683 scroll_view_->set_parent_owned(false);
684 scroll_view_->set_background( 684 scroll_view_->set_background(
685 views::Background::CreateSolidBackground(SK_ColorWHITE)); 685 views::Background::CreateSolidBackground(SK_ColorWHITE));
686 } 686 }
687 687
688 void NotificationPanel::UnregisterNotification() { 688 void NotificationPanel::UnregisterNotification() {
689 if (panel_controller_.get()) 689 if (panel_controller_.get())
690 registrar_.Remove(this, NotificationType::PANEL_STATE_CHANGED, 690 registrar_.Remove(this, chrome::PANEL_STATE_CHANGED,
691 Source<PanelController>(panel_controller_.get())); 691 Source<PanelController>(panel_controller_.get()));
692 } 692 }
693 693
694 void NotificationPanel::ScrollBalloonToVisible(Balloon* balloon) { 694 void NotificationPanel::ScrollBalloonToVisible(Balloon* balloon) {
695 BalloonViewImpl* view = GetBalloonViewOf(balloon); 695 BalloonViewImpl* view = GetBalloonViewOf(balloon);
696 if (!view->closed()) { 696 if (!view->closed()) {
697 // We can't use View::ScrollRectToVisible because the viewport is not 697 // We can't use View::ScrollRectToVisible because the viewport is not
698 // ancestor of the BalloonViewImpl. 698 // ancestor of the BalloonViewImpl.
699 // Use Widget's coordinate which is same as viewport's coordinates. 699 // Use Widget's coordinate which is same as viewport's coordinates.
700 gfx::Point p(0, 0); 700 gfx::Point p(0, 0);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 &origin); 866 &origin);
867 return rect.Contains(gfx::Rect(origin, view->size())); 867 return rect.Contains(gfx::Rect(origin, view->size()));
868 } 868 }
869 869
870 870
871 bool NotificationPanelTester::IsActive(const BalloonViewImpl* view) const { 871 bool NotificationPanelTester::IsActive(const BalloonViewImpl* view) const {
872 return panel_->active_ == view; 872 return panel_->active_ == view;
873 } 873 }
874 874
875 } // namespace chromeos 875 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698