diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 20:39:34 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-14 20:39:34 +0000 |
commit | c0d5fc9424a062dd51b90854b461bd4a9c309dad (patch) | |
tree | 1d1ad1b72c9e17689b6cb19dffcadd13b70168dc /webkit/default_plugin | |
parent | fa8b44910eb051f9a6d9bb7955afa8e0b6482268 (diff) | |
download | chromium_src-c0d5fc9424a062dd51b90854b461bd4a9c309dad.zip chromium_src-c0d5fc9424a062dd51b90854b461bd4a9c309dad.tar.gz chromium_src-c0d5fc9424a062dd51b90854b461bd4a9c309dad.tar.bz2 |
Revert "Reverting 23406" as it didn't break any tests.
Change PluginInstallImpl to use base::WindowImpl instead of CWindowImpl to
reduce a dependency on ATL.
BUG=5023
TEST=Uninstall flash. Visit hulu.com and install the flash plugin.
Original review: http://codereview.chromium.org/165469
TBR=levin
Review URL: http://codereview.chromium.org/165543
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23454 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/default_plugin')
-rw-r--r-- | webkit/default_plugin/default_plugin.gyp | 1 | ||||
-rw-r--r-- | webkit/default_plugin/plugin_impl_win.cc | 75 | ||||
-rw-r--r-- | webkit/default_plugin/plugin_impl_win.h | 10 |
3 files changed, 44 insertions, 42 deletions
diff --git a/webkit/default_plugin/default_plugin.gyp b/webkit/default_plugin/default_plugin.gyp index 2aeac4e..375431a 100644 --- a/webkit/default_plugin/default_plugin.gyp +++ b/webkit/default_plugin/default_plugin.gyp @@ -26,6 +26,7 @@ ], '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 a940927..904aa7f 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()) { - DestroyWindow(); + if (IsWindow(hwnd())) { + DestroyWindow(hwnd()); } } @@ -168,12 +168,12 @@ void PluginInstallerImpl::ClearDisplay() { } void PluginInstallerImpl::RefreshDisplay() { - if (!IsWindow()) + if (!IsWindow(hwnd())) return; UpdateToolTip(); - InvalidateRect(NULL, TRUE); - UpdateWindow(); + InvalidateRect(hwnd(), NULL, TRUE); + UpdateWindow(hwnd()); } bool PluginInstallerImpl::CreateToolTip() { @@ -182,16 +182,16 @@ bool PluginInstallerImpl::CreateToolTip() { WS_POPUP | TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - m_hWnd, NULL, NULL, NULL); + 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 = m_hWnd; + tool_info.hwnd = hwnd(); tool_info.uFlags = TTF_IDISHWND | TTF_SUBCLASS; - tool_info.uId = reinterpret_cast<UINT_PTR>(m_hWnd); + tool_info.uId = reinterpret_cast<UINT_PTR>(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 = m_hWnd; + tool_info.hwnd = hwnd(); tool_info.uFlags = TTF_IDISHWND; - tool_info.uId = reinterpret_cast<UINT_PTR>(m_hWnd); + tool_info.uId = reinterpret_cast<UINT_PTR>(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()) + if (!IsWindow(hwnd())) return true; // Parent window has been destroyed. Shutdown(); @@ -327,22 +327,25 @@ bool PluginInstallerImpl::SetWindow(HWND parent_window) { RECT parent_rect = {0}; - if (IsWindow()) { - ::GetClientRect(parent_window, &parent_rect); - SetWindowPos(NULL, &parent_rect, SWP_SHOWWINDOW); + 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); return true; } // First time in -- no window created by plugin yet. - ::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); + 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()); CreateToolTip(); UpdateToolTip(); - UpdateWindow(); - ShowWindow(SW_SHOW); + UpdateWindow(hwnd()); + ShowWindow(hwnd(), SW_SHOW); return true; } @@ -360,11 +363,11 @@ void PluginInstallerImpl::DownloadPlugin() { CComObject<ActiveXInstaller>::CreateInstance(&activex_installer_); activex_installer_->AddRef(); } - activex_installer_->StartDownload(activex_clsid_, activex_codebase_, m_hWnd, - kActivexInstallResult); + activex_installer_->StartDownload(activex_clsid_, activex_codebase_, + hwnd(), kActivexInstallResult); } else { if (!plugin_download_url_for_display_) { - webkit_glue::DownloadUrl(plugin_download_url_, m_hWnd); + webkit_glue::DownloadUrl(plugin_download_url_, hwnd()); } else { default_plugin::g_browser->geturl(instance(), plugin_download_url_.c_str(), @@ -385,11 +388,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; } @@ -414,7 +417,7 @@ bool PluginInstallerImpl::IsRTLLayout() const { LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) { PAINTSTRUCT paint_struct = {0}; - BeginPaint(&paint_struct); + BeginPaint(hwnd(), &paint_struct); int save_dc_context = SaveDC(paint_struct.hdc); // The drawing order is as below:- @@ -441,7 +444,7 @@ LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam, text_rect.bottom = text_rect.top + device_point.y; RECT client_rect = {0}; - GetClientRect(&client_rect); + GetClientRect(hwnd(), &client_rect); int icon_width = GetSystemMetrics(SM_CXICON); int icon_height = GetSystemMetrics(SM_CYICON); @@ -491,7 +494,7 @@ LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam, } RestoreDC(paint_struct.hdc, save_dc_context); - EndPaint(&paint_struct); + EndPaint(hwnd(), &paint_struct); return 0; } @@ -551,7 +554,7 @@ void PluginInstallerImpl::PaintUserActionInformation(HDC paint_dc, void PluginInstallerImpl::ShowInstallDialog() { enable_click_ = false; install_dialog_.Initialize(this, plugin_name_); - install_dialog_.Create(m_hWnd, NULL); + install_dialog_.Create(hwnd(), NULL); install_dialog_.ShowWindow(SW_SHOW); } @@ -581,7 +584,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; @@ -657,7 +660,7 @@ LRESULT PluginInstallerImpl::OnActiveXInstallResult(UINT message, if (SUCCEEDED(wparam)) { set_plugin_installer_state(PluginInstallerLaunchSuccess); DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG); - PostMessage(kRefreshPluginsMessage, 0, 0); + PostMessage(hwnd(), 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 66a97c6..a0e5596 100644 --- a/webkit/default_plugin/plugin_impl_win.h +++ b/webkit/default_plugin/plugin_impl_win.h @@ -5,11 +5,10 @@ #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" @@ -36,7 +35,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 CWindowImpl<PluginInstallerImpl> { +class PluginInstallerImpl : public base::WindowImpl { public: static const int kRefreshPluginsMessage = WM_APP + 1; static const int kInstallMissingPluginMessage = WM_APP + 2; @@ -47,7 +46,7 @@ class PluginInstallerImpl : public CWindowImpl<PluginInstallerImpl> { explicit PluginInstallerImpl(int16 mode); virtual ~PluginInstallerImpl(); - BEGIN_MSG_MAP(PluginInstallerImpl) + BEGIN_MSG_MAP_EX(PluginInstallerImpl) MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBackGround) MESSAGE_HANDLER(WM_PAINT, OnPaint) MESSAGE_HANDLER(WM_LBUTTONDOWN, OnLButtonDown) @@ -151,7 +150,6 @@ class PluginInstallerImpl : public CWindowImpl<PluginInstallerImpl> { // 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 @@ -375,7 +373,7 @@ class PluginInstallerImpl : public CWindowImpl<PluginInstallerImpl> { std::string activex_clsid_; CComObject<ActiveXInstaller>* activex_installer_; - DISALLOW_EVIL_CONSTRUCTORS(PluginInstallerImpl); + DISALLOW_COPY_AND_ASSIGN(PluginInstallerImpl); }; |