1 // Copyright 2015 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.
5 #import "chrome/browser/ui/views/apps/chrome_native_app_window_views_mac.h"
7 #include "chrome/browser/apps/app_shim/extension_app_shim_handler_mac.h"
8 #include "chrome/browser/ui/views/apps/app_window_native_widget_mac.h"
9 #include "chrome/browser/ui/views/apps/native_app_window_frame_view_mac.h"
11 ChromeNativeAppWindowViewsMac::ChromeNativeAppWindowViewsMac()
12 : is_hidden_with_app_(false) {
15 ChromeNativeAppWindowViewsMac::~ChromeNativeAppWindowViewsMac() {
18 void ChromeNativeAppWindowViewsMac::OnBeforeWidgetInit(
19 const extensions::AppWindow::CreateParams& create_params,
20 views::Widget::InitParams* init_params,
21 views::Widget* widget) {
22 DCHECK(!init_params->native_widget);
23 init_params->native_widget = new AppWindowNativeWidgetMac(widget);
24 ChromeNativeAppWindowViews::OnBeforeWidgetInit(create_params, init_params,
28 views::NonClientFrameView*
29 ChromeNativeAppWindowViewsMac::CreateStandardDesktopAppFrame() {
30 return new NativeAppWindowFrameViewMac(widget());
33 void ChromeNativeAppWindowViewsMac::Show() {
34 if (is_hidden_with_app_) {
35 // If there is a shim to gently request attention, return here. Otherwise
36 // show the window as usual.
37 if (apps::ExtensionAppShimHandler::ActivateAndRequestUserAttentionForWindow(
43 ChromeNativeAppWindowViews::Show();
46 void ChromeNativeAppWindowViewsMac::ShowInactive() {
47 if (is_hidden_with_app_)
50 ChromeNativeAppWindowViews::ShowInactive();
53 void ChromeNativeAppWindowViewsMac::ShowWithApp() {
54 is_hidden_with_app_ = false;
55 if (!app_window()->is_hidden())
59 void ChromeNativeAppWindowViewsMac::HideWithApp() {
60 is_hidden_with_app_ = true;
61 ChromeNativeAppWindowViews::Hide();