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

Side by Side Diff: ui/views/focus/focus_manager.cc

Issue 2036193003: Fix null pointer dereference in FocusManager::ViewRemoved. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/views/focus/focus_manager.h" 5 #include "ui/views/focus/focus_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // static 510 // static
511 bool FocusManager::IsTabTraversalKeyEvent(const ui::KeyEvent& key_event) { 511 bool FocusManager::IsTabTraversalKeyEvent(const ui::KeyEvent& key_event) {
512 return key_event.key_code() == ui::VKEY_TAB && !key_event.IsControlDown(); 512 return key_event.key_code() == ui::VKEY_TAB && !key_event.IsControlDown();
513 } 513 }
514 514
515 void FocusManager::ViewRemoved(View* removed) { 515 void FocusManager::ViewRemoved(View* removed) {
516 // If the view being removed contains (or is) the focused view, 516 // If the view being removed contains (or is) the focused view,
517 // clear the focus. However, it's not safe to call ClearFocus() 517 // clear the focus. However, it's not safe to call ClearFocus()
518 // (and in turn ClearNativeFocus()) here because ViewRemoved() can 518 // (and in turn ClearNativeFocus()) here because ViewRemoved() can
519 // be called while the top level widget is being destroyed. 519 // be called while the top level widget is being destroyed.
520 if (focused_view_ && removed->Contains(focused_view_)) 520 if (focused_view_ && removed && removed->Contains(focused_view_))
sky 2016/06/06 16:30:45 This code shouldn't have to check for a null suppl
521 SetFocusedView(NULL); 521 SetFocusedView(NULL);
522 } 522 }
523 523
524 void FocusManager::AddFocusChangeListener(FocusChangeListener* listener) { 524 void FocusManager::AddFocusChangeListener(FocusChangeListener* listener) {
525 focus_change_listeners_.AddObserver(listener); 525 focus_change_listeners_.AddObserver(listener);
526 } 526 }
527 527
528 void FocusManager::RemoveFocusChangeListener(FocusChangeListener* listener) { 528 void FocusManager::RemoveFocusChangeListener(FocusChangeListener* listener) {
529 focus_change_listeners_.RemoveObserver(listener); 529 focus_change_listeners_.RemoveObserver(listener);
530 } 530 }
(...skipping 21 matching lines...) Expand all
552 // |keyboard_accessible_| is only used on Mac. 552 // |keyboard_accessible_| is only used on Mac.
553 #if defined(OS_MACOSX) 553 #if defined(OS_MACOSX)
554 return keyboard_accessible_ ? view->IsAccessibilityFocusable() 554 return keyboard_accessible_ ? view->IsAccessibilityFocusable()
555 : view->IsFocusable(); 555 : view->IsFocusable();
556 #else 556 #else
557 return view->IsAccessibilityFocusable(); 557 return view->IsAccessibilityFocusable();
558 #endif 558 #endif
559 } 559 }
560 560
561 } // namespace views 561 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698