Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2779)

Unified Diff: ash/system/tray/system_tray.cc

Issue 2897553002: Do not activate TrayBubbleView by default (Closed)
Patch Set: Remove unnecessary code. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/system_tray.cc
diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc
index 66ca2527aa0a3fcbdf222f0f1912912471c14af7..d129fba629f271ca16bda49ec0d24a31ae84667f 100644
--- a/ash/system/tray/system_tray.cc
+++ b/ash/system/tray/system_tray.cc
@@ -8,6 +8,7 @@
#include <map>
#include <vector>
+#include "ash/accelerators/accelerator_controller.h"
#include "ash/key_event_watcher.h"
#include "ash/login_status.h"
#include "ash/public/cpp/config.h"
@@ -118,19 +119,14 @@ class SystemBubbleWrapper {
TrayBubbleView::InitParams* init_params,
bool is_persistent) {
DCHECK(anchor);
+
+ is_persistent_ = is_persistent;
+
const LoginStatus login_status =
Shell::Get()->session_controller()->login_status();
bubble_->InitView(anchor, login_status, init_params);
bubble_->bubble_view()->set_anchor_view_insets(anchor_insets);
bubble_wrapper_.reset(new TrayBubbleWrapper(tray, bubble_->bubble_view()));
- is_persistent_ = is_persistent;
-
- // If ChromeVox is enabled, focus the default item if no item is focused and
- // there isn't a delayed close.
- if (Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled() &&
- !is_persistent) {
- bubble_->FocusDefaultIfNeeded();
- }
}
// Convenience accessors:
@@ -210,7 +206,6 @@ SystemTray::SystemTray(Shelf* shelf) : TrayBackgroundView(shelf) {
SystemTray::~SystemTray() {
// Destroy any child views that might have back pointers before ~View().
activation_observer_.reset();
- key_event_watcher_.reset();
system_bubble_.reset();
for (const auto& item : items_)
item->OnTrayViewDestroyed();
@@ -437,9 +432,6 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
if (system_bubble_.get() && creation_type == BUBBLE_USE_EXISTING) {
system_bubble_->bubble()->UpdateView(items, bubble_type);
- // If ChromeVox is enabled, focus the default item if no item is focused.
- if (Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled())
- system_bubble_->bubble()->FocusDefaultIfNeeded();
} else {
// Cleanup the existing bubble before showing a new one. Otherwise, it's
// possible to confuse the new system bubble with the old one during
@@ -457,8 +449,6 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
init_params.anchor_alignment = GetAnchorAlignment();
init_params.min_width = kTrayMenuMinimumWidth;
init_params.max_width = kTrayPopupMaxWidth;
- // TODO(oshima): Change TrayBubbleView itself.
- init_params.can_activate = false;
// The bubble is not initially activatable, but will become activatable if
// the user presses Tab. For behavioral consistency with the non-activatable
// scenario, don't close on deactivation after Tab either.
@@ -487,10 +477,6 @@ void SystemTray::ShowItems(const std::vector<SystemTrayItem*>& items,
if (!detailed)
default_bubble_height_ = system_bubble_->bubble_view()->height();
- key_event_watcher_.reset();
- if (can_activate)
- CreateKeyEventWatcher();
-
if (detailed && items.size() > 0)
detailed_item_ = items[0];
else
@@ -581,10 +567,30 @@ void SystemTray::OnMouseExitedView() {
system_bubble_->bubble()->RestartAutoCloseTimer();
}
+void SystemTray::RegisterAccelerators(
+ const std::vector<ui::Accelerator>& accelerators,
+ views::TrayBubbleView* tray_bubble_view) {
+ Shell::Get()->accelerator_controller()->Register(accelerators,
+ tray_bubble_view);
+}
+
+void SystemTray::UnregisterAllAccelerators(
+ views::TrayBubbleView* tray_bubble_view) {
+ Shell::Get()->accelerator_controller()->UnregisterAll(tray_bubble_view);
+}
+
base::string16 SystemTray::GetAccessibleNameForBubble() {
return GetAccessibleNameForTray();
}
+bool SystemTray::ShouldEnableExtraKeyboardAccessibility() {
+ // Do not enable extra keyboard accessibility for persistent system bubble.
dmazzoni 2017/06/20 16:32:54 Maybe the comment should mention spoken feedback?
yawano 2017/06/21 01:20:04 No, we don't enable extra keyboard accessibility f
+ // e.g. volume slider. Persistent system bubble is a bubble which is not
+ // closed even if user clicks outside of the bubble.
+ return system_bubble_ && !system_bubble_->is_persistent() &&
+ Shell::Get()->accessibility_delegate()->IsSpokenFeedbackEnabled();
+}
+
void SystemTray::HideBubble(const TrayBubbleView* bubble_view) {
HideBubbleWithView(bubble_view);
}
@@ -602,24 +608,6 @@ void SystemTray::ActivateAndStartNavigation(const ui::KeyEvent& key_event) {
widget->GetFocusManager()->OnKeyEvent(key_event);
}
-void SystemTray::CreateKeyEventWatcher() {
- key_event_watcher_ = ShellPort::Get()->CreateKeyEventWatcher();
- // mustash does not yet support KeyEventWatcher. http://crbug.com/649600.
- if (!key_event_watcher_)
- return;
- key_event_watcher_->AddKeyEventCallback(
- ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE),
- base::Bind(&SystemTray::CloseBubble, base::Unretained(this)));
- key_event_watcher_->AddKeyEventCallback(
- ui::Accelerator(ui::VKEY_TAB, ui::EF_NONE),
- base::Bind(&SystemTray::ActivateAndStartNavigation,
- base::Unretained(this)));
- key_event_watcher_->AddKeyEventCallback(
- ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN),
- base::Bind(&SystemTray::ActivateAndStartNavigation,
- base::Unretained(this)));
-}
-
void SystemTray::ActivateBubble() {
TrayBubbleView* bubble_view = GetSystemBubble()->bubble_view();
// If system tray bubble is in the process of closing, do not try to activate
@@ -647,7 +635,6 @@ bool SystemTray::PerformAction(const ui::Event& event) {
void SystemTray::CloseSystemBubbleAndDeactivateSystemTray() {
activation_observer_.reset();
- key_event_watcher_.reset();
system_bubble_.reset();
// When closing a system bubble with the alternate shelf layout, we need to
// turn off the active tinting of the shelf.
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698