notification_surface.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2016 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. #ifndef COMPONENTS_EXO_NOTIFICATION_SURFACE_H_
  5. #define COMPONENTS_EXO_NOTIFICATION_SURFACE_H_
  6. #include <memory>
  7. #include <string>
  8. #include "components/exo/surface_observer.h"
  9. #include "components/exo/surface_tree_host.h"
  10. #include "ui/gfx/geometry/size.h"
  11. namespace exo {
  12. class NotificationSurfaceManager;
  13. class Surface;
  14. // Handles notification surface role of a given surface.
  15. class NotificationSurface : public SurfaceTreeHost,
  16. public SurfaceObserver,
  17. public aura::WindowObserver {
  18. public:
  19. NotificationSurface(NotificationSurfaceManager* manager,
  20. Surface* surface,
  21. const std::string& notification_key);
  22. NotificationSurface(const NotificationSurface&) = delete;
  23. NotificationSurface& operator=(const NotificationSurface&) = delete;
  24. ~NotificationSurface() override;
  25. // Get the content size of the |root_surface()|.
  26. gfx::Size GetContentSize() const;
  27. void SetApplicationId(const char* application_id);
  28. const std::string& notification_key() const { return notification_key_; }
  29. // Overridden from SurfaceDelegate:
  30. void OnSurfaceCommit() override;
  31. // Overridden from SurfaceObserver:
  32. void OnSurfaceDestroying(Surface* surface) override;
  33. // Overridden from WindowObserver:
  34. void OnWindowDestroying(aura::Window* window) override;
  35. void OnWindowPropertyChanged(aura::Window* window,
  36. const void* key,
  37. intptr_t old_value) override;
  38. void OnWindowAddedToRootWindow(aura::Window* window) override;
  39. void OnWindowRemovingFromRootWindow(aura::Window* window,
  40. aura::Window* new_root) override;
  41. private:
  42. NotificationSurfaceManager* const manager_; // Not owned.
  43. const std::string notification_key_;
  44. bool added_to_manager_ = false;
  45. // True if the notification is visible by e.g. being embedded in the message
  46. // center.
  47. bool is_embedded_ = false;
  48. };
  49. } // namespace exo
  50. #endif // COMPONENTS_EXO_NOTIFICATION_SURFACE_H_