diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-06 01:48:22 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-06 01:48:22 +0000 |
commit | 87b92695697ae44b079a9d431ffb2a9e9837a377 (patch) | |
tree | e045196c6766160d3eb6e6ac2ce01387310bef55 | |
parent | 284308e941b0781ee4817e8b1c1c2b7ece4502d0 (diff) | |
download | chromium_src-87b92695697ae44b079a9d431ffb2a9e9837a377.zip chromium_src-87b92695697ae44b079a9d431ffb2a9e9837a377.tar.gz chromium_src-87b92695697ae44b079a9d431ffb2a9e9837a377.tar.bz2 |
A reported crasher seems to indicate the ViewStorage can be NULL. I don't see how it could happen.
Just bullet-proofing the code so we don't crash.
BUG=981648
Review URL: http://codereview.chromium.org/9190
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4857 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/views/focus_manager.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/chrome/views/focus_manager.cc b/chrome/views/focus_manager.cc index 084fab5..4ea004c 100644 --- a/chrome/views/focus_manager.cc +++ b/chrome/views/focus_manager.cc @@ -590,6 +590,11 @@ void FocusManager::FocusHWND(HWND hwnd) { void FocusManager::StoreFocusedView() { ViewStorage* view_storage = ViewStorage::GetSharedInstance(); + if (!view_storage) { + // This should never happen but bug 981648 seems to indicate it could. + NOTREACHED(); + return; + } // TODO (jcampan): when a WebContents containing a popup is closed, the focus // is stored twice causing an assert. We should find a better alternative than @@ -610,6 +615,11 @@ void FocusManager::StoreFocusedView() { void FocusManager::RestoreFocusedView() { ViewStorage* view_storage = ViewStorage::GetSharedInstance(); + if (!view_storage) { + // This should never happen but bug 981648 seems to indicate it could. + NOTREACHED(); + return; + } View* view = view_storage->RetrieveView(stored_focused_view_storage_id_); if (view) { @@ -623,7 +633,13 @@ void FocusManager::RestoreFocusedView() { } void FocusManager::ClearStoredFocusedView() { - ViewStorage::GetSharedInstance()->RemoveView(stored_focused_view_storage_id_); + ViewStorage* view_storage = ViewStorage::GetSharedInstance(); + if (!view_storage) { + // This should never happen but bug 981648 seems to indicate it could. + NOTREACHED(); + return; + } + view_storage->RemoveView(stored_focused_view_storage_id_); } FocusManager* FocusManager::GetParentFocusManager() const { |