OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/views/tab_contents/native_tab_contents_container_gtk
.h" | 5 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_gtk
.h" |
6 | 6 |
7 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 7 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
8 #include "chrome/browser/tab_contents/interstitial_page.h" | 8 #include "chrome/browser/tab_contents/interstitial_page.h" |
9 #include "chrome/browser/tab_contents/tab_contents.h" | 9 #include "chrome/browser/tab_contents/tab_contents.h" |
10 #include "chrome/browser/ui/view_ids.h" | 10 #include "chrome/browser/ui/view_ids.h" |
11 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" | 11 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
12 #include "views/focus/focus_manager.h" | 12 #include "views/focus/focus_manager.h" |
13 #include "views/widget/root_view.h" | |
14 #include "views/widget/widget.h" | |
15 | 13 |
16 //////////////////////////////////////////////////////////////////////////////// | 14 //////////////////////////////////////////////////////////////////////////////// |
17 // NativeTabContentsContainerGtk, public: | 15 // NativeTabContentsContainerGtk, public: |
18 | 16 |
19 NativeTabContentsContainerGtk::NativeTabContentsContainerGtk( | 17 NativeTabContentsContainerGtk::NativeTabContentsContainerGtk( |
20 TabContentsContainer* container) | 18 TabContentsContainer* container) |
21 : container_(container), | 19 : container_(container), |
22 focus_callback_id_(0) { | 20 focus_callback_id_(0) { |
23 SetID(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 21 SetID(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); |
24 } | 22 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 103 |
106 void NativeTabContentsContainerGtk::RequestFocus() { | 104 void NativeTabContentsContainerGtk::RequestFocus() { |
107 // This is a hack to circumvent the fact that a view does not explicitly get | 105 // This is a hack to circumvent the fact that a view does not explicitly get |
108 // a call to set the focus if it already has the focus. This causes a problem | 106 // a call to set the focus if it already has the focus. This causes a problem |
109 // with tabs such as the TabContents that instruct the RenderView that it got | 107 // with tabs such as the TabContents that instruct the RenderView that it got |
110 // focus when they actually get the focus. When switching from one TabContents | 108 // focus when they actually get the focus. When switching from one TabContents |
111 // tab that has focus to another TabContents tab that had focus, since the | 109 // tab that has focus to another TabContents tab that had focus, since the |
112 // TabContentsContainerView already has focus, Focus() would not be called and | 110 // TabContentsContainerView already has focus, Focus() would not be called and |
113 // the RenderView would not get notified it got focused. | 111 // the RenderView would not get notified it got focused. |
114 // By clearing the focused view before-hand, we ensure Focus() will be called. | 112 // By clearing the focused view before-hand, we ensure Focus() will be called. |
115 GetRootView()->FocusView(NULL); | 113 views::FocusManager* focus_manager = GetFocusManager(); |
| 114 if (focus_manager) |
| 115 focus_manager->SetFocusedView(NULL); |
116 View::RequestFocus(); | 116 View::RequestFocus(); |
117 } | 117 } |
118 | 118 |
119 void NativeTabContentsContainerGtk::AboutToRequestFocusFromTabTraversal( | 119 void NativeTabContentsContainerGtk::AboutToRequestFocusFromTabTraversal( |
120 bool reverse) { | 120 bool reverse) { |
121 if (!container_->tab_contents()) | 121 if (!container_->tab_contents()) |
122 return; | 122 return; |
123 // Give an opportunity to the tab to reset its focus. | 123 // Give an opportunity to the tab to reset its focus. |
124 if (container_->tab_contents()->interstitial_page()) { | 124 if (container_->tab_contents()->interstitial_page()) { |
125 container_->tab_contents()->interstitial_page()->FocusThroughTabTraversal( | 125 container_->tab_contents()->interstitial_page()->FocusThroughTabTraversal( |
126 reverse); | 126 reverse); |
127 return; | 127 return; |
128 } | 128 } |
129 container_->tab_contents()->FocusThroughTabTraversal(reverse); | 129 container_->tab_contents()->FocusThroughTabTraversal(reverse); |
130 } | 130 } |
131 | 131 |
132 AccessibilityTypes::Role NativeTabContentsContainerGtk::GetAccessibleRole() { | 132 AccessibilityTypes::Role NativeTabContentsContainerGtk::GetAccessibleRole() { |
133 return AccessibilityTypes::ROLE_GROUPING; | 133 return AccessibilityTypes::ROLE_GROUPING; |
134 } | 134 } |
135 | 135 |
136 //////////////////////////////////////////////////////////////////////////////// | 136 //////////////////////////////////////////////////////////////////////////////// |
137 // NativeTabContentsContainer, public: | 137 // NativeTabContentsContainer, public: |
138 | 138 |
139 // static | 139 // static |
140 NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer( | 140 NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer( |
141 TabContentsContainer* container) { | 141 TabContentsContainer* container) { |
142 return new NativeTabContentsContainerGtk(container); | 142 return new NativeTabContentsContainerGtk(container); |
143 } | 143 } |
OLD | NEW |