| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/renderer_host/render_widget_host_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 bool RenderWidgetHostViewWin::HasFocus() { | 558 bool RenderWidgetHostViewWin::HasFocus() { |
| 559 return ::GetFocus() == m_hWnd; | 559 return ::GetFocus() == m_hWnd; |
| 560 } | 560 } |
| 561 | 561 |
| 562 void RenderWidgetHostViewWin::Show() { | 562 void RenderWidgetHostViewWin::Show() { |
| 563 DCHECK(parent_hwnd_); | 563 DCHECK(parent_hwnd_); |
| 564 DCHECK(parent_hwnd_ != GetDesktopWindow()); | 564 DCHECK(parent_hwnd_ != GetDesktopWindow()); |
| 565 SetParent(parent_hwnd_); | 565 SetParent(parent_hwnd_); |
| 566 ShowWindow(SW_SHOW); | 566 ShowWindow(SW_SHOW); |
| 567 | 567 |
| 568 // Save away our HWND in the parent window as a property so that the |
| 569 // accessibility code can find it. |
| 570 accessibility_prop_.reset(new ViewProp(GetParent(), |
| 571 kViewsNativeHostPropForAccessibility, |
| 572 m_hWnd)); |
| 573 |
| 568 DidBecomeSelected(); | 574 DidBecomeSelected(); |
| 569 } | 575 } |
| 570 | 576 |
| 571 void RenderWidgetHostViewWin::Hide() { | 577 void RenderWidgetHostViewWin::Hide() { |
| 572 if (GetParent() == GetDesktopWindow()) { | 578 if (GetParent() == GetDesktopWindow()) { |
| 573 LOG(WARNING) << "Hide() called twice in a row: " << this << ":" << | 579 LOG(WARNING) << "Hide() called twice in a row: " << this << ":" << |
| 574 parent_hwnd_ << ":" << GetParent(); | 580 parent_hwnd_ << ":" << GetParent(); |
| 575 return; | 581 return; |
| 576 } | 582 } |
| 577 | 583 |
| 584 accessibility_prop_.reset(); |
| 585 |
| 578 if (::GetFocus() == m_hWnd) | 586 if (::GetFocus() == m_hWnd) |
| 579 ::SetFocus(NULL); | 587 ::SetFocus(NULL); |
| 580 ShowWindow(SW_HIDE); | 588 ShowWindow(SW_HIDE); |
| 581 | 589 |
| 582 // Cache the old parent, then orphan the window so we stop receiving messages | 590 // Cache the old parent, then orphan the window so we stop receiving messages |
| 583 parent_hwnd_ = GetParent(); | 591 parent_hwnd_ = GetParent(); |
| 584 SetParent(NULL); | 592 SetParent(NULL); |
| 585 | 593 |
| 586 WasHidden(); | 594 WasHidden(); |
| 587 } | 595 } |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 /////////////////////////////////////////////////////////////////////////////// | 833 /////////////////////////////////////////////////////////////////////////////// |
| 826 // RenderWidgetHostViewWin, private: | 834 // RenderWidgetHostViewWin, private: |
| 827 | 835 |
| 828 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { | 836 LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) { |
| 829 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale | 837 // Call the WM_INPUTLANGCHANGE message handler to initialize the input locale |
| 830 // of a browser process. | 838 // of a browser process. |
| 831 OnInputLangChange(0, 0); | 839 OnInputLangChange(0, 0); |
| 832 // Marks that window as supporting mouse-wheel messages rerouting so it is | 840 // Marks that window as supporting mouse-wheel messages rerouting so it is |
| 833 // scrolled when under the mouse pointer even if inactive. | 841 // scrolled when under the mouse pointer even if inactive. |
| 834 props_.push_back(views::SetWindowSupportsRerouteMouseWheel(m_hWnd)); | 842 props_.push_back(views::SetWindowSupportsRerouteMouseWheel(m_hWnd)); |
| 835 // Save away our HWND in the parent window as a property so that the | |
| 836 // accessibility code can find it. | |
| 837 props_.push_back(new ViewProp(GetParent(), | |
| 838 kViewsNativeHostPropForAccessibility, | |
| 839 m_hWnd)); | |
| 840 props_.push_back(new ViewProp(m_hWnd, kRenderWidgetHostViewKey, | 843 props_.push_back(new ViewProp(m_hWnd, kRenderWidgetHostViewKey, |
| 841 static_cast<RenderWidgetHostView*>(this))); | 844 static_cast<RenderWidgetHostView*>(this))); |
| 842 return 0; | 845 return 0; |
| 843 } | 846 } |
| 844 | 847 |
| 845 void RenderWidgetHostViewWin::OnActivate(UINT action, BOOL minimized, | 848 void RenderWidgetHostViewWin::OnActivate(UINT action, BOOL minimized, |
| 846 HWND window) { | 849 HWND window) { |
| 847 // If the container is a popup, clicking elsewhere on screen should close the | 850 // If the container is a popup, clicking elsewhere on screen should close the |
| 848 // popup. | 851 // popup. |
| 849 if (close_on_deactivate_ && action == WA_INACTIVE) { | 852 if (close_on_deactivate_ && action == WA_INACTIVE) { |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1807 } | 1810 } |
| 1808 | 1811 |
| 1809 // static | 1812 // static |
| 1810 RenderWidgetHostView* | 1813 RenderWidgetHostView* |
| 1811 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1814 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
| 1812 gfx::NativeView native_view) { | 1815 gfx::NativeView native_view) { |
| 1813 return ::IsWindow(native_view) ? | 1816 return ::IsWindow(native_view) ? |
| 1814 reinterpret_cast<RenderWidgetHostView*>( | 1817 reinterpret_cast<RenderWidgetHostView*>( |
| 1815 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; | 1818 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; |
| 1816 } | 1819 } |
| OLD | NEW |