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.
5 #include "athena/extensions/athena_app_window_client_base.h"
7 #include "athena/activity/public/activity_factory.h"
8 #include "athena/activity/public/activity_manager.h"
9 #include "athena/wm/public/window_list_provider.h"
10 #include "athena/wm/public/window_manager.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/components/native_app_window/native_app_window_views.h"
16 AthenaAppWindowClientBase::AthenaAppWindowClientBase() {
19 AthenaAppWindowClientBase::~AthenaAppWindowClientBase() {
22 extensions::NativeAppWindow
* AthenaAppWindowClientBase::CreateNativeAppWindow(
23 extensions::AppWindow
* app_window
,
24 extensions::AppWindow::CreateParams
* params
) {
25 auto* native_window
= new native_app_window::NativeAppWindowViews
;
26 native_window
->Init(app_window
, *params
);
27 ActivityFactory::Get()->CreateAppActivity(app_window
->extension_id(),
28 native_window
->web_view());
29 if (params
->focused
) {
30 // Windows are created per default at the top of the stack. If - at this
31 // point of initialization - it is has been moved into a different Z-order
32 // location we should respect this, not allowing the application activation
33 // to bring it to the front. This can happen as part of the resource
34 // manager's reloading or intelligent preloading of an application.
35 const aura::Window::Windows
& list
=
36 WindowManager::Get()->GetWindowListProvider()->GetWindowList();
37 aura::Window
* native_app_window
=
38 native_window
->widget()->GetNativeWindow();
39 params
->focused
= !list
.size() || list
.back() == native_app_window
;