| 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/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" | 5 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" |
| 6 |
| 7 #include <algorithm> |
| 6 | 8 |
| 7 #include "ash/common/keyboard/keyboard_ui.h" | 9 #include "ash/common/keyboard/keyboard_ui.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/shelf/shelf_constants.h" | 11 #include "ash/common/shelf/shelf_constants.h" |
| 10 #include "ash/common/shelf/wm_shelf_util.h" | 12 #include "ash/common/shelf/wm_shelf_util.h" |
| 11 #include "ash/common/system/tray/tray_constants.h" | 13 #include "ash/common/system/tray/tray_constants.h" |
| 12 #include "ash/common/system/tray/tray_utils.h" | 14 #include "ash/common/system/tray/tray_utils.h" |
| 13 #include "ash/shell.h" | 15 #include "ash/common/wm_shell.h" |
| 14 #include "grit/ash_resources.h" | 16 #include "grit/ash_resources.h" |
| 15 #include "grit/ash_strings.h" | 17 #include "grit/ash_strings.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
| 19 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
| 20 #include "ui/gfx/paint_vector_icon.h" | 22 #include "ui/gfx/paint_vector_icon.h" |
| 21 #include "ui/gfx/vector_icons_public.h" | 23 #include "ui/gfx/vector_icons_public.h" |
| 22 #include "ui/views/controls/button/image_button.h" | 24 #include "ui/views/controls/button/image_button.h" |
| 23 | 25 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 36 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD); | 38 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD); |
| 37 button_->SetImage(views::CustomButton::STATE_NORMAL, image_non_md); | 39 button_->SetImage(views::CustomButton::STATE_NORMAL, image_non_md); |
| 38 } | 40 } |
| 39 button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 41 button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 40 views::ImageButton::ALIGN_MIDDLE); | 42 views::ImageButton::ALIGN_MIDDLE); |
| 41 | 43 |
| 42 tray_container()->AddChildView(button_); | 44 tray_container()->AddChildView(button_); |
| 43 button_->SetFocusBehavior(FocusBehavior::NEVER); | 45 button_->SetFocusBehavior(FocusBehavior::NEVER); |
| 44 SetContentsBackground(); | 46 SetContentsBackground(); |
| 45 // The Shell may not exist in some unit tests. | 47 // The Shell may not exist in some unit tests. |
| 46 if (Shell::HasInstance()) | 48 if (WmShell::HasInstance()) |
| 47 Shell::GetInstance()->keyboard_ui()->AddObserver(this); | 49 WmShell::Get()->keyboard_ui()->AddObserver(this); |
| 48 } | 50 } |
| 49 | 51 |
| 50 VirtualKeyboardTray::~VirtualKeyboardTray() { | 52 VirtualKeyboardTray::~VirtualKeyboardTray() { |
| 51 // The Shell may not exist in some unit tests. | 53 // The Shell may not exist in some unit tests. |
| 52 if (Shell::HasInstance()) | 54 if (WmShell::HasInstance()) |
| 53 Shell::GetInstance()->keyboard_ui()->RemoveObserver(this); | 55 WmShell::Get()->keyboard_ui()->RemoveObserver(this); |
| 54 } | 56 } |
| 55 | 57 |
| 56 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) { | 58 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 57 TrayBackgroundView::SetShelfAlignment(alignment); | 59 TrayBackgroundView::SetShelfAlignment(alignment); |
| 58 tray_container()->SetBorder(views::Border::NullBorder()); | 60 tray_container()->SetBorder(views::Border::NullBorder()); |
| 59 | 61 |
| 60 // Pad button size to align with other controls in the system tray. | 62 // Pad button size to align with other controls in the system tray. |
| 61 const gfx::ImageSkia image = | 63 const gfx::ImageSkia image = |
| 62 button_->GetImage(views::CustomButton::STATE_NORMAL); | 64 button_->GetImage(views::CustomButton::STATE_NORMAL); |
| 63 const int size = GetTrayConstant(VIRTUAL_KEYBOARD_BUTTON_SIZE); | 65 const int size = GetTrayConstant(VIRTUAL_KEYBOARD_BUTTON_SIZE); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 79 return l10n_util::GetStringUTF16( | 81 return l10n_util::GetStringUTF16( |
| 80 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); | 82 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); |
| 81 } | 83 } |
| 82 | 84 |
| 83 void VirtualKeyboardTray::HideBubbleWithView( | 85 void VirtualKeyboardTray::HideBubbleWithView( |
| 84 const views::TrayBubbleView* bubble_view) {} | 86 const views::TrayBubbleView* bubble_view) {} |
| 85 | 87 |
| 86 void VirtualKeyboardTray::ClickedOutsideBubble() {} | 88 void VirtualKeyboardTray::ClickedOutsideBubble() {} |
| 87 | 89 |
| 88 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { | 90 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { |
| 89 Shell::GetInstance()->keyboard_ui()->Show(); | 91 WmShell::Get()->keyboard_ui()->Show(); |
| 90 return true; | 92 return true; |
| 91 } | 93 } |
| 92 | 94 |
| 93 void VirtualKeyboardTray::ButtonPressed(views::Button* sender, | 95 void VirtualKeyboardTray::ButtonPressed(views::Button* sender, |
| 94 const ui::Event& event) { | 96 const ui::Event& event) { |
| 95 DCHECK_EQ(button_, sender); | 97 DCHECK_EQ(button_, sender); |
| 96 PerformAction(event); | 98 PerformAction(event); |
| 97 } | 99 } |
| 98 | 100 |
| 99 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) { | 101 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) { |
| 100 SetVisible(Shell::GetInstance()->keyboard_ui()->IsEnabled()); | 102 SetVisible(WmShell::Get()->keyboard_ui()->IsEnabled()); |
| 101 } | 103 } |
| 102 | 104 |
| 103 } // namespace ash | 105 } // namespace ash |
| OLD | NEW |