Chromium Code Reviews| 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/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.h" | 10 #include "content/browser/renderer_host/render_widget_host_view.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 | 15 |
| 16 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
| 17 // NativeTabContentsContainerGtk, public: | 17 // NativeTabContentsContainerGtk, public: |
| 18 | 18 |
| 19 NativeTabContentsContainerGtk::NativeTabContentsContainerGtk( | 19 NativeTabContentsContainerGtk::NativeTabContentsContainerGtk( |
| 20 TabContentsContainer* container) | 20 TabContentsContainer* container) |
| 21 : container_(container), | 21 : container_(container), |
| 22 focus_callback_id_(0) { | 22 focus_callback_id_(0) { |
| 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 NativeTabContentsContainerGtk::~NativeTabContentsContainerGtk() { | 29 NativeTabContentsContainerGtk::~NativeTabContentsContainerGtk() { |
| 27 } | 30 } |
| 28 | 31 |
| 29 //////////////////////////////////////////////////////////////////////////////// | 32 //////////////////////////////////////////////////////////////////////////////// |
| 30 // NativeTabContentsContainerGtk, NativeTabContentsContainer overrides: | 33 // NativeTabContentsContainerGtk, NativeTabContentsContainer overrides: |
| 31 | 34 |
| 32 void NativeTabContentsContainerGtk::AttachContents(TabContents* contents) { | 35 void NativeTabContentsContainerGtk::AttachContents(TabContents* contents) { |
| 33 Attach(contents->GetNativeView()); | 36 Attach(contents->GetNativeView()); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 // not process them, they'll be returned to us and we'll treat them as | 93 // not process them, they'll be returned to us and we'll treat them as |
| 91 // accelerators then. | 94 // accelerators then. |
| 92 return container_->tab_contents() && | 95 return container_->tab_contents() && |
| 93 !container_->tab_contents()->is_crashed(); | 96 !container_->tab_contents()->is_crashed(); |
| 94 } | 97 } |
| 95 | 98 |
| 96 views::FocusTraversable* NativeTabContentsContainerGtk::GetFocusTraversable() { | 99 views::FocusTraversable* NativeTabContentsContainerGtk::GetFocusTraversable() { |
| 97 return NULL; | 100 return NULL; |
| 98 } | 101 } |
| 99 | 102 |
| 100 bool NativeTabContentsContainerGtk::IsFocusable() const { | |
| 101 // We need to be focusable when our contents is not a view hierarchy, as | |
| 102 // clicking on the contents needs to focus us. | |
|
Ben Goodger (Google)
2011/12/15 21:21:41
Same question as the other file.
| |
| 103 return container_->tab_contents() != NULL; | |
| 104 } | |
| 105 | |
| 106 void NativeTabContentsContainerGtk::OnFocus() { | 103 void NativeTabContentsContainerGtk::OnFocus() { |
| 107 if (container_->tab_contents()) | 104 if (container_->tab_contents()) |
| 108 container_->tab_contents()->Focus(); | 105 container_->tab_contents()->Focus(); |
| 109 } | 106 } |
| 110 | 107 |
| 111 void NativeTabContentsContainerGtk::RequestFocus() { | 108 void NativeTabContentsContainerGtk::RequestFocus() { |
| 112 // This is a hack to circumvent the fact that a view does not explicitly get | 109 // This is a hack to circumvent the fact that a view does not explicitly get |
| 113 // a call to set the focus if it already has the focus. This causes a problem | 110 // a call to set the focus if it already has the focus. This causes a problem |
| 114 // with tabs such as the TabContents that instruct the RenderView that it got | 111 // with tabs such as the TabContents that instruct the RenderView that it got |
| 115 // focus when they actually get the focus. When switching from one TabContents | 112 // focus when they actually get the focus. When switching from one TabContents |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 143 } | 140 } |
| 144 | 141 |
| 145 //////////////////////////////////////////////////////////////////////////////// | 142 //////////////////////////////////////////////////////////////////////////////// |
| 146 // NativeTabContentsContainer, public: | 143 // NativeTabContentsContainer, public: |
| 147 | 144 |
| 148 // static | 145 // static |
| 149 NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer( | 146 NativeTabContentsContainer* NativeTabContentsContainer::CreateNativeContainer( |
| 150 TabContentsContainer* container) { | 147 TabContentsContainer* container) { |
| 151 return new NativeTabContentsContainerGtk(container); | 148 return new NativeTabContentsContainerGtk(container); |
| 152 } | 149 } |
| OLD | NEW |