| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Draws the view for the balloons. | |
| 6 | |
| 7 #ifndef CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_H_ | |
| 8 #define CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_H_ | |
| 9 #pragma once | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "base/memory/weak_ptr.h" | |
| 15 #include "chrome/browser/notifications/balloon.h" | |
| 16 #include "content/public/browser/notification_observer.h" | |
| 17 #include "content/public/browser/notification_registrar.h" | |
| 18 #include "ui/gfx/path.h" | |
| 19 #include "ui/gfx/point.h" | |
| 20 #include "ui/gfx/rect.h" | |
| 21 #include "ui/gfx/size.h" | |
| 22 #include "ui/views/view.h" | |
| 23 | |
| 24 namespace views { | |
| 25 class Widget; | |
| 26 } // namespace views | |
| 27 | |
| 28 class Notification; | |
| 29 | |
| 30 namespace chromeos { | |
| 31 | |
| 32 class BalloonViewHost; | |
| 33 class NotificationControlView; | |
| 34 | |
| 35 // A balloon view is the UI component for a notification panel. | |
| 36 class BalloonViewImpl : public BalloonView, | |
| 37 public views::View, | |
| 38 public content::NotificationObserver, | |
| 39 public base::SupportsWeakPtr<BalloonViewImpl> { | |
| 40 public: | |
| 41 BalloonViewImpl(bool sticky, bool controls, bool web_ui); | |
| 42 virtual ~BalloonViewImpl(); | |
| 43 | |
| 44 // views::View interface. | |
| 45 virtual void Layout() OVERRIDE; | |
| 46 virtual void ViewHierarchyChanged(bool is_add, | |
| 47 View* parent, | |
| 48 View* child) OVERRIDE; | |
| 49 | |
| 50 // BalloonView interface. | |
| 51 virtual void Show(Balloon* balloon) OVERRIDE; | |
| 52 virtual void Update() OVERRIDE; | |
| 53 virtual void Close(bool by_user) OVERRIDE; | |
| 54 virtual void RepositionToBalloon() OVERRIDE; | |
| 55 virtual gfx::Size GetSize() const OVERRIDE; | |
| 56 virtual BalloonHost* GetHost() const OVERRIDE; | |
| 57 | |
| 58 // True if the notification is stale. False if the notification is new. | |
| 59 bool stale() const { return stale_; } | |
| 60 | |
| 61 // Makes the notification stale. | |
| 62 void set_stale() { stale_ = true; } | |
| 63 | |
| 64 // True if the notification is sticky. | |
| 65 bool sticky() const { return sticky_; } | |
| 66 | |
| 67 // True if the notification is being closed. | |
| 68 bool closed() const { return closed_; } | |
| 69 | |
| 70 // True if the balloon is for the given |notification|. | |
| 71 bool IsFor(const Notification& notification) const; | |
| 72 | |
| 73 // Called when the notification becomes active (mouse is on). | |
| 74 void Activated(); | |
| 75 | |
| 76 // Called when the notification becomes inactive. | |
| 77 void Deactivated(); | |
| 78 | |
| 79 private: | |
| 80 friend class NotificationControlView; | |
| 81 | |
| 82 // views::View interface. | |
| 83 virtual gfx::Size GetPreferredSize() OVERRIDE; | |
| 84 | |
| 85 // content::NotificationObserver interface. | |
| 86 virtual void Observe(int type, | |
| 87 const content::NotificationSource& source, | |
| 88 const content::NotificationDetails& details) OVERRIDE; | |
| 89 | |
| 90 // Initializes the options menu. | |
| 91 void CreateOptionsMenu(); | |
| 92 | |
| 93 // Do the delayed close work. | |
| 94 void DelayedClose(bool by_user); | |
| 95 | |
| 96 // Denies the permission to show the ballooon from its source. | |
| 97 void DenyPermission(); | |
| 98 | |
| 99 // Returns the renderer's native view. | |
| 100 gfx::NativeView GetParentNativeView(); | |
| 101 | |
| 102 // Non-owned pointer to the balloon which owns this object. | |
| 103 Balloon* balloon_; | |
| 104 | |
| 105 // The renderer of the HTML contents. | |
| 106 scoped_ptr<BalloonViewHost> html_contents_; | |
| 107 | |
| 108 // A widget for ControlView. | |
| 109 scoped_ptr<views::Widget> control_view_host_; | |
| 110 | |
| 111 bool stale_; | |
| 112 content::NotificationRegistrar notification_registrar_; | |
| 113 // A sticky flag. A sticky notification cannot be dismissed by a user. | |
| 114 bool sticky_; | |
| 115 // True if a notification should have info/option/dismiss label/buttons. | |
| 116 bool controls_; | |
| 117 // True if the notification is being closed. | |
| 118 bool closed_; | |
| 119 // True to enable WebUI in the notification. | |
| 120 bool web_ui_; | |
| 121 | |
| 122 DISALLOW_COPY_AND_ASSIGN(BalloonViewImpl); | |
| 123 }; | |
| 124 | |
| 125 } // namespace chromeos | |
| 126 | |
| 127 #endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_BALLOON_VIEW_H_ | |
| OLD | NEW |