| 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/tab_contents_view_views.h" | 5 #include "chrome/browser/ui/views/tab_contents/tab_contents_view_views.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 10 #include "chrome/browser/ui/views/sad_tab_view.h" | 12 #include "chrome/browser/ui/views/sad_tab_view.h" |
| 11 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view.h" | 13 #include "chrome/browser/ui/views/tab_contents/native_tab_contents_view.h" |
| 12 #include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h" | 14 #include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h" |
| 13 #include "content/browser/renderer_host/render_process_host.h" | 15 #include "content/browser/renderer_host/render_process_host.h" |
| 14 #include "content/browser/renderer_host/render_view_host.h" | 16 #include "content/browser/renderer_host/render_view_host.h" |
| 15 #include "content/browser/renderer_host/render_view_host_factory.h" | 17 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 16 #include "content/browser/renderer_host/render_widget_host_view.h" | 18 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 17 #include "content/browser/tab_contents/interstitial_page.h" | 19 #include "content/browser/tab_contents/interstitial_page.h" |
| 18 #include "content/browser/tab_contents/tab_contents.h" | 20 #include "content/browser/tab_contents/tab_contents.h" |
| 19 #include "content/browser/tab_contents/tab_contents_delegate.h" | 21 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 if (tab_contents_->interstitial_page()) { | 158 if (tab_contents_->interstitial_page()) { |
| 157 tab_contents_->interstitial_page()->Focus(); | 159 tab_contents_->interstitial_page()->Focus(); |
| 158 return; | 160 return; |
| 159 } | 161 } |
| 160 | 162 |
| 161 if (tab_contents_->is_crashed() && sad_tab_ != NULL) { | 163 if (tab_contents_->is_crashed() && sad_tab_ != NULL) { |
| 162 sad_tab_->RequestFocus(); | 164 sad_tab_->RequestFocus(); |
| 163 return; | 165 return; |
| 164 } | 166 } |
| 165 | 167 |
| 166 if (tab_contents_->constrained_window_count() > 0) { | 168 TabContentsWrapper* wrapper = |
| 167 ConstrainedWindow* window = *tab_contents_->constrained_window_begin(); | 169 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_); |
| 168 DCHECK(window); | 170 if (wrapper) { |
| 169 window->FocusConstrainedWindow(); | 171 // TODO(erg): TabContents used to own constrained windows, which is why |
| 170 return; | 172 // this is here. Eventually this should be ported to a containing view |
| 173 // specializing in constrained window management. |
| 174 ConstrainedWindowTabHelper* helper = |
| 175 wrapper->constrained_window_tab_helper(); |
| 176 if (helper->constrained_window_count() > 0) { |
| 177 ConstrainedWindow* window = *helper->constrained_window_begin(); |
| 178 DCHECK(window); |
| 179 window->FocusConstrainedWindow(); |
| 180 return; |
| 181 } |
| 171 } | 182 } |
| 172 | 183 |
| 173 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); | 184 RenderWidgetHostView* rwhv = tab_contents_->GetRenderWidgetHostView(); |
| 174 if (rwhv) { | 185 if (rwhv) { |
| 175 rwhv->Focus(); | 186 rwhv->Focus(); |
| 176 } else { | 187 } else { |
| 177 views::FocusManager* focus_manager = GetFocusManager(); | 188 views::FocusManager* focus_manager = GetFocusManager(); |
| 178 // TODO(oshima): There is no native view for RWHVViews. | 189 // TODO(oshima): There is no native view for RWHVViews. |
| 179 // Consider Widget::Focus(). | 190 // Consider Widget::Focus(). |
| 180 if (focus_manager) | 191 if (focus_manager) |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 } | 437 } |
| 427 | 438 |
| 428 void TabContentsViewViews::OnNativeWidgetVisibilityChanged(bool visible) { | 439 void TabContentsViewViews::OnNativeWidgetVisibilityChanged(bool visible) { |
| 429 views::Widget::OnNativeWidgetVisibilityChanged(visible); | 440 views::Widget::OnNativeWidgetVisibilityChanged(visible); |
| 430 if (visible) { | 441 if (visible) { |
| 431 tab_contents_->ShowContents(); | 442 tab_contents_->ShowContents(); |
| 432 } else { | 443 } else { |
| 433 tab_contents_->HideContents(); | 444 tab_contents_->HideContents(); |
| 434 } | 445 } |
| 435 } | 446 } |
| OLD | NEW |