1 // Copyright (c) 2012 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 "content/shell/shell_stacking_client_ash.h"
7 #include "ui/aura/client/default_capture_client.h"
8 #include "ui/aura/focus_manager.h"
9 #include "ui/aura/root_window.h"
10 #include "ui/aura/test/test_activation_client.h"
11 #include "ui/views/corewm/compound_event_filter.h"
12 #include "ui/views/corewm/input_method_event_filter.h"
16 ShellStackingClientAsh::ShellStackingClientAsh() {
19 ShellStackingClientAsh::~ShellStackingClientAsh() {
20 if (root_window_
.get())
21 root_window_event_filter_
->RemoveHandler(input_method_filter_
.get());
23 aura::client::SetStackingClient(NULL
);
26 aura::Window
* ShellStackingClientAsh::GetDefaultParent(
27 aura::Window
* context
,
29 const gfx::Rect
& bounds
) {
30 if (!root_window_
.get()) {
31 root_window_
.reset(new aura::RootWindow(
32 aura::RootWindow::CreateParams(gfx::Rect(100, 100))));
34 focus_client_
.reset(new aura::FocusManager
);
35 aura::client::SetFocusClient(root_window_
.get(), focus_client_
.get());
37 root_window_event_filter_
= new views::corewm::CompoundEventFilter
;
38 // Pass ownership of the filter to the root_window.
39 root_window_
->SetEventFilter(root_window_event_filter_
);
41 input_method_filter_
.reset(new views::corewm::InputMethodEventFilter(
42 root_window_
->GetAcceleratedWidget()));
43 input_method_filter_
->SetInputMethodPropertyInRootWindow(
45 root_window_event_filter_
->AddHandler(input_method_filter_
.get());
47 test_activation_client_
.reset(
48 new aura::test::TestActivationClient(root_window_
.get()));
50 capture_client_
.reset(
51 new aura::client::DefaultCaptureClient(root_window_
.get()));
53 return root_window_
.get();
56 } // namespace content