OLD | NEW |
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/tab_contents/chrome_web_contents_view_delegate_win.h" | 5 #include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_win.h" |
6 | 6 |
7 #include "chrome/browser/browser_shutdown.h" | 7 #include "chrome/browser/browser_shutdown.h" |
8 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h" | 8 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h" |
9 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 9 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
10 #include "chrome/browser/ui/sad_tab_helper.h" | 10 #include "chrome/browser/ui/sad_tab_helper.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 void ChromeWebContentsViewDelegateWin::TakeFocus(bool reverse) { | 74 void ChromeWebContentsViewDelegateWin::TakeFocus(bool reverse) { |
75 GetFocusManager()->AdvanceFocus(reverse); | 75 GetFocusManager()->AdvanceFocus(reverse); |
76 } | 76 } |
77 | 77 |
78 void ChromeWebContentsViewDelegateWin::StoreFocus() { | 78 void ChromeWebContentsViewDelegateWin::StoreFocus() { |
79 views::ViewStorage* view_storage = views::ViewStorage::GetInstance(); | 79 views::ViewStorage* view_storage = views::ViewStorage::GetInstance(); |
80 | 80 |
81 if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL) | 81 if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL) |
82 view_storage->RemoveView(last_focused_view_storage_id_); | 82 view_storage->RemoveView(last_focused_view_storage_id_); |
83 | 83 |
| 84 if (!GetFocusManager()) |
| 85 return; |
84 views::View* focused_view = GetFocusManager()->GetFocusedView(); | 86 views::View* focused_view = GetFocusManager()->GetFocusedView(); |
85 if (focused_view) | 87 if (focused_view) |
86 view_storage->StoreView(last_focused_view_storage_id_, focused_view); | 88 view_storage->StoreView(last_focused_view_storage_id_, focused_view); |
87 } | 89 } |
88 | 90 |
89 void ChromeWebContentsViewDelegateWin::RestoreFocus() { | 91 void ChromeWebContentsViewDelegateWin::RestoreFocus() { |
90 views::ViewStorage* view_storage = views::ViewStorage::GetInstance(); | 92 views::ViewStorage* view_storage = views::ViewStorage::GetInstance(); |
91 views::View* last_focused_view = | 93 views::View* last_focused_view = |
92 view_storage->RetrieveView(last_focused_view_storage_id_); | 94 view_storage->RetrieveView(last_focused_view_storage_id_); |
93 | 95 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 return toplevel_widget ? toplevel_widget->GetFocusManager() : NULL; | 155 return toplevel_widget ? toplevel_widget->GetFocusManager() : NULL; |
154 } | 156 } |
155 | 157 |
156 void ChromeWebContentsViewDelegateWin::SetInitialFocus() { | 158 void ChromeWebContentsViewDelegateWin::SetInitialFocus() { |
157 if (web_contents_->FocusLocationBarByDefault()) { | 159 if (web_contents_->FocusLocationBarByDefault()) { |
158 web_contents_->SetFocusToLocationBar(false); | 160 web_contents_->SetFocusToLocationBar(false); |
159 } else { | 161 } else { |
160 web_contents_->GetView()->Focus(); | 162 web_contents_->GetView()->Focus(); |
161 } | 163 } |
162 } | 164 } |
OLD | NEW |