shell_native_app_window_mac.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2014 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 EXTENSIONS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_MAC_H_
  5. #define EXTENSIONS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_MAC_H_
  6. #import <Cocoa/Cocoa.h>
  7. #import "base/mac/scoped_nsobject.h"
  8. #include "extensions/shell/browser/shell_native_app_window.h"
  9. namespace extensions {
  10. class ShellNativeAppWindowMac;
  11. }
  12. // A window controller for ShellNativeAppWindowMac to handle NSNotifications
  13. // and pass them to the C++ implementation.
  14. @interface ShellNativeAppWindowController
  15. : NSWindowController<NSWindowDelegate> {
  16. @private
  17. extensions::ShellNativeAppWindowMac* _appWindow; // Owns us.
  18. }
  19. @property(assign, nonatomic) extensions::ShellNativeAppWindowMac* appWindow;
  20. @end
  21. namespace extensions {
  22. // A minimal implementation of ShellNativeAppWindow for Mac Cocoa.
  23. // Based on the NativeAppWindowCocoa implementation.
  24. class ShellNativeAppWindowMac : public ShellNativeAppWindow {
  25. public:
  26. ShellNativeAppWindowMac(extensions::AppWindow* app_window,
  27. const extensions::AppWindow::CreateParams& params);
  28. ShellNativeAppWindowMac(const ShellNativeAppWindowMac&) = delete;
  29. ShellNativeAppWindowMac& operator=(const ShellNativeAppWindowMac&) = delete;
  30. ~ShellNativeAppWindowMac() override;
  31. // ui::BaseWindow:
  32. bool IsActive() const override;
  33. gfx::NativeWindow GetNativeWindow() const override;
  34. gfx::Rect GetBounds() const override;
  35. void Show() override;
  36. void Hide() override;
  37. bool IsVisible() const override;
  38. void Activate() override;
  39. void Deactivate() override;
  40. void SetBounds(const gfx::Rect& bounds) override;
  41. // NativeAppWindow:
  42. gfx::Size GetContentMinimumSize() const override;
  43. gfx::Size GetContentMaximumSize() const override;
  44. // Called when the window is about to close.
  45. void WindowWillClose();
  46. private:
  47. NSWindow* window() const;
  48. base::scoped_nsobject<ShellNativeAppWindowController> window_controller_;
  49. };
  50. } // namespace extensions
  51. #endif // EXTENSIONS_SHELL_BROWSER_SHELL_NATIVE_APP_WINDOW_MAC_H_