OLD | NEW |
---|---|
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/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
11 #include "ash/common/shelf/shelf_constants.h" | 11 #include "ash/common/shelf/shelf_constants.h" |
12 #include "ash/common/shelf/wm_shelf.h" | |
12 #include "ash/common/shelf/wm_shelf_util.h" | 13 #include "ash/common/shelf/wm_shelf_util.h" |
13 #include "ash/common/system/tray/tray_constants.h" | 14 #include "ash/common/system/tray/tray_constants.h" |
14 #include "ash/common/system/tray/tray_utils.h" | 15 #include "ash/common/system/tray/tray_utils.h" |
15 #include "ash/common/wm_shell.h" | 16 #include "ash/common/wm_shell.h" |
17 #include "ash/common/wm_window.h" | |
16 #include "grit/ash_resources.h" | 18 #include "grit/ash_resources.h" |
17 #include "grit/ash_strings.h" | 19 #include "grit/ash_strings.h" |
18 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
19 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/display/display.h" | |
20 #include "ui/events/event.h" | 23 #include "ui/events/event.h" |
21 #include "ui/gfx/image/image_skia.h" | 24 #include "ui/gfx/image/image_skia.h" |
22 #include "ui/gfx/paint_vector_icon.h" | 25 #include "ui/gfx/paint_vector_icon.h" |
23 #include "ui/gfx/vector_icons_public.h" | 26 #include "ui/gfx/vector_icons_public.h" |
24 #include "ui/keyboard/keyboard_controller.h" | 27 #include "ui/keyboard/keyboard_controller.h" |
25 #include "ui/views/controls/image_view.h" | 28 #include "ui/views/controls/image_view.h" |
26 | 29 |
27 namespace ash { | 30 namespace ash { |
28 | 31 |
29 VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf) | 32 VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf) |
30 : TrayBackgroundView(wm_shelf), icon_(new views::ImageView) { | 33 : TrayBackgroundView(wm_shelf), |
34 display_id_(wm_shelf->GetWindow()->GetDisplayNearestWindow().id()), | |
oshima
2016/11/08 17:26:04
This mapping may change. Please get this when show
yhanada
2016/11/14 22:48:47
Done.
| |
35 icon_(new views::ImageView) { | |
31 if (MaterialDesignController::IsShelfMaterial()) { | 36 if (MaterialDesignController::IsShelfMaterial()) { |
32 gfx::ImageSkia image_md = | 37 gfx::ImageSkia image_md = |
33 CreateVectorIcon(gfx::VectorIconId::SHELF_KEYBOARD, kShelfIconColor); | 38 CreateVectorIcon(gfx::VectorIconId::SHELF_KEYBOARD, kShelfIconColor); |
34 icon_->SetImage(image_md); | 39 icon_->SetImage(image_md); |
35 } else { | 40 } else { |
36 gfx::ImageSkia* image_non_md = | 41 gfx::ImageSkia* image_non_md = |
37 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 42 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
38 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD); | 43 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD); |
39 icon_->SetImage(image_non_md); | 44 icon_->SetImage(image_non_md); |
40 } | 45 } |
(...skipping 28 matching lines...) Expand all Loading... | |
69 return l10n_util::GetStringUTF16( | 74 return l10n_util::GetStringUTF16( |
70 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); | 75 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); |
71 } | 76 } |
72 | 77 |
73 void VirtualKeyboardTray::HideBubbleWithView( | 78 void VirtualKeyboardTray::HideBubbleWithView( |
74 const views::TrayBubbleView* bubble_view) {} | 79 const views::TrayBubbleView* bubble_view) {} |
75 | 80 |
76 void VirtualKeyboardTray::ClickedOutsideBubble() {} | 81 void VirtualKeyboardTray::ClickedOutsideBubble() {} |
77 | 82 |
78 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { | 83 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { |
79 WmShell::Get()->keyboard_ui()->Show(); | 84 WmShell::Get()->keyboard_ui()->ShowInSpecificDisplay(display_id_); |
80 return true; | 85 return true; |
81 } | 86 } |
82 | 87 |
83 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_enabled) { | 88 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_enabled) { |
84 SetVisible(new_enabled); | 89 SetVisible(new_enabled); |
85 if (new_enabled) { | 90 if (new_enabled) { |
86 // Observe keyboard controller to detect when the virtual keyboard is | 91 // Observe keyboard controller to detect when the virtual keyboard is |
87 // shown/hidden. | 92 // shown/hidden. |
88 ObserveKeyboardController(); | 93 ObserveKeyboardController(); |
89 } else { | 94 } else { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 } | 132 } |
128 | 133 |
129 void VirtualKeyboardTray::UnobserveKeyboardController() { | 134 void VirtualKeyboardTray::UnobserveKeyboardController() { |
130 keyboard::KeyboardController* keyboard_controller = | 135 keyboard::KeyboardController* keyboard_controller = |
131 keyboard::KeyboardController::GetInstance(); | 136 keyboard::KeyboardController::GetInstance(); |
132 if (keyboard_controller) | 137 if (keyboard_controller) |
133 keyboard_controller->RemoveObserver(this); | 138 keyboard_controller->RemoveObserver(this); |
134 } | 139 } |
135 | 140 |
136 } // namespace ash | 141 } // namespace ash |
OLD | NEW |