From 672eca0fd191acd39c28430d1ed1f327594faff8 Mon Sep 17 00:00:00 2001
From: "levin@chromium.org"
 <levin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>
Date: Fri, 14 Aug 2009 03:00:30 +0000
Subject: Reverting 23406.

It seems that Tab2OutOfTabStrip is failing consistently after this change.

BUG=None
TEST=None
TBR=jhawkins@chromium.org

Review URL: http://codereview.chromium.org/164543

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23411 0039d316-1c4b-4281-b951-d872f2087c98
---
 base/window_impl.cc                                | 18 ++++--
 base/window_impl.h                                 | 34 ++++------
 .../views/tab_contents/tab_contents_view_win.cc    |  2 +-
 views/widget/widget_win.cc                         | 66 +++++++++----------
 webkit/default_plugin/default_plugin.gyp           |  1 -
 webkit/default_plugin/plugin_impl_win.cc           | 75 +++++++++++-----------
 webkit/default_plugin/plugin_impl_win.h            | 10 +--
 webkit/tools/test_shell/foreground_helper.h        | 12 ++--
 webkit/webkit.gyp                                  |  3 -
 9 files changed, 110 insertions(+), 111 deletions(-)

diff --git a/base/window_impl.cc b/base/window_impl.cc
index c3b3ad4..4a37f7b 100644
--- a/base/window_impl.cc
+++ b/base/window_impl.cc
@@ -96,7 +96,7 @@ class ClassRegistrar {
   typedef std::list<RegisteredClass> RegisteredClasses;
   RegisteredClasses registered_classes_;
 
-  // Counter of how many classes have been registered so far.
+  // Counter of how many classes have ben registered so far.
   int registered_count_;
 
   DISALLOW_COPY_AND_ASSIGN(ClassRegistrar);
@@ -136,7 +136,7 @@ void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) {
     height = bounds.height();
   }
 
-  hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), NULL,
+  hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), L"",
                          window_style_, x, y, width, height,
                          parent, NULL, NULL, this);
   DCHECK(hwnd_);
@@ -145,17 +145,27 @@ void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) {
   DCHECK(win_util::GetWindowUserData(hwnd_) == this);
 }
 
+gfx::NativeView WindowImpl::GetNativeView() const {
+  return hwnd_;
+}
+
 HICON WindowImpl::GetDefaultWindowIcon() const {
   return NULL;
 }
 
+BOOL WindowImpl::DestroyWindow() {
+  DCHECK(::IsWindow(GetNativeView()));
+  return ::DestroyWindow(GetNativeView());
+}
+
 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) {
+  HWND window = GetNativeView();
   LRESULT result = 0;
 
   // Handle the message if it's in our message map; otherwise, let the system
   // handle it.
-  if (!ProcessWindowMessage(hwnd_, message, w_param, l_param, result))
-    result = DefWindowProc(hwnd_, message, w_param, l_param);
+  if (!ProcessWindowMessage(window, message, w_param, l_param, result))
+    result = DefWindowProc(window, message, w_param, l_param);
 
   return result;
 }
diff --git a/base/window_impl.h b/base/window_impl.h
index 2941c3d9..30c6298 100644
--- a/base/window_impl.h
+++ b/base/window_impl.h
@@ -18,19 +18,6 @@
 
 namespace base {
 
-// An interface implemented by classes that use message maps.
-// ProcessWindowMessage is implemented by the BEGIN_MESSAGE_MAP_EX macro.
-class MessageMapInterface {
- public:
-  // Processes one message from the window's message queue.
-  virtual BOOL ProcessWindowMessage(HWND window,
-                                    UINT message,
-                                    WPARAM w_param,
-                                    LPARAM l_param,
-                                    LRESULT& result,
-                                    DWORD msg_mad_id = 0) = 0;
-};
-
 ///////////////////////////////////////////////////////////////////////////////
 //
 // WindowImpl
@@ -39,20 +26,24 @@ class MessageMapInterface {
 //  Windows.
 //
 ///////////////////////////////////////////////////////////////////////////////
-class WindowImpl : public MessageMapInterface {
+class WindowImpl {
  public:
   WindowImpl();
   virtual ~WindowImpl();
 
-  // Initializes the Window with a parent and an initial desired size.
-  void Init(HWND parent, const gfx::Rect& bounds);
+  BEGIN_MSG_MAP_EX(WindowImpl)
+    // No messages to handle
+  END_MSG_MAP()
+
+  // Initialize the Window with a parent and an initial desired size.
+  virtual void Init(HWND parent, const gfx::Rect& bounds);
+
+  // Returns the gfx::NativeView associated with this Window.
+  virtual gfx::NativeView GetNativeView() const;
 
   // Retrieves the default window icon to use for windows if none is specified.
   virtual HICON GetDefaultWindowIcon() const;
 
-  // Returns the HWND associated with this Window.
-  HWND hwnd() const { return hwnd_; }
-
   // Sets the window styles. This is ONLY used when the window is created.
   // In other words, if you invoke this after invoking Init, nothing happens.
   void set_window_style(DWORD style) { window_style_ = style; }
@@ -71,13 +62,16 @@ class WindowImpl : public MessageMapInterface {
   UINT initial_class_style() { return class_style_; }
 
  protected:
+  // Call close instead of this to Destroy the window.
+  BOOL DestroyWindow();
+
   // Handles the WndProc callback for this object.
   virtual LRESULT OnWndProc(UINT message, WPARAM w_param, LPARAM l_param);
 
  private:
   friend class ClassRegistrar;
 
-  // The window procedure used by all Windows.
+  // The windows procedure used by all Windows.
   static LRESULT CALLBACK WndProc(HWND window,
                                   UINT message,
                                   WPARAM w_param,
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
index 2c5786b..47a73e3 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -247,7 +247,7 @@ void TabContentsViewWin::OnTabCrashed() {
   // paint.
   // Note that it's possible to get this message after the window was destroyed.
   if (::IsWindow(GetNativeView()))
-    ::InvalidateRect(GetNativeView(), NULL, FALSE);
+    InvalidateRect(GetNativeView(), NULL, FALSE);
 }
 
 void TabContentsViewWin::SizeContents(const gfx::Size& size) {
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index f54da9a..f431fc7 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -27,7 +27,7 @@ namespace views {
 static const wchar_t* const kRootViewWindowProperty = L"__ROOT_VIEW__";
 
 bool SetRootViewForHWND(HWND hwnd, RootView* root_view) {
-  return SetProp(hwnd, kRootViewWindowProperty, root_view) ? true : false;
+  return ::SetProp(hwnd, kRootViewWindowProperty, root_view) ? true : false;
 }
 
 RootView* GetRootViewForHWND(HWND hwnd) {
@@ -36,7 +36,7 @@ RootView* GetRootViewForHWND(HWND hwnd) {
 
 NativeControlWin* GetNativeControlWinForHWND(HWND hwnd) {
   return reinterpret_cast<NativeControlWin*>(
-      GetProp(hwnd, NativeControlWin::kNativeControlWinKey));
+      ::GetProp(hwnd, NativeControlWin::kNativeControlWinKey));
 }
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -77,7 +77,7 @@ void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
 
   default_theme_provider_.reset(new DefaultThemeProvider());
 
-  SetWindowSupportsRerouteMouseWheel(hwnd());
+  SetWindowSupportsRerouteMouseWheel(GetNativeView());
 
   drop_target_ = new DropTargetWin(root_view_.get());
 
@@ -87,7 +87,7 @@ void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
   }
 
   // Sets the RootView as a property, so the automation can introspect windows.
-  SetRootViewForHWND(hwnd(), root_view_.get());
+  SetRootViewForHWND(GetNativeView(), root_view_.get());
 
   MessageLoopForUI::current()->AddObserver(this);
 
@@ -102,14 +102,14 @@ void WidgetWin::Init(gfx::NativeView parent, const gfx::Rect& bounds) {
 
   // This message initializes the window so that focus border are shown for
   // windows.
-  SendMessage(hwnd(),
-              WM_CHANGEUISTATE,
-              MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS),
-              0);
+  ::SendMessage(GetNativeView(),
+                WM_CHANGEUISTATE,
+                MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS),
+                0);
 
   // Bug 964884: detach the IME attached to this window.
   // We should attach IMEs only when we need to input CJK strings.
-  ImmAssociateContextEx(hwnd(), NULL, 0);
+  ::ImmAssociateContextEx(GetNativeView(), NULL, 0);
 }
 
 void WidgetWin::SetContentsView(View* view) {
@@ -126,7 +126,7 @@ void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const {
 
   GetClientRect(&crect);
   POINT p = {0, 0};
-  ClientToScreen(hwnd(), &p);
+  ::ClientToScreen(GetNativeView(), &p);
   out->SetRect(crect.left + p.x, crect.top + p.y,
                crect.Width(), crect.Height());
 }
@@ -164,7 +164,7 @@ void WidgetWin::CloseNow() {
   // we need to check to see if we're still a window before trying to destroy
   // ourself.
   if (IsWindow())
-    DestroyWindow(hwnd());
+    DestroyWindow();
 }
 
 void WidgetWin::Show() {
@@ -185,7 +185,7 @@ void WidgetWin::Hide() {
 }
 
 gfx::NativeView WidgetWin::GetNativeView() const {
-  return WindowImpl::hwnd();
+  return WindowImpl::GetNativeView();
 }
 
 static BOOL CALLBACK EnumChildProcForRedraw(HWND hwnd, LPARAM lparam) {
@@ -212,10 +212,10 @@ void WidgetWin::PaintNow(const gfx::Rect& update_rect) {
       // We're transparent. Need to force painting to occur from our parent.
       CRect parent_update_rect = update_rect.ToRECT();
       POINT location_in_parent = { 0, 0 };
-      ClientToScreen(hwnd(), &location_in_parent);
-      ScreenToClient(GetParent(), &location_in_parent);
+      ClientToScreen(GetNativeView(), &location_in_parent);
+      ::ScreenToClient(GetParent(), &location_in_parent);
       parent_update_rect.OffsetRect(location_in_parent);
-      RedrawWindow(GetParent(), parent_update_rect, NULL,
+      ::RedrawWindow(GetParent(), parent_update_rect, NULL,
                      RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN);
     } else {
       // Paint child windows that are in a different process asynchronously.
@@ -230,11 +230,11 @@ void WidgetWin::PaintNow(const gfx::Rect& update_rect) {
       gfx::Rect invalid_screen_rect = update_rect;
       invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y());
 
-      RedrawWindow(hwnd(), &update_rect.ToRECT(), NULL,
-                   RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
+      ::RedrawWindow(GetNativeView(), &update_rect.ToRECT(), NULL,
+                     RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
 
       LPARAM lparam = reinterpret_cast<LPARAM>(&invalid_screen_rect);
-      EnumChildWindows(hwnd(), EnumChildProcForRedraw, lparam);
+      EnumChildWindows(GetNativeView(), EnumChildProcForRedraw, lparam);
     }
     // As we were created with a style of WS_CLIPCHILDREN redraw requests may
     // result in an empty paint rect in WM_PAINT (this'll happen if a
@@ -261,15 +261,15 @@ RootView* WidgetWin::GetRootView() {
 
 Widget* WidgetWin::GetRootWidget() const {
   return reinterpret_cast<WidgetWin*>(
-      win_util::GetWindowUserData(GetAncestor(hwnd(), GA_ROOT)));
+      win_util::GetWindowUserData(GetAncestor(GetNativeView(), GA_ROOT)));
 }
 
 bool WidgetWin::IsVisible() const {
-  return !!::IsWindowVisible(hwnd());
+  return !!::IsWindowVisible(GetNativeView());
 }
 
 bool WidgetWin::IsActive() const {
-  return win_util::IsWindowActive(hwnd());
+  return win_util::IsWindowActive(GetNativeView());
 }
 
 void WidgetWin::GenerateMousePressedForView(View* view,
@@ -301,11 +301,11 @@ ThemeProvider* WidgetWin::GetThemeProvider() const {
 }
 
 Window* WidgetWin::GetWindow() {
-  return GetWindowImpl(hwnd());
+  return GetWindowImpl(GetNativeView());
 }
 
 const Window* WidgetWin::GetWindow() const {
-  return GetWindowImpl(hwnd());
+  return GetWindowImpl(GetNativeView());
 }
 
 FocusManager* WidgetWin::GetFocusManager() {
@@ -332,7 +332,7 @@ void WidgetWin::SetUseLayeredBuffer(bool use_layered_buffer) {
     return;
 
   use_layered_buffer_ = use_layered_buffer;
-  if (!hwnd())
+  if (!GetNativeView())
     return;
 
   if (use_layered_buffer_) {
@@ -440,11 +440,11 @@ void WidgetWin::OnClose() {
 
 void WidgetWin::OnDestroy() {
   if (drop_target_.get()) {
-    RevokeDragDrop(hwnd());
+    RevokeDragDrop(GetNativeView());
     drop_target_ = NULL;
   }
 
-  RemoveProp(hwnd(), kRootViewWindowProperty);
+  RemoveProp(GetNativeView(), kRootViewWindowProperty);
 }
 
 LRESULT WidgetWin::OnEraseBkgnd(HDC dc) {
@@ -548,7 +548,7 @@ LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) {
   // Reroute the mouse-wheel to the window under the mouse pointer if
   // applicable.
   if (message == WM_MOUSEWHEEL &&
-      views::RerouteMouseWheel(hwnd(), w_param, l_param)) {
+      views::RerouteMouseWheel(GetNativeView(), w_param, l_param)) {
     return 0;
   }
 
@@ -598,7 +598,7 @@ LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) {
 LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) {
   // NC points are in screen coordinates.
   CPoint temp = point;
-  MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1);
+  MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1);
   ProcessMouseMoved(temp, 0, true);
 
   // We need to process this message to stop Windows from drawing the window
@@ -634,7 +634,7 @@ LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) {
 }
 
 void WidgetWin::OnPaint(HDC dc) {
-  root_view_->OnPaint(hwnd());
+  root_view_->OnPaint(GetNativeView());
 }
 
 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) {
@@ -681,7 +681,7 @@ void WidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) {
     TRACKMOUSEEVENT tme;
     tme.cbSize = sizeof(tme);
     tme.dwFlags = mouse_tracking_flags;
-    tme.hwndTrack = hwnd();
+    tme.hwndTrack = GetNativeView();
     tme.dwHoverTime = 0;
     TrackMouseEvent(&tme);
   } else if (mouse_tracking_flags != active_mouse_tracking_flags_) {
@@ -848,8 +848,8 @@ void WidgetWin::UpdateWindowFromContents(HDC dib_dc) {
     CPoint window_position = wr.TopLeft();
 
     BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA};
-    UpdateLayeredWindow(
-        hwnd(), NULL, &window_position, &size, dib_dc, &zero_origin,
+    ::UpdateLayeredWindow(
+        GetNativeView(), NULL, &window_position, &size, dib_dc, &zero_origin,
         RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA);
   }
 }
@@ -904,7 +904,7 @@ bool ProcessNativeControlMessage(UINT message,
 }
 
 LRESULT WidgetWin::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) {
-  HWND window = hwnd();
+  HWND window = GetNativeView();
   LRESULT result = 0;
 
   // First allow messages sent by child controls to be processed directly by
diff --git a/webkit/default_plugin/default_plugin.gyp b/webkit/default_plugin/default_plugin.gyp
index 375431a..2aeac4e 100644
--- a/webkit/default_plugin/default_plugin.gyp
+++ b/webkit/default_plugin/default_plugin.gyp
@@ -26,7 +26,6 @@
           ],
           'include_dirs': [
             '../..',
-            '../../chrome/third_party/wtl/include',
             # TODO(bradnelson): this should fall out of the dependencies.
             '<(SHARED_INTERMEDIATE_DIR)/webkit',
           ],
diff --git a/webkit/default_plugin/plugin_impl_win.cc b/webkit/default_plugin/plugin_impl_win.cc
index 904aa7f..a940927 100644
--- a/webkit/default_plugin/plugin_impl_win.cc
+++ b/webkit/default_plugin/plugin_impl_win.cc
@@ -44,10 +44,10 @@ PluginInstallerImpl::~PluginInstallerImpl() {
   installation_job_monitor_thread_->Stop();
 
   if (bold_font_)
-    DeleteObject(bold_font_);
+    ::DeleteObject(bold_font_);
 
   if (underline_font_)
-    DeleteObject(underline_font_);
+    ::DeleteObject(underline_font_);
 
   if (activex_installer_) {
     activex_installer_->Cleanup();
@@ -55,7 +55,7 @@ PluginInstallerImpl::~PluginInstallerImpl() {
   }
 
   if (tooltip_)
-    DestroyWindow(tooltip_);
+    ::DestroyWindow(tooltip_);
 }
 
 bool PluginInstallerImpl::Initialize(HINSTANCE module_handle, NPP instance,
@@ -118,8 +118,8 @@ void PluginInstallerImpl::Shutdown() {
   if (install_dialog_.IsWindow()) {
     install_dialog_.DestroyWindow();
   }
-  if (IsWindow(hwnd())) {
-    DestroyWindow(hwnd());
+  if (IsWindow()) {
+    DestroyWindow();
   }
 }
 
@@ -168,12 +168,12 @@ void PluginInstallerImpl::ClearDisplay() {
 }
 
 void PluginInstallerImpl::RefreshDisplay() {
-  if (!IsWindow(hwnd()))
+  if (!IsWindow())
     return;
   UpdateToolTip();
 
-  InvalidateRect(hwnd(), NULL, TRUE);
-  UpdateWindow(hwnd());
+  InvalidateRect(NULL, TRUE);
+  UpdateWindow();
 }
 
 bool PluginInstallerImpl::CreateToolTip() {
@@ -182,16 +182,16 @@ bool PluginInstallerImpl::CreateToolTip() {
                             WS_POPUP | TTS_ALWAYSTIP,
                             CW_USEDEFAULT, CW_USEDEFAULT,
                             CW_USEDEFAULT, CW_USEDEFAULT,
-                            hwnd(), NULL, NULL, NULL);
+                            m_hWnd, NULL, NULL, NULL);
  if (!tooltip_)
    return false;
 
   // Associate the ToolTip with the tool.
   TOOLINFO tool_info = {0};
   tool_info.cbSize = sizeof(tool_info);
-  tool_info.hwnd = hwnd();
+  tool_info.hwnd = m_hWnd;
   tool_info.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
-  tool_info.uId = reinterpret_cast<UINT_PTR>(hwnd());
+  tool_info.uId = reinterpret_cast<UINT_PTR>(m_hWnd);
   tool_info.lpszText = NULL;
   SendMessage(tooltip_, TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&tool_info));
   SendMessage(tooltip_, TTM_SETMAXTIPWIDTH, 0, TOOLTIP_MAX_WIDTH);
@@ -207,9 +207,9 @@ void PluginInstallerImpl::UpdateToolTip() {
 
   TOOLINFO tool_info = {0};
   tool_info.cbSize = sizeof(tool_info);
-  tool_info.hwnd = hwnd();
+  tool_info.hwnd = m_hWnd;
   tool_info.uFlags = TTF_IDISHWND;
-  tool_info.uId = reinterpret_cast<UINT_PTR>(hwnd());
+  tool_info.uId = reinterpret_cast<UINT_PTR>(m_hWnd);
   tool_info.lpszText = const_cast<LPWSTR>(tip.c_str());
   SendMessage(tooltip_, TTM_UPDATETIPTEXT, 0, (LPARAM)&tool_info);
 }
@@ -316,9 +316,9 @@ std::wstring PluginInstallerImpl::ReplaceStringForPossibleEmptyReplacement(
 }
 
 bool PluginInstallerImpl::SetWindow(HWND parent_window) {
-  if (!IsWindow(parent_window)) {
+  if (!::IsWindow(parent_window)) {
     // No window created yet. Ignore this call.
-    if (!IsWindow(hwnd()))
+    if (!IsWindow())
       return true;
     // Parent window has been destroyed.
     Shutdown();
@@ -327,25 +327,22 @@ bool PluginInstallerImpl::SetWindow(HWND parent_window) {
 
   RECT parent_rect = {0};
 
-  if (IsWindow(hwnd())) {
-    GetClientRect(parent_window, &parent_rect);
-    SetWindowPos(hwnd(), NULL, parent_rect.left, parent_rect.top,
-                 parent_rect.right - parent_rect.left,
-                 parent_rect.bottom - parent_rect.top, SWP_SHOWWINDOW);
+  if (IsWindow()) {
+    ::GetClientRect(parent_window, &parent_rect);
+    SetWindowPos(NULL, &parent_rect, SWP_SHOWWINDOW);
     return true;
   }
   // First time in -- no window created by plugin yet.
-  GetClientRect(parent_window, &parent_rect);
-  set_window_style(WS_CHILD | WS_BORDER);
-  Init(parent_window, gfx::Rect(parent_rect));
-  DCHECK(IsWindow(hwnd()));
-  installation_job_monitor_thread_->set_plugin_window(hwnd());
+  ::GetClientRect(parent_window, &parent_rect);
+  Create(parent_window, parent_rect, NULL, WS_CHILD | WS_BORDER);
+  DCHECK(IsWindow());
+  installation_job_monitor_thread_->set_plugin_window(m_hWnd);
 
   CreateToolTip();
   UpdateToolTip();
 
-  UpdateWindow(hwnd());
-  ShowWindow(hwnd(), SW_SHOW);
+  UpdateWindow();
+  ShowWindow(SW_SHOW);
 
   return true;
 }
@@ -363,11 +360,11 @@ void PluginInstallerImpl::DownloadPlugin() {
       CComObject<ActiveXInstaller>::CreateInstance(&activex_installer_);
       activex_installer_->AddRef();
     }
-    activex_installer_->StartDownload(activex_clsid_, activex_codebase_,
-                                      hwnd(), kActivexInstallResult);
+    activex_installer_->StartDownload(activex_clsid_, activex_codebase_, m_hWnd,
+                                      kActivexInstallResult);
   } else {
     if (!plugin_download_url_for_display_) {
-      webkit_glue::DownloadUrl(plugin_download_url_, hwnd());
+      webkit_glue::DownloadUrl(plugin_download_url_, m_hWnd);
     } else {
       default_plugin::g_browser->geturl(instance(),
                                         plugin_download_url_.c_str(),
@@ -388,11 +385,11 @@ LRESULT PluginInstallerImpl::OnEraseBackGround(UINT message, WPARAM wparam,
                                                LPARAM lparam, BOOL& handled) {
   HDC paint_device_context = reinterpret_cast<HDC>(wparam);
   RECT erase_rect = {0};
-  GetClipBox(paint_device_context, &erase_rect);
+  ::GetClipBox(paint_device_context, &erase_rect);
   HBRUSH brush = ::CreateSolidBrush(RGB(252, 235, 162));
   DCHECK(brush);
-  FillRect(paint_device_context, &erase_rect, brush);
-  DeleteObject(brush);
+  ::FillRect(paint_device_context, &erase_rect, brush);
+  ::DeleteObject(brush);
   return 1;
 }
 
@@ -417,7 +414,7 @@ bool PluginInstallerImpl::IsRTLLayout() const {
 LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam,
                                      BOOL& handled) {
   PAINTSTRUCT paint_struct = {0};
-  BeginPaint(hwnd(), &paint_struct);
+  BeginPaint(&paint_struct);
 
   int save_dc_context = SaveDC(paint_struct.hdc);
   // The drawing order is as below:-
@@ -444,7 +441,7 @@ LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam,
   text_rect.bottom = text_rect.top + device_point.y;
 
   RECT client_rect = {0};
-  GetClientRect(hwnd(), &client_rect);
+  GetClientRect(&client_rect);
 
   int icon_width = GetSystemMetrics(SM_CXICON);
   int icon_height = GetSystemMetrics(SM_CYICON);
@@ -494,7 +491,7 @@ LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam,
   }
 
   RestoreDC(paint_struct.hdc, save_dc_context);
-  EndPaint(hwnd(), &paint_struct);
+  EndPaint(&paint_struct);
   return 0;
 }
 
@@ -554,7 +551,7 @@ void PluginInstallerImpl::PaintUserActionInformation(HDC paint_dc,
 void PluginInstallerImpl::ShowInstallDialog() {
   enable_click_ = false;
   install_dialog_.Initialize(this, plugin_name_);
-  install_dialog_.Create(hwnd(), NULL);
+  install_dialog_.Create(m_hWnd, NULL);
   install_dialog_.ShowWindow(SW_SHOW);
 }
 
@@ -584,7 +581,7 @@ LRESULT PluginInstallerImpl::OnLButtonDown(UINT message, WPARAM wparam,
 LRESULT PluginInstallerImpl::OnSetCursor(UINT message, WPARAM wparam,
                                          LPARAM lparam, BOOL& handled) {
   if (enable_click_) {
-    SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND)));
+    ::SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND)));
     return 1;
   }
   handled = FALSE;
@@ -660,7 +657,7 @@ LRESULT PluginInstallerImpl::OnActiveXInstallResult(UINT message,
   if (SUCCEEDED(wparam)) {
     set_plugin_installer_state(PluginInstallerLaunchSuccess);
     DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG);
-    PostMessage(hwnd(), kRefreshPluginsMessage, 0, 0);
+    PostMessage(kRefreshPluginsMessage, 0, 0);
   } else if ((wparam == INET_E_UNKNOWN_PROTOCOL) ||
              (wparam == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND))) {
     set_plugin_installer_state(PluginDownloadFailed);
diff --git a/webkit/default_plugin/plugin_impl_win.h b/webkit/default_plugin/plugin_impl_win.h
index a0e5596..66a97c6 100644
--- a/webkit/default_plugin/plugin_impl_win.h
+++ b/webkit/default_plugin/plugin_impl_win.h
@@ -5,10 +5,11 @@
 #ifndef WEBKIT_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_
 #define WEBKIT_DEFAULT_PLUGIN_PLUGIN_IMPL_WIN_H_
 
+#include <atlbase.h>
+#include <atlwin.h>
 #include <string>
 #include <vector>
 
-#include "base/window_impl.h"
 #include "third_party/npapi/bindings/npapi.h"
 #include "webkit/default_plugin/install_dialog.h"
 #include "webkit/default_plugin/plugin_database_handler.h"
@@ -35,7 +36,7 @@ class PluginDatabaseHandler;
 // Provides the plugin installation functionality. This class is
 // instantiated with the information like the mime type of the
 // target plugin, the display mode, etc.
-class PluginInstallerImpl : public base::WindowImpl {
+class PluginInstallerImpl : public CWindowImpl<PluginInstallerImpl> {
  public:
   static const int kRefreshPluginsMessage  = WM_APP + 1;
   static const int kInstallMissingPluginMessage = WM_APP + 2;
@@ -46,7 +47,7 @@ class PluginInstallerImpl : public base::WindowImpl {
   explicit PluginInstallerImpl(int16 mode);
   virtual ~PluginInstallerImpl();
 
-  BEGIN_MSG_MAP_EX(PluginInstallerImpl)
+  BEGIN_MSG_MAP(PluginInstallerImpl)
     MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackGround)
     MESSAGE_HANDLER(WM_PAINT, OnPaint)
     MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown)
@@ -150,6 +151,7 @@ class PluginInstallerImpl : public base::WindowImpl {
   // activex.
   int16 NPP_HandleEvent(void* event);
 
+  HWND window() const { return m_hWnd; }
   const std::string& mime_type() const { return mime_type_; }
 
   // Replaces a resource string with the placeholder passed in as an argument
@@ -373,7 +375,7 @@ class PluginInstallerImpl : public base::WindowImpl {
   std::string activex_clsid_;
   CComObject<ActiveXInstaller>* activex_installer_;
 
-  DISALLOW_COPY_AND_ASSIGN(PluginInstallerImpl);
+  DISALLOW_EVIL_CONSTRUCTORS(PluginInstallerImpl);
 };
 
 
diff --git a/webkit/tools/test_shell/foreground_helper.h b/webkit/tools/test_shell/foreground_helper.h
index a687c0d..9456ded 100644
--- a/webkit/tools/test_shell/foreground_helper.h
+++ b/webkit/tools/test_shell/foreground_helper.h
@@ -38,16 +38,16 @@ class ForegroundHelper : public base::WindowImpl {
     // be in the foreground and allowed to move the target window
     // into the foreground too.
 
-    set_window_style(WS_POPUP);
+    set_window_ex_style(WS_POPUP);
     Init(NULL, gfx::Rect());
 
     static const int hotkey_id = 0x0000baba;
 
     // Store the target window into our USERDATA for use in our
     // HotKey handler.
-    SetWindowLongPtr(hwnd(), GWLP_USERDATA,
+    SetWindowLongPtr(GetNativeView(), GWLP_USERDATA,
                      reinterpret_cast<ULONG_PTR>(window));
-    RegisterHotKey(hwnd(), hotkey_id, 0, VK_F22);
+    RegisterHotKey(GetNativeView(), hotkey_id, 0, VK_F22);
 
     // If the calling thread is not yet a UI thread, call PeekMessage
     // to ensure creation of its message queue.
@@ -72,8 +72,8 @@ class ForegroundHelper : public base::WindowImpl {
         break;
     }
 
-    UnregisterHotKey(hwnd(), hotkey_id);
-    DestroyWindow(hwnd());
+    UnregisterHotKey(GetNativeView(), hotkey_id);
+    DestroyWindow();
 
     return S_OK;
   }
@@ -83,7 +83,7 @@ class ForegroundHelper : public base::WindowImpl {
                    WPARAM wparam,
                    LPARAM lparam,
                    BOOL& handled) {
-    HWND window = reinterpret_cast<HWND>(GetWindowLongPtr(hwnd(),
+    HWND window = reinterpret_cast<HWND>(GetWindowLongPtr(GetNativeView(),
                                                           GWLP_USERDATA));
     SetForegroundWindow(window);
     return 1;
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index 746cf1b..c9028c2 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -1505,9 +1505,6 @@
           ],
         }, {  # else: OS=="win"
           'sources/': [['exclude', '_posix\\.cc$']],
-          'include_dirs': [
-            '../chrome/third_party/wtl/include',
-          ],
           'dependencies': [
             '../build/win/system.gyp:cygwin',
             'activex_shim/activex_shim.gyp:activex_shim',
-- 
cgit v1.1