shell_desktop_controller_mac.mm 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. #include "extensions/shell/browser/shell_desktop_controller_mac.h"
  5. #include "base/run_loop.h"
  6. #include "extensions/browser/app_window/app_window.h"
  7. #include "extensions/browser/app_window/native_app_window.h"
  8. #include "extensions/shell/browser/shell_app_window_client.h"
  9. #include "ui/base/base_window.h"
  10. namespace extensions {
  11. ShellDesktopControllerMac::ShellDesktopControllerMac()
  12. : app_window_client_(new ShellAppWindowClient), app_window_(nullptr) {
  13. AppWindowClient::Set(app_window_client_.get());
  14. }
  15. ShellDesktopControllerMac::~ShellDesktopControllerMac() {
  16. // TODO(yoz): This is actually too late to close app windows (for tests).
  17. // Maybe this is useful for non-tests.
  18. CloseAppWindows();
  19. }
  20. void ShellDesktopControllerMac::AddAppWindow(AppWindow* app_window,
  21. gfx::NativeWindow window) {
  22. app_window_ = app_window;
  23. }
  24. void ShellDesktopControllerMac::CloseAppWindows() {
  25. if (app_window_) {
  26. ui::BaseWindow* window = app_window_->GetBaseWindow();
  27. window->Close(); // Close() deletes |app_window_|.
  28. app_window_ = nullptr;
  29. }
  30. }
  31. } // namespace extensions