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

Side by Side Diff: ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc

Issue 2761063002: Move more from WmShell to Shell (Closed)
Patch Set: merge Created 3 years, 9 months 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
« no previous file with comments | « ash/common/system/chromeos/tray_tracing.cc ('k') | ash/common/system/date/date_default_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" 5 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/keyboard/keyboard_ui.h" 9 #include "ash/common/keyboard/keyboard_ui.h"
10 #include "ash/common/shelf/shelf_constants.h" 10 #include "ash/common/shelf/shelf_constants.h"
11 #include "ash/common/shelf/wm_shelf.h" 11 #include "ash/common/shelf/wm_shelf.h"
12 #include "ash/common/system/tray/tray_constants.h" 12 #include "ash/common/system/tray/tray_constants.h"
13 #include "ash/common/wm_shell.h"
14 #include "ash/common/wm_window.h" 13 #include "ash/common/wm_window.h"
15 #include "ash/resources/vector_icons/vector_icons.h" 14 #include "ash/resources/vector_icons/vector_icons.h"
15 #include "ash/shell.h"
16 #include "ash/strings/grit/ash_strings.h" 16 #include "ash/strings/grit/ash_strings.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/display/display.h" 18 #include "ui/display/display.h"
19 #include "ui/events/event.h" 19 #include "ui/events/event.h"
20 #include "ui/gfx/image/image_skia.h" 20 #include "ui/gfx/image/image_skia.h"
21 #include "ui/gfx/paint_vector_icon.h" 21 #include "ui/gfx/paint_vector_icon.h"
22 #include "ui/keyboard/keyboard_controller.h" 22 #include "ui/keyboard/keyboard_controller.h"
23 #include "ui/views/controls/image_view.h" 23 #include "ui/views/controls/image_view.h"
24 24
25 namespace ash { 25 namespace ash {
26 26
27 VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf) 27 VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf)
28 : TrayBackgroundView(wm_shelf, true), 28 : TrayBackgroundView(wm_shelf, true),
29 icon_(new views::ImageView), 29 icon_(new views::ImageView),
30 wm_shelf_(wm_shelf) { 30 wm_shelf_(wm_shelf) {
31 SetInkDropMode(InkDropMode::ON); 31 SetInkDropMode(InkDropMode::ON);
32 32
33 icon_->SetImage(gfx::CreateVectorIcon(kShelfKeyboardIcon, kShelfIconColor)); 33 icon_->SetImage(gfx::CreateVectorIcon(kShelfKeyboardIcon, kShelfIconColor));
34 SetIconBorderForShelfAlignment(); 34 SetIconBorderForShelfAlignment();
35 tray_container()->AddChildView(icon_); 35 tray_container()->AddChildView(icon_);
36 36
37 // The Shell may not exist in some unit tests. 37 // The Shell may not exist in some unit tests.
38 if (WmShell::HasInstance()) 38 if (Shell::HasInstance())
39 WmShell::Get()->keyboard_ui()->AddObserver(this); 39 Shell::Get()->keyboard_ui()->AddObserver(this);
40 // Try observing keyboard controller, in case it is already constructed. 40 // Try observing keyboard controller, in case it is already constructed.
41 ObserveKeyboardController(); 41 ObserveKeyboardController();
42 } 42 }
43 43
44 VirtualKeyboardTray::~VirtualKeyboardTray() { 44 VirtualKeyboardTray::~VirtualKeyboardTray() {
45 // Try unobserving keyboard controller, in case it still exists. 45 // Try unobserving keyboard controller, in case it still exists.
46 UnobserveKeyboardController(); 46 UnobserveKeyboardController();
47 // The Shell may not exist in some unit tests. 47 // The Shell may not exist in some unit tests.
48 if (WmShell::HasInstance()) 48 if (Shell::HasInstance())
49 WmShell::Get()->keyboard_ui()->RemoveObserver(this); 49 Shell::Get()->keyboard_ui()->RemoveObserver(this);
50 } 50 }
51 51
52 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) { 52 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) {
53 if (alignment == shelf_alignment()) 53 if (alignment == shelf_alignment())
54 return; 54 return;
55 55
56 TrayBackgroundView::SetShelfAlignment(alignment); 56 TrayBackgroundView::SetShelfAlignment(alignment);
57 SetIconBorderForShelfAlignment(); 57 SetIconBorderForShelfAlignment();
58 } 58 }
59 59
60 base::string16 VirtualKeyboardTray::GetAccessibleNameForTray() { 60 base::string16 VirtualKeyboardTray::GetAccessibleNameForTray() {
61 return l10n_util::GetStringUTF16( 61 return l10n_util::GetStringUTF16(
62 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); 62 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME);
63 } 63 }
64 64
65 void VirtualKeyboardTray::HideBubbleWithView( 65 void VirtualKeyboardTray::HideBubbleWithView(
66 const views::TrayBubbleView* bubble_view) {} 66 const views::TrayBubbleView* bubble_view) {}
67 67
68 void VirtualKeyboardTray::ClickedOutsideBubble() {} 68 void VirtualKeyboardTray::ClickedOutsideBubble() {}
69 69
70 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { 70 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) {
71 const int64_t display_id = 71 const int64_t display_id =
72 wm_shelf_->GetWindow()->GetDisplayNearestWindow().id(); 72 wm_shelf_->GetWindow()->GetDisplayNearestWindow().id();
73 WmShell::Get()->keyboard_ui()->ShowInDisplay(display_id); 73 Shell::Get()->keyboard_ui()->ShowInDisplay(display_id);
74 // Normally, active status is set when virtual keyboard is shown/hidden, 74 // Normally, active status is set when virtual keyboard is shown/hidden,
75 // however, showing virtual keyboard happens asynchronously and, especially 75 // however, showing virtual keyboard happens asynchronously and, especially
76 // the first time, takes some time. We need to set active status here to 76 // the first time, takes some time. We need to set active status here to
77 // prevent bad things happening if user clicked the button before keyboard is 77 // prevent bad things happening if user clicked the button before keyboard is
78 // shown. 78 // shown.
79 SetIsActive(true); 79 SetIsActive(true);
80 return true; 80 return true;
81 } 81 }
82 82
83 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_enabled) { 83 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_enabled) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 115 }
116 116
117 void VirtualKeyboardTray::UnobserveKeyboardController() { 117 void VirtualKeyboardTray::UnobserveKeyboardController() {
118 keyboard::KeyboardController* keyboard_controller = 118 keyboard::KeyboardController* keyboard_controller =
119 keyboard::KeyboardController::GetInstance(); 119 keyboard::KeyboardController::GetInstance();
120 if (keyboard_controller) 120 if (keyboard_controller)
121 keyboard_controller->RemoveObserver(this); 121 keyboard_controller->RemoveObserver(this);
122 } 122 }
123 123
124 } // namespace ash 124 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/tray_tracing.cc ('k') | ash/common/system/date/date_default_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698