| Index: ash/system/web_notification/web_notification_tray.h
|
| diff --git a/ash/system/web_notification/web_notification_tray.h b/ash/system/web_notification/web_notification_tray.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..304099a53f03a8401559449c4b005f7b8374116a
|
| --- /dev/null
|
| +++ b/ash/system/web_notification/web_notification_tray.h
|
| @@ -0,0 +1,140 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_
|
| +#define ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_
|
| +#pragma once
|
| +
|
| +#include "ash/ash_export.h"
|
| +#include "ash/system/tray/tray_background_view.h"
|
| +#include "base/gtest_prod_util.h"
|
| +#include "ui/aura/event_filter.h"
|
| +
|
| +class SkBitmap;
|
| +
|
| +namespace aura {
|
| +class LocatedEvent;
|
| +}
|
| +
|
| +namespace base {
|
| +class DictionaryValue;
|
| +}
|
| +
|
| +namespace views {
|
| +class ImageView;
|
| +}
|
| +
|
| +namespace ash {
|
| +
|
| +namespace internal {
|
| +class StatusAreaWidget;
|
| +class WebNotificationList;
|
| +}
|
| +
|
| +// Status area tray for showing browser and app notifications.
|
| +// Note: Not to be confused with system notifications (a NotificationView
|
| +// generated by a SystemTrayItem).
|
| +
|
| +class ASH_EXPORT WebNotificationTray : public aura::EventFilter,
|
| + public internal::TrayBackgroundView {
|
| + public:
|
| + class Delegate {
|
| + public:
|
| + virtual ~Delegate() {}
|
| +
|
| + // Called when the notification associated with |notification_id| is
|
| + // removed (i.e. closed by the user).
|
| + virtual void NotificationRemoved(const std::string& notifcation_id) = 0;
|
| +
|
| + // Disables the extension associated with |notification_id|.
|
| + virtual void DisableExtension(const std::string& notifcation_id) = 0;
|
| +
|
| + // Disables notifications from the source of |notification_id|.
|
| + virtual void DisableNotificationsFromSource(
|
| + const std::string& notifcation_id) = 0;
|
| +
|
| + // Show the notification settings (from notifiation |notification_id|).
|
| + virtual void ShowSettings(const std::string& notifcation_id) = 0;
|
| + };
|
| +
|
| + explicit WebNotificationTray(internal::StatusAreaWidget* status_area_widget);
|
| + virtual ~WebNotificationTray();
|
| +
|
| + // Called once to set the delegate.
|
| + void SetDelegate(Delegate* delegate);
|
| +
|
| + // Add a new notification. Use SetNotificationImage to set the icon image.
|
| + void AddNotification(const std::string& id,
|
| + const string16& title,
|
| + const string16& message,
|
| + const string16& source,
|
| + const std::string& extension);
|
| +
|
| + // Remove an existing notification.
|
| + void RemoveNotification(const std::string& id);
|
| +
|
| + // Set the notification image.
|
| + void SetNotificationImage(const std::string& id,
|
| + const SkBitmap& image);
|
| +
|
| + // Disable all notifications matching notification |id|.
|
| + void DisableByExtension(const std::string& id);
|
| + void DisableByUrl(const std::string& id);
|
| +
|
| + // Show the notification bubble. Should only be called by StatusAreaWidget.
|
| + void ShowBubble();
|
| +
|
| + // Hide the notification bubble. Should only be called by StatusAreaWidget.
|
| + void HideBubble();
|
| +
|
| + // Show the settings dialog (use notification matching |id| for the source
|
| + // browser context).
|
| + void ShowSettings(const std::string& id);
|
| +
|
| + // Overridden from aura::EventFilter.
|
| + virtual bool PreHandleKeyEvent(aura::Window* target,
|
| + aura::KeyEvent* event) OVERRIDE;
|
| + virtual bool PreHandleMouseEvent(aura::Window* target,
|
| + aura::MouseEvent* event) OVERRIDE;
|
| + virtual ui::TouchStatus PreHandleTouchEvent(aura::Window* target,
|
| + aura::TouchEvent* event) OVERRIDE;
|
| + virtual ui::GestureStatus PreHandleGestureEvent(
|
| + aura::Window* target,
|
| + aura::GestureEvent* event) OVERRIDE;
|
| +
|
| + // Overridden from TrayBackgroundView.
|
| + virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
|
| +
|
| + // Overridden from internal::ActionableView.
|
| + virtual bool PerformAction(const views::Event& event) OVERRIDE;
|
| +
|
| + private:
|
| + class Bubble;
|
| + class BubbleContentsView;
|
| + FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, WebNotifications);
|
| +
|
| + int GetNotificationCount() const;
|
| + void UpdateIcon();
|
| + void UpdateBubbleAndIcon();
|
| + void ProcessLocatedEvent(const aura::LocatedEvent& event);
|
| +
|
| + const internal::WebNotificationList* notification_list() const {
|
| + return notification_list_.get();
|
| + }
|
| + views::View* tray_container() const { return tray_container_; }
|
| + Bubble* bubble() const { return bubble_.get(); }
|
| +
|
| + internal::StatusAreaWidget* status_area_widget_; // Unowned parent.
|
| + scoped_ptr<internal::WebNotificationList> notification_list_;
|
| + scoped_ptr<Bubble> bubble_;
|
| + views::View* tray_container_;
|
| + views::ImageView* icon_;
|
| + Delegate* delegate_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WebNotificationTray);
|
| +};
|
| +
|
| +} // namespace ash
|
| +
|
| +#endif // ASH_SYSTEM_NOTIFICATION_WEB_NOTIFICATION_TRAY_H_
|
|
|