Commit a160e8c5 authored by bshe@chromium.org's avatar bshe@chromium.org

Add a11y virtual keyboard icon when a11y VK is enabled

This CL adds a virtual keyboard icon when a11y VK is enabled. Click or tap on
the icon will force the VK to show and lock.

BUG=346695

Review URL: https://codereview.chromium.org/177123016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255307 0039d316-1c4b-4281-b951-d872f2087c98
parent 0e8975cb
...@@ -352,6 +352,8 @@ ...@@ -352,6 +352,8 @@
'system/chromeos/tray_display.h', 'system/chromeos/tray_display.h',
'system/chromeos/tray_tracing.cc', 'system/chromeos/tray_tracing.cc',
'system/chromeos/tray_tracing.h', 'system/chromeos/tray_tracing.h',
'system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc',
'system/chromeos/virtual_keyboard/virtual_keyboard_tray.h',
'system/date/clock_observer.h', 'system/date/clock_observer.h',
'system/date/date_default_view.cc', 'system/date/date_default_view.cc',
'system/date/date_default_view.h', 'system/date/date_default_view.h',
......
...@@ -524,6 +524,10 @@ Press Shift + Alt to switch. ...@@ -524,6 +524,10 @@ Press Shift + Alt to switch.
Previous menu Previous menu
</message> </message>
<message name="IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME" desc="The accessible text for virtual keyboard icon in status tray.">
Show on-screen keyboard
</message>
<message name="IDS_ASH_NOTIFICATION_UNREAD_COUNT_NINE_PLUS" desc="The text shown in the notification icon for the unread count when the count is more than 9."> <message name="IDS_ASH_NOTIFICATION_UNREAD_COUNT_NINE_PLUS" desc="The text shown in the notification icon for the unread count when the count is more than 9.">
9+ 9+
</message> </message>
......
...@@ -217,6 +217,7 @@ ...@@ -217,6 +217,7 @@
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_VPN" file="cros/network/statusbar_vpn_dark.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_VPN" file="cros/network/statusbar_vpn_dark.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_VPN_BADGE" file="cros/network/statusbar_network_vpn_badge.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_VPN_BADGE" file="cros/network/statusbar_network_vpn_badge.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_WIRED" file="cros/network/statusbar_wired.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_NETWORK_WIRED" file="cros/network/statusbar_wired.png" />
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD" file="cros/status/status_virtual_keyboard.png" />
</if> </if>
<structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_UPDATE" file="cros/status/status_update.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_UPDATE" file="cros/status/status_update.png" />
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
#include "ash/shell.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/system/tray/tray_constants.h"
#include "ash/system/tray/tray_utils.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/event.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/views/controls/button/image_button.h"
namespace ash {
namespace internal {
namespace {
class VirtualKeyboardButton : public views::ImageButton {
public:
VirtualKeyboardButton(views::ButtonListener* listener);
virtual ~VirtualKeyboardButton();
// Overridden from views::ImageButton:
virtual gfx::Size GetPreferredSize() OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardButton);
};
VirtualKeyboardButton::VirtualKeyboardButton(views::ButtonListener* listener)
: views::ImageButton(listener) {
}
VirtualKeyboardButton::~VirtualKeyboardButton() {
}
gfx::Size VirtualKeyboardButton::GetPreferredSize() {
const int virtual_keyboard_button_height = GetShelfItemHeight();
gfx::Size size = ImageButton::GetPreferredSize();
int padding = virtual_keyboard_button_height - size.height();
size.set_height(virtual_keyboard_button_height);
size.set_width(size.width() + padding);
return size;
}
} // namespace
VirtualKeyboardTray::VirtualKeyboardTray(StatusAreaWidget* status_area_widget)
: TrayBackgroundView(status_area_widget),
button_(NULL) {
button_ = new VirtualKeyboardButton(this);
button_->SetImage(views::CustomButton::STATE_NORMAL,
ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD));
button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
views::ImageButton::ALIGN_MIDDLE);
tray_container()->AddChildView(button_);
SetContentsBackground();
SetVisible(false);
// The Shell may not exist in some unit tests.
if (Shell::HasInstance()) {
Shell::GetInstance()->system_tray_notifier()->
AddAccessibilityObserver(this);
}
}
VirtualKeyboardTray::~VirtualKeyboardTray() {
// The Shell may not exist in some unit tests.
if (Shell::HasInstance()) {
Shell::GetInstance()->system_tray_notifier()->
RemoveAccessibilityObserver(this);
}
}
void VirtualKeyboardTray::SetShelfAlignment(ShelfAlignment alignment) {
TrayBackgroundView::SetShelfAlignment(alignment);
tray_container()->SetBorder(views::Border::NullBorder());
}
base::string16 VirtualKeyboardTray::GetAccessibleNameForTray() {
return l10n_util::GetStringUTF16(
IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME);
}
void VirtualKeyboardTray::HideBubbleWithView(
const views::TrayBubbleView* bubble_view) {
}
bool VirtualKeyboardTray::ClickedOutsideBubble() {
return false;
}
bool VirtualKeyboardTray::PerformAction(const ui::Event& event) {
Shell::GetInstance()->keyboard_controller()->ShowAndLockKeyboard();
return true;
}
void VirtualKeyboardTray::ButtonPressed(views::Button* sender,
const ui::Event& event) {
DCHECK_EQ(button_, sender);
PerformAction(event);
}
void VirtualKeyboardTray::OnAccessibilityModeChanged(
AccessibilityNotificationVisibility notify) {
SetVisible(Shell::GetInstance()->accessibility_delegate()->
IsVirtualKeyboardEnabled());
}
} // namespace internal
} // namespace ash
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_SYSTEM_CHROMEOS_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_TRAY_H_
#define ASH_SYSTEM_CHROMEOS_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_TRAY_H_
#include "ash/system/tray/tray_background_view.h"
#include "ash/system/tray_accessibility.h"
#include "ash/system/user/login_status.h"
#include "base/basictypes.h"
#include "ui/views/controls/button/button.h"
namespace views {
class ImageButton;
}
namespace ash {
namespace internal {
class StatusAreaWidget;
class VirtualKeyboardTray : public TrayBackgroundView,
public views::ButtonListener,
public AccessibilityObserver {
public:
explicit VirtualKeyboardTray(StatusAreaWidget* status_area_widget);
virtual ~VirtualKeyboardTray();
// TrayBackgroundView:
virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
virtual base::string16 GetAccessibleNameForTray() OVERRIDE;
virtual void HideBubbleWithView(
const views::TrayBubbleView* bubble_view) OVERRIDE;
virtual bool ClickedOutsideBubble() OVERRIDE;
virtual bool PerformAction(const ui::Event& event) OVERRIDE;
// views::ButtonListener:
virtual void ButtonPressed(views::Button* sender,
const ui::Event& event) OVERRIDE;
// AccessibilityObserver:
virtual void OnAccessibilityModeChanged(
AccessibilityNotificationVisibility notify) OVERRIDE;
private:
views::ImageButton* button_; // Not owned.
DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardTray);
};
} // namespace internal
} // namespace ash
#endif // ASH_SYSTEM_CHROMEOS_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_TRAY_H_
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/gfx/screen.h" #include "ui/gfx/screen.h"
#if defined(OS_CHROMEOS)
#include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
#endif
namespace ash { namespace ash {
namespace internal { namespace internal {
...@@ -32,6 +36,9 @@ StatusAreaWidget::StatusAreaWidget(aura::Window* status_container) ...@@ -32,6 +36,9 @@ StatusAreaWidget::StatusAreaWidget(aura::Window* status_container)
system_tray_(NULL), system_tray_(NULL),
web_notification_tray_(NULL), web_notification_tray_(NULL),
logout_button_tray_(NULL), logout_button_tray_(NULL),
#if defined(OS_CHROMEOS)
virtual_keyboard_tray_(NULL),
#endif
login_status_(user::LOGGED_IN_NONE) { login_status_(user::LOGGED_IN_NONE) {
views::Widget::InitParams params( views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
...@@ -51,6 +58,9 @@ void StatusAreaWidget::CreateTrayViews() { ...@@ -51,6 +58,9 @@ void StatusAreaWidget::CreateTrayViews() {
AddSystemTray(); AddSystemTray();
AddWebNotificationTray(); AddWebNotificationTray();
AddLogoutButtonTray(); AddLogoutButtonTray();
#if defined(OS_CHROMEOS)
AddVirtualKeyboardTray();
#endif
SystemTrayDelegate* delegate = SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->system_tray_delegate(); ash::Shell::GetInstance()->system_tray_delegate();
DCHECK(delegate); DCHECK(delegate);
...@@ -61,6 +71,10 @@ void StatusAreaWidget::CreateTrayViews() { ...@@ -61,6 +71,10 @@ void StatusAreaWidget::CreateTrayViews() {
web_notification_tray_->Initialize(); web_notification_tray_->Initialize();
if (logout_button_tray_) if (logout_button_tray_)
logout_button_tray_->Initialize(); logout_button_tray_->Initialize();
#if defined(OS_CHROMEOS)
if (virtual_keyboard_tray_)
virtual_keyboard_tray_->Initialize();
#endif
UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus()); UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus());
} }
...@@ -74,6 +88,10 @@ void StatusAreaWidget::Shutdown() { ...@@ -74,6 +88,10 @@ void StatusAreaWidget::Shutdown() {
web_notification_tray_ = NULL; web_notification_tray_ = NULL;
delete system_tray_; delete system_tray_;
system_tray_ = NULL; system_tray_ = NULL;
#if defined(OS_CHROMEOS)
delete virtual_keyboard_tray_;
virtual_keyboard_tray_ = NULL;
#endif
} }
bool StatusAreaWidget::ShouldShowShelf() const { bool StatusAreaWidget::ShouldShowShelf() const {
...@@ -119,6 +137,13 @@ void StatusAreaWidget::AddLogoutButtonTray() { ...@@ -119,6 +137,13 @@ void StatusAreaWidget::AddLogoutButtonTray() {
status_area_widget_delegate_->AddTray(logout_button_tray_); status_area_widget_delegate_->AddTray(logout_button_tray_);
} }
#if defined(OS_CHROMEOS)
void StatusAreaWidget::AddVirtualKeyboardTray() {
virtual_keyboard_tray_ = new VirtualKeyboardTray(this);
status_area_widget_delegate_->AddTray(virtual_keyboard_tray_);
}
#endif
void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
status_area_widget_delegate_->set_alignment(alignment); status_area_widget_delegate_->set_alignment(alignment);
if (system_tray_) if (system_tray_)
...@@ -127,6 +152,10 @@ void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) { ...@@ -127,6 +152,10 @@ void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
web_notification_tray_->SetShelfAlignment(alignment); web_notification_tray_->SetShelfAlignment(alignment);
if (logout_button_tray_) if (logout_button_tray_)
logout_button_tray_->SetShelfAlignment(alignment); logout_button_tray_->SetShelfAlignment(alignment);
#if defined(OS_CHROMEOS)
if (virtual_keyboard_tray_)
virtual_keyboard_tray_->SetShelfAlignment(alignment);
#endif
status_area_widget_delegate_->UpdateLayout(); status_area_widget_delegate_->UpdateLayout();
} }
......
...@@ -20,6 +20,9 @@ namespace internal { ...@@ -20,6 +20,9 @@ namespace internal {
class LogoutButtonTray; class LogoutButtonTray;
class StatusAreaWidgetDelegate; class StatusAreaWidgetDelegate;
#if defined(OS_CHROMEOS)
class VirtualKeyboardTray;
#endif
class ASH_EXPORT StatusAreaWidget : public views::Widget { class ASH_EXPORT StatusAreaWidget : public views::Widget {
public: public:
...@@ -71,12 +74,18 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget { ...@@ -71,12 +74,18 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
void AddSystemTray(); void AddSystemTray();
void AddWebNotificationTray(); void AddWebNotificationTray();
void AddLogoutButtonTray(); void AddLogoutButtonTray();
#if defined(OS_CHROMEOS)
void AddVirtualKeyboardTray();
#endif
// Weak pointers to View classes that are parented to StatusAreaWidget: // Weak pointers to View classes that are parented to StatusAreaWidget:
internal::StatusAreaWidgetDelegate* status_area_widget_delegate_; internal::StatusAreaWidgetDelegate* status_area_widget_delegate_;
SystemTray* system_tray_; SystemTray* system_tray_;
WebNotificationTray* web_notification_tray_; WebNotificationTray* web_notification_tray_;
LogoutButtonTray* logout_button_tray_; LogoutButtonTray* logout_button_tray_;
#if defined(OS_CHROMEOS)
VirtualKeyboardTray* virtual_keyboard_tray_;
#endif
user::LoginStatus login_status_; user::LoginStatus login_status_;
DISALLOW_COPY_AND_ASSIGN(StatusAreaWidget); DISALLOW_COPY_AND_ASSIGN(StatusAreaWidget);
......
...@@ -314,6 +314,11 @@ void KeyboardController::RemoveObserver(KeyboardControllerObserver* observer) { ...@@ -314,6 +314,11 @@ void KeyboardController::RemoveObserver(KeyboardControllerObserver* observer) {
observer_list_.RemoveObserver(observer); observer_list_.RemoveObserver(observer);
} }
void KeyboardController::ShowAndLockKeyboard() {
set_lock_keyboard(true);
OnShowImeIfNeeded();
}
void KeyboardController::OnWindowHierarchyChanged( void KeyboardController::OnWindowHierarchyChanged(
const HierarchyChangeParams& params) { const HierarchyChangeParams& params) {
if (params.new_parent && params.target == container_.get()) if (params.new_parent && params.target == container_.get())
......
...@@ -79,6 +79,9 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver, ...@@ -79,6 +79,9 @@ class KEYBOARD_EXPORT KeyboardController : public ui::InputMethodObserver,
void set_lock_keyboard(bool lock) { lock_keyboard_ = lock; } void set_lock_keyboard(bool lock) { lock_keyboard_ = lock; }
// Force the keyboard to show up if not showing and lock the keyboard.
void ShowAndLockKeyboard();
private: private:
// For access to Observer methods for simulation. // For access to Observer methods for simulation.
friend class KeyboardControllerTest; friend class KeyboardControllerTest;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment