Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / shell / browser / shell_platform_data_aura.cc
blob6a8423a18ef3feb9d1b5cd4b0983610e9953bbd3
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 "content/shell/browser/shell_platform_data_aura.h"
7 #include "content/shell/browser/shell.h"
8 #include "ui/aura/client/default_capture_client.h"
9 #include "ui/aura/env.h"
10 #include "ui/aura/layout_manager.h"
11 #include "ui/aura/test/test_focus_client.h"
12 #include "ui/aura/test/test_window_tree_client.h"
13 #include "ui/aura/window.h"
14 #include "ui/aura/window_event_dispatcher.h"
15 #include "ui/base/ime/input_method.h"
16 #include "ui/base/ime/input_method_delegate.h"
17 #include "ui/base/ime/input_method_factory.h"
18 #include "ui/gfx/screen.h"
19 #include "ui/wm/core/default_activation_client.h"
21 namespace content {
23 namespace {
25 class FillLayout : public aura::LayoutManager {
26 public:
27 explicit FillLayout(aura::Window* root)
28 : root_(root) {
31 ~FillLayout() override {}
33 private:
34 // aura::LayoutManager:
35 void OnWindowResized() override {}
37 void OnWindowAddedToLayout(aura::Window* child) override {
38 child->SetBounds(root_->bounds());
41 void OnWillRemoveWindowFromLayout(aura::Window* child) override {}
43 void OnWindowRemovedFromLayout(aura::Window* child) override {}
45 void OnChildWindowVisibilityChanged(aura::Window* child,
46 bool visible) override {}
48 void SetChildBounds(aura::Window* child,
49 const gfx::Rect& requested_bounds) override {
50 SetChildBoundsDirect(child, requested_bounds);
53 aura::Window* root_;
55 DISALLOW_COPY_AND_ASSIGN(FillLayout);
60 ShellPlatformDataAura* Shell::platform_ = NULL;
62 ShellPlatformDataAura::ShellPlatformDataAura(const gfx::Size& initial_size) {
63 CHECK(aura::Env::GetInstance());
64 host_.reset(aura::WindowTreeHost::Create(gfx::Rect(initial_size)));
65 host_->InitHost();
66 host_->window()->SetLayoutManager(new FillLayout(host_->window()));
68 focus_client_.reset(new aura::test::TestFocusClient());
69 aura::client::SetFocusClient(host_->window(), focus_client_.get());
71 new wm::DefaultActivationClient(host_->window());
72 capture_client_.reset(
73 new aura::client::DefaultCaptureClient(host_->window()));
74 window_tree_client_.reset(
75 new aura::test::TestWindowTreeClient(host_->window()));
78 ShellPlatformDataAura::~ShellPlatformDataAura() {
81 void ShellPlatformDataAura::ShowWindow() {
82 host_->Show();
85 void ShellPlatformDataAura::ResizeWindow(const gfx::Size& size) {
86 host_->SetBounds(gfx::Rect(size));
89 } // namespace content