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

Side by Side Diff: chrome/browser/chromeos/login/webui_login_view.cc

Issue 14827004: cros: Arrow key traversal in views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/login/webui_login_view.h" 5 #include "chrome/browser/chromeos/login/webui_login_view.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray.h" 8 #include "ash/system/tray/system_tray.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 gfx::Size preferred_size = child->GetPreferredSize(); 101 gfx::Size preferred_size = child->GetPreferredSize();
102 child->SetBounds(width() - preferred_size.width(), 102 child->SetBounds(width() - preferred_size.width(),
103 0, preferred_size.width(), preferred_size.height()); 103 0, preferred_size.width(), preferred_size.height());
104 } 104 }
105 } 105 }
106 106
107 void RightAlignedView::ChildPreferredSizeChanged(View* child) { 107 void RightAlignedView::ChildPreferredSizeChanged(View* child) {
108 Layout(); 108 Layout();
109 } 109 }
110 110
111 // A class to change arrow key traversal behavior when it's alive.
112 class ScopedArrowKeyTraversal {
113 public:
114 explicit ScopedArrowKeyTraversal(bool new_arrow_key_tranversal_enabled)
115 : previous_arrow_key_traversal_enabled_(
116 views::FocusManager::arrow_key_traversal_enabled()) {
117 views::FocusManager::set_arrow_key_traversal_enabled(
118 new_arrow_key_tranversal_enabled);
119 }
120 ~ScopedArrowKeyTraversal() {
121 views::FocusManager::set_arrow_key_traversal_enabled(
122 previous_arrow_key_traversal_enabled_);
123 }
124
125 private:
126 const bool previous_arrow_key_traversal_enabled_;
127 DISALLOW_COPY_AND_ASSIGN(ScopedArrowKeyTraversal);
128 };
129
111 } // namespace 130 } // namespace
112 131
113 namespace chromeos { 132 namespace chromeos {
114 133
115 // static 134 // static
116 const char WebUILoginView::kViewClassName[] = 135 const char WebUILoginView::kViewClassName[] =
117 "browser/chromeos/login/WebUILoginView"; 136 "browser/chromeos/login/WebUILoginView";
118 137
119 // WebUILoginView public: ------------------------------------------------------ 138 // WebUILoginView public: ------------------------------------------------------
120 139
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 #ifndef NDEBUG 340 #ifndef NDEBUG
322 return false; 341 return false;
323 #else 342 #else
324 return true; 343 return true;
325 #endif 344 #endif
326 } 345 }
327 346
328 void WebUILoginView::HandleKeyboardEvent(content::WebContents* source, 347 void WebUILoginView::HandleKeyboardEvent(content::WebContents* source,
329 const NativeWebKeyboardEvent& event) { 348 const NativeWebKeyboardEvent& event) {
330 if (forward_keyboard_event_) { 349 if (forward_keyboard_event_) {
350 // Disable arrow key traversal because arrow keys are handled via
351 // accelerator when this view has focus.
352 ScopedArrowKeyTraversal arrow_key_traversal(false);
353
331 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event, 354 unhandled_keyboard_event_handler_.HandleKeyboardEvent(event,
332 GetFocusManager()); 355 GetFocusManager());
333 } 356 }
334 357
335 // Make sure error bubble is cleared on keyboard event. This is needed 358 // Make sure error bubble is cleared on keyboard event. This is needed
336 // when the focus is inside an iframe. Only clear on KeyDown to prevent hiding 359 // when the focus is inside an iframe. Only clear on KeyDown to prevent hiding
337 // an immediate authentication error (See crbug.com/103643). 360 // an immediate authentication error (See crbug.com/103643).
338 if (event.type == WebKit::WebInputEvent::KeyDown) { 361 if (event.type == WebKit::WebInputEvent::KeyDown) {
339 content::WebUI* web_ui = GetWebUI(); 362 content::WebUI* web_ui = GetWebUI();
340 if (web_ui) 363 if (web_ui)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 aura::Env::GetInstance()->set_render_white_bg(true); 412 aura::Env::GetInstance()->set_render_white_bg(true);
390 } 413 }
391 414
392 void WebUILoginView::ReturnFocus(bool reverse) { 415 void WebUILoginView::ReturnFocus(bool reverse) {
393 // Return the focus to the web contents. 416 // Return the focus to the web contents.
394 webui_login_->web_contents()->FocusThroughTabTraversal(reverse); 417 webui_login_->web_contents()->FocusThroughTabTraversal(reverse);
395 GetWidget()->Activate(); 418 GetWidget()->Activate();
396 } 419 }
397 420
398 } // namespace chromeos 421 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698