Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(815)

Side by Side Diff: ash/display/virtual_keyboard_window_controller.cc

Issue 74693002: . (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/display/virtual_keyboard_window_controller.h" 5 #include "ash/display/virtual_keyboard_window_controller.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/display/display_info.h" 8 #include "ash/display/display_info.h"
9 #include "ash/display/display_manager.h" 9 #include "ash/display/display_manager.h"
10 #include "ash/host/root_window_host_factory.h" 10 #include "ash/host/root_window_host_factory.h"
11 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
12 #include "ash/root_window_settings.h" 12 #include "ash/root_window_settings.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_window_ids.h" 14 #include "ash/shell_window_ids.h"
15 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "ui/aura/env.h" 17 #include "ui/aura/env.h"
18 #include "ui/aura/root_window.h" 18 #include "ui/aura/root_window.h"
19 #include "ui/keyboard/keyboard_controller.h"
20 19
21 namespace ash { 20 namespace ash {
22 namespace internal { 21 namespace internal {
23 22
24 VirtualKeyboardWindowController::VirtualKeyboardWindowController() { 23 VirtualKeyboardWindowController::VirtualKeyboardWindowController() {
25 } 24 }
26 25
27 VirtualKeyboardWindowController::~VirtualKeyboardWindowController() { 26 VirtualKeyboardWindowController::~VirtualKeyboardWindowController() {
28 // Make sure the root window gets deleted before cursor_window_delegate. 27 // Make sure the root window gets deleted before cursor_window_delegate.
29 Close(); 28 Close();
30 } 29 }
31 30
32 void VirtualKeyboardWindowController::ActivateKeyboard(
33 keyboard::KeyboardController* keyboard_controller) {
34 root_window_controller_->ActivateKeyboard(keyboard_controller);
35 }
36
37 void VirtualKeyboardWindowController::UpdateWindow( 31 void VirtualKeyboardWindowController::UpdateWindow(
38 const DisplayInfo& display_info) { 32 const DisplayInfo& display_info) {
39 static int virtual_keyboard_root_window_count = 0; 33 static int virtual_keyboard_root_window_count = 0;
40 if (!root_window_controller_.get()) { 34 if (!root_window_controller_.get()) {
41 const gfx::Rect& bounds_in_native = display_info.bounds_in_native(); 35 const gfx::Rect& bounds_in_native = display_info.bounds_in_native();
42 aura::RootWindow::CreateParams params(bounds_in_native); 36 aura::RootWindow::CreateParams params(bounds_in_native);
43 params.host = Shell::GetInstance()->root_window_host_factory()-> 37 params.host = Shell::GetInstance()->root_window_host_factory()->
44 CreateRootWindowHost(bounds_in_native); 38 CreateRootWindowHost(bounds_in_native);
45 aura::RootWindow* root_window = new aura::RootWindow(params); 39 aura::RootWindow* root_window = new aura::RootWindow(params);
46 40
47 root_window->window()->SetName( 41 root_window->window()->SetName(
48 base::StringPrintf("VirtualKeyboardRootWindow-%d", 42 base::StringPrintf("VirtualKeyboardRootWindow-%d",
49 virtual_keyboard_root_window_count++)); 43 virtual_keyboard_root_window_count++));
50 44
51 // No need to remove RootWindowObserver because 45 // No need to remove RootWindowObserver because
52 // the DisplayController object outlives RootWindow objects. 46 // the DisplayController object outlives RootWindow objects.
53 root_window->AddRootWindowObserver( 47 root_window->AddRootWindowObserver(
54 Shell::GetInstance()->display_controller()); 48 Shell::GetInstance()->display_controller());
55 InitRootWindowSettings(root_window->window())->display_id = 49 InitRootWindowSettings(root_window->window())->display_id =
56 display_info.id(); 50 display_info.id();
57 root_window->Init(); 51 root_window->Init();
58 RootWindowController::CreateForVirtualKeyboardDisplay(root_window); 52 RootWindowController::CreateForVirtualKeyboardDisplay(root_window);
59 root_window_controller_.reset(GetRootWindowController( 53 root_window_controller_.reset(GetRootWindowController(
60 root_window->window())); 54 root_window->window()));
61 root_window_controller_->dispatcher()->host()->Show(); 55 root_window_controller_->dispatcher()->host()->Show();
62 root_window_controller_->ActivateKeyboard(
63 Shell::GetInstance()->keyboard_controller());
64 } else { 56 } else {
65 aura::RootWindow* root_window = root_window_controller_->dispatcher(); 57 aura::RootWindow* root_window = root_window_controller_->dispatcher();
66 GetRootWindowSettings(root_window->window())->display_id = 58 GetRootWindowSettings(root_window->window())->display_id =
67 display_info.id(); 59 display_info.id();
68 root_window->SetHostBounds(display_info.bounds_in_native()); 60 root_window->SetHostBounds(display_info.bounds_in_native());
69 } 61 }
70 } 62 }
71 63
72 void VirtualKeyboardWindowController::Close() { 64 void VirtualKeyboardWindowController::Close() {
73 if (root_window_controller_.get()) { 65 if (root_window_controller_.get()) {
74 root_window_controller_->dispatcher()->RemoveRootWindowObserver( 66 root_window_controller_->dispatcher()->RemoveRootWindowObserver(
75 Shell::GetInstance()->display_controller()); 67 Shell::GetInstance()->display_controller());
76 root_window_controller_->Shutdown(); 68 root_window_controller_->Shutdown();
77 root_window_controller_.reset(); 69 root_window_controller_.reset();
78 } 70 }
79 } 71 }
80 72
81 } // namespace internal 73 } // namespace internal
82 } // namespace ash 74 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/virtual_keyboard_window_controller.h ('k') | ash/display/virtual_keyboard_window_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698