| 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/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" |
| 6 | 6 |
| 7 #include "ash/keyboard/keyboard_ui.h" |
| 7 #include "ash/shelf/shelf.h" | 8 #include "ash/shelf/shelf.h" |
| 8 #include "ash/shelf/shelf_constants.h" | 9 #include "ash/shelf/shelf_constants.h" |
| 9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 10 #include "ash/system/status_area_widget.h" | 11 #include "ash/system/status_area_widget.h" |
| 11 #include "ash/system/tray/system_tray_notifier.h" | 12 #include "ash/system/tray/system_tray_notifier.h" |
| 12 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
| 13 #include "ash/system/tray/tray_utils.h" | 14 #include "ash/system/tray/tray_utils.h" |
| 14 #include "grit/ash_resources.h" | 15 #include "grit/ash_resources.h" |
| 15 #include "grit/ash_strings.h" | 16 #include "grit/ash_strings.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/events/event.h" | 19 #include "ui/events/event.h" |
| 19 #include "ui/gfx/image/image_skia.h" | 20 #include "ui/gfx/image/image_skia.h" |
| 20 #include "ui/keyboard/keyboard_controller.h" | |
| 21 #include "ui/views/controls/button/image_button.h" | 21 #include "ui/views/controls/button/image_button.h" |
| 22 | 22 |
| 23 namespace ash { | 23 namespace ash { |
| 24 | 24 |
| 25 VirtualKeyboardTray::VirtualKeyboardTray(StatusAreaWidget* status_area_widget) | 25 VirtualKeyboardTray::VirtualKeyboardTray(StatusAreaWidget* status_area_widget) |
| 26 : TrayBackgroundView(status_area_widget), | 26 : TrayBackgroundView(status_area_widget), |
| 27 button_(NULL) { | 27 button_(NULL) { |
| 28 button_ = new views::ImageButton(this); | 28 button_ = new views::ImageButton(this); |
| 29 button_->SetImage(views::CustomButton::STATE_NORMAL, | 29 button_->SetImage(views::CustomButton::STATE_NORMAL, |
| 30 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 30 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 31 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD)); | 31 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD)); |
| 32 button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 32 button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
| 33 views::ImageButton::ALIGN_MIDDLE); | 33 views::ImageButton::ALIGN_MIDDLE); |
| 34 | 34 |
| 35 tray_container()->AddChildView(button_); | 35 tray_container()->AddChildView(button_); |
| 36 SetContentsBackground(); | 36 SetContentsBackground(); |
| 37 // The Shell may not exist in some unit tests. | 37 // The Shell may not exist in some unit tests. |
| 38 if (Shell::HasInstance()) { | 38 if (Shell::HasInstance()) |
| 39 Shell::GetInstance()->system_tray_notifier()-> | 39 Shell::GetInstance()->keyboard_ui()->AddObserver(this); |
| 40 AddAccessibilityObserver(this); | |
| 41 } | |
| 42 } | 40 } |
| 43 | 41 |
| 44 VirtualKeyboardTray::~VirtualKeyboardTray() { | 42 VirtualKeyboardTray::~VirtualKeyboardTray() { |
| 45 // The Shell may not exist in some unit tests. | 43 // The Shell may not exist in some unit tests. |
| 46 if (Shell::HasInstance()) { | 44 if (Shell::HasInstance()) |
| 47 Shell::GetInstance()->system_tray_notifier()-> | 45 Shell::GetInstance()->keyboard_ui()->RemoveObserver(this); |
| 48 RemoveAccessibilityObserver(this); | |
| 49 } | |
| 50 } | 46 } |
| 51 | 47 |
| 52 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) { | 48 void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 53 TrayBackgroundView::SetShelfAlignment(alignment); | 49 TrayBackgroundView::SetShelfAlignment(alignment); |
| 54 tray_container()->SetBorder(views::Border::NullBorder()); | 50 tray_container()->SetBorder(views::Border::NullBorder()); |
| 55 | 51 |
| 56 // Pad button size to align with other controls in the system tray. | 52 // Pad button size to align with other controls in the system tray. |
| 57 const gfx::ImageSkia image = button_->GetImage( | 53 const gfx::ImageSkia image = button_->GetImage( |
| 58 views::CustomButton::STATE_NORMAL); | 54 views::CustomButton::STATE_NORMAL); |
| 59 int top_padding = (kTrayBarButtonWidth - image.height()) / 2; | 55 int top_padding = (kTrayBarButtonWidth - image.height()) / 2; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 85 | 81 |
| 86 void VirtualKeyboardTray::HideBubbleWithView( | 82 void VirtualKeyboardTray::HideBubbleWithView( |
| 87 const views::TrayBubbleView* bubble_view) { | 83 const views::TrayBubbleView* bubble_view) { |
| 88 } | 84 } |
| 89 | 85 |
| 90 bool VirtualKeyboardTray::ClickedOutsideBubble() { | 86 bool VirtualKeyboardTray::ClickedOutsideBubble() { |
| 91 return false; | 87 return false; |
| 92 } | 88 } |
| 93 | 89 |
| 94 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { | 90 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { |
| 95 keyboard::KeyboardController::GetInstance()->ShowKeyboard(true); | 91 Shell::GetInstance()->keyboard_ui()->Show(); |
| 96 return true; | 92 return true; |
| 97 } | 93 } |
| 98 | 94 |
| 99 void VirtualKeyboardTray::ButtonPressed(views::Button* sender, | 95 void VirtualKeyboardTray::ButtonPressed(views::Button* sender, |
| 100 const ui::Event& event) { | 96 const ui::Event& event) { |
| 101 DCHECK_EQ(button_, sender); | 97 DCHECK_EQ(button_, sender); |
| 102 PerformAction(event); | 98 PerformAction(event); |
| 103 } | 99 } |
| 104 | 100 |
| 105 void VirtualKeyboardTray::OnAccessibilityModeChanged( | 101 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_value) { |
| 106 ui::AccessibilityNotificationVisibility notify) { | 102 SetVisible(Shell::GetInstance()->keyboard_ui()->IsEnabled()); |
| 107 SetVisible(Shell::GetInstance()->accessibility_delegate()-> | |
| 108 IsVirtualKeyboardEnabled()); | |
| 109 } | 103 } |
| 110 | 104 |
| 111 } // namespace ash | 105 } // namespace ash |
| OLD | NEW |