| 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_win
.h" | 5 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_container_win
.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/view_ids.h" | 7 #include "chrome/browser/ui/view_ids.h" |
| 8 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" | 8 #include "chrome/browser/ui/views/tab_contents/tab_contents_container.h" |
| 9 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" | 9 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" |
| 10 #include "content/browser/renderer_host/render_widget_host_view_win.h" | 10 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
| 11 #include "content/browser/tab_contents/interstitial_page.h" | 11 #include "content/browser/tab_contents/interstitial_page.h" |
| 12 #include "content/browser/tab_contents/tab_contents.h" | 12 #include "content/browser/tab_contents/tab_contents.h" |
| 13 #include "ui/base/accessibility/accessible_view_state.h" | 13 #include "ui/base/accessibility/accessible_view_state.h" |
| 14 #include "ui/views/focus/focus_manager.h" | 14 #include "ui/views/focus/focus_manager.h" |
| 15 #include "ui/views/focus/widget_focus_manager.h" | 15 #include "ui/views/focus/widget_focus_manager.h" |
| 16 | 16 |
| 17 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
| 18 // NativeTabContentsContainerWin, public: | 18 // NativeTabContentsContainerWin, public: |
| 19 | 19 |
| 20 NativeTabContentsContainerWin::NativeTabContentsContainerWin( | 20 NativeTabContentsContainerWin::NativeTabContentsContainerWin( |
| 21 TabContentsContainer* container) | 21 TabContentsContainer* container) |
| 22 : container_(container) { | 22 : container_(container) { |
| 23 set_id(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); | 23 set_id(VIEW_ID_TAB_CONTAINER_FOCUS_VIEW); |
| 24 // We need to be focusable when our contents is not a view hierarchy, as |
| 25 // clicking on the contents needs to focus us. |
| 26 set_focusable(container_->tab_contents() != NULL); |
| 24 } | 27 } |
| 25 | 28 |
| 26 NativeTabContentsContainerWin::~NativeTabContentsContainerWin() { | 29 NativeTabContentsContainerWin::~NativeTabContentsContainerWin() { |
| 27 } | 30 } |
| 28 | 31 |
| 29 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
| 30 // NativeTabContentsContainerWin, NativeTabContentsContainer overrides: | 33 // NativeTabContentsContainerWin, NativeTabContentsContainer overrides: |
| 31 | 34 |
| 32 void NativeTabContentsContainerWin::AttachContents(TabContents* contents) { | 35 void NativeTabContentsContainerWin::AttachContents(TabContents* contents) { |
| 33 // We need to register the tab contents window with the BrowserContainer so | 36 // We need to register the tab contents window with the BrowserContainer so |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 const views::KeyEvent& e) { | 101 const views::KeyEvent& e) { |
| 99 // Don't look-up accelerators or tab-traversal if we are showing a non-crashed | 102 // Don't look-up accelerators or tab-traversal if we are showing a non-crashed |
| 100 // TabContents. | 103 // TabContents. |
| 101 // We'll first give the page a chance to process the key events. If it does | 104 // We'll first give the page a chance to process the key events. If it does |
| 102 // not process them, they'll be returned to us and we'll treat them as | 105 // not process them, they'll be returned to us and we'll treat them as |
| 103 // accelerators then. | 106 // accelerators then. |
| 104 return container_->tab_contents() && | 107 return container_->tab_contents() && |
| 105 !container_->tab_contents()->is_crashed(); | 108 !container_->tab_contents()->is_crashed(); |
| 106 } | 109 } |
| 107 | 110 |
| 108 bool NativeTabContentsContainerWin::IsFocusable() const { | |
| 109 // We need to be focusable when our contents is not a view hierarchy, as | |
| 110 // clicking on the contents needs to focus us. | |
| 111 return container_->tab_contents() != NULL; | |
| 112 } | |
| 113 | |
| 114 void NativeTabContentsContainerWin::OnFocus() { | 111 void NativeTabContentsContainerWin::OnFocus() { |
| 115 if (container_->tab_contents()) | 112 if (container_->tab_contents()) |
| 116 container_->tab_contents()->Focus(); | 113 container_->tab_contents()->Focus(); |
| 117 } | 114 } |
| 118 | 115 |
| 119 void NativeTabContentsContainerWin::RequestFocus() { | 116 void NativeTabContentsContainerWin::RequestFocus() { |
| 120 // This is a hack to circumvent the fact that a the OnFocus() method is not | 117 // This is a hack to circumvent the fact that a the OnFocus() method is not |
| 121 // invoked when RequestFocus() is called on an already focused view. | 118 // invoked when RequestFocus() is called on an already focused view. |
| 122 // The TabContentsContainer is the view focused when the TabContents has | 119 // The TabContentsContainer is the view focused when the TabContents has |
| 123 // focus. When switching between from one tab that has focus to another tab | 120 // focus. When switching between from one tab that has focus to another tab |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 156 } |
| 160 | 157 |
| 161 //////////////////////////////////////////////////////////////////////////////// | 158 //////////////////////////////////////////////////////////////////////////////// |
| 162 // NativeTabContentsContainer, public: | 159 // NativeTabContentsContainer, public: |
| 163 | 160 |
| 164 // static | 161 // static |
| 165 NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer( | 162 NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer( |
| 166 TabContentsContainer* container) { | 163 TabContentsContainer* container) { |
| 167 return new NativeTabContentsContainerWin(container); | 164 return new NativeTabContentsContainerWin(container); |
| 168 } | 165 } |
| OLD | NEW |