| 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/ui/views/external_tab_container_win.h" | 5 #include "chrome/browser/ui/views/external_tab_container_win.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlapp.h> | 8 #include <atlapp.h> |
| 9 #include <atlconv.h> | 9 #include <atlconv.h> |
| 10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 }; | 279 }; |
| 280 | 280 |
| 281 // A specialization of DesktopRootWindowHost for an external tab container that | 281 // A specialization of DesktopRootWindowHost for an external tab container that |
| 282 // saves and restores focus as the ETC is blurred and focused. DRWHW ordinarily | 282 // saves and restores focus as the ETC is blurred and focused. DRWHW ordinarily |
| 283 // does this during window activation and deactivation. Since the ETC is a child | 283 // does this during window activation and deactivation. Since the ETC is a child |
| 284 // window, it does not receive activation messages. | 284 // window, it does not receive activation messages. |
| 285 class ExternalTabRootWindowHost : public views::DesktopRootWindowHostWin { | 285 class ExternalTabRootWindowHost : public views::DesktopRootWindowHostWin { |
| 286 public: | 286 public: |
| 287 ExternalTabRootWindowHost( | 287 ExternalTabRootWindowHost( |
| 288 views::internal::NativeWidgetDelegate* native_widget_delegate, | 288 views::internal::NativeWidgetDelegate* native_widget_delegate, |
| 289 views::DesktopNativeWidgetAura* desktop_native_widget_aura, | 289 views::DesktopNativeWidgetAura* desktop_native_widget_aura) |
| 290 const gfx::Rect& initial_bounds) | |
| 291 : views::DesktopRootWindowHostWin(native_widget_delegate, | 290 : views::DesktopRootWindowHostWin(native_widget_delegate, |
| 292 desktop_native_widget_aura, | 291 desktop_native_widget_aura) {} |
| 293 initial_bounds) {} | |
| 294 | 292 |
| 295 protected: | 293 protected: |
| 296 // HWNDMessageHandlerDelegate methods: | 294 // HWNDMessageHandlerDelegate methods: |
| 297 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE { | 295 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE { |
| 298 views::DesktopRootWindowHostWin::HandleNativeFocus(last_focused_window); | 296 views::DesktopRootWindowHostWin::HandleNativeFocus(last_focused_window); |
| 299 RestoreFocusOnActivate(); | 297 RestoreFocusOnActivate(); |
| 300 } | 298 } |
| 301 | 299 |
| 302 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE { | 300 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE { |
| 303 SaveFocusOnDeactivate(); | 301 SaveFocusOnDeactivate(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 #if defined(USE_AURA) | 376 #if defined(USE_AURA) |
| 379 // Create the window that sits between the parent (most likely a | 377 // Create the window that sits between the parent (most likely a |
| 380 // ChromeFrameAutomationClient) and the DesktopRootWindowHostWin. | 378 // ChromeFrameAutomationClient) and the DesktopRootWindowHostWin. |
| 381 tab_container_window_ = | 379 tab_container_window_ = |
| 382 (new ContainerWindow(HWND_DESKTOP, params.bounds))->AsWeakPtr(); | 380 (new ContainerWindow(HWND_DESKTOP, params.bounds))->AsWeakPtr(); |
| 383 | 381 |
| 384 views::DesktopNativeWidgetAura* native_widget = | 382 views::DesktopNativeWidgetAura* native_widget = |
| 385 new views::DesktopNativeWidgetAura(widget_); | 383 new views::DesktopNativeWidgetAura(widget_); |
| 386 params.native_widget = native_widget; | 384 params.native_widget = native_widget; |
| 387 params.desktop_root_window_host = | 385 params.desktop_root_window_host = |
| 388 new ExternalTabRootWindowHost(widget_, native_widget, params.bounds); | 386 new ExternalTabRootWindowHost(widget_, native_widget); |
| 389 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; | 387 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; |
| 390 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; | 388 params.opacity = views::Widget::InitParams::OPAQUE_WINDOW; |
| 391 #endif | 389 #endif |
| 392 widget_->Init(params); | 390 widget_->Init(params); |
| 393 | 391 |
| 394 #if defined(USE_AURA) | 392 #if defined(USE_AURA) |
| 395 tab_container_window_->SetWidget(widget_); | 393 tab_container_window_->SetWidget(widget_); |
| 396 #endif | 394 #endif |
| 397 | 395 |
| 398 // TODO(jcampan): limit focus traversal to contents. | 396 // TODO(jcampan): limit focus traversal to contents. |
| (...skipping 1091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1490 if (params.disposition == CURRENT_TAB) { | 1488 if (params.disposition == CURRENT_TAB) { |
| 1491 DCHECK(route_all_top_level_navigations_); | 1489 DCHECK(route_all_top_level_navigations_); |
| 1492 forward_params.disposition = NEW_FOREGROUND_TAB; | 1490 forward_params.disposition = NEW_FOREGROUND_TAB; |
| 1493 } | 1491 } |
| 1494 WebContents* new_contents = | 1492 WebContents* new_contents = |
| 1495 ExternalTabContainerWin::OpenURLFromTab(source, forward_params); | 1493 ExternalTabContainerWin::OpenURLFromTab(source, forward_params); |
| 1496 // support only one navigation for a dummy tab before it is killed. | 1494 // support only one navigation for a dummy tab before it is killed. |
| 1497 widget_->CloseNow(); | 1495 widget_->CloseNow(); |
| 1498 return new_contents; | 1496 return new_contents; |
| 1499 } | 1497 } |
| OLD | NEW |