| 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 icon_(new views::ImageView), |
| 35 wm_shelf_(wm_shelf) { |
| 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 const int64_t display_id = |
| 85 wm_shelf_->GetWindow()->GetDisplayNearestWindow().id(); |
| 86 WmShell::Get()->keyboard_ui()->ShowInDisplay(display_id); |
| 80 return true; | 87 return true; |
| 81 } | 88 } |
| 82 | 89 |
| 83 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_enabled) { | 90 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_enabled) { |
| 84 SetVisible(new_enabled); | 91 SetVisible(new_enabled); |
| 85 if (new_enabled) { | 92 if (new_enabled) { |
| 86 // Observe keyboard controller to detect when the virtual keyboard is | 93 // Observe keyboard controller to detect when the virtual keyboard is |
| 87 // shown/hidden. | 94 // shown/hidden. |
| 88 ObserveKeyboardController(); | 95 ObserveKeyboardController(); |
| 89 } else { | 96 } else { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 134 } |
| 128 | 135 |
| 129 void VirtualKeyboardTray::UnobserveKeyboardController() { | 136 void VirtualKeyboardTray::UnobserveKeyboardController() { |
| 130 keyboard::KeyboardController* keyboard_controller = | 137 keyboard::KeyboardController* keyboard_controller = |
| 131 keyboard::KeyboardController::GetInstance(); | 138 keyboard::KeyboardController::GetInstance(); |
| 132 if (keyboard_controller) | 139 if (keyboard_controller) |
| 133 keyboard_controller->RemoveObserver(this); | 140 keyboard_controller->RemoveObserver(this); |
| 134 } | 141 } |
| 135 | 142 |
| 136 } // namespace ash | 143 } // namespace ash |
| OLD | NEW |