| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "webkit/default_plugin/plugin_impl_win.h" | 5 #include "webkit/default_plugin/plugin_impl_win.h" |
| 6 | 6 |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 installation_job_monitor_thread_( | 37 installation_job_monitor_thread_( |
| 38 new PluginInstallationJobMonitorThread()), | 38 new PluginInstallationJobMonitorThread()), |
| 39 plugin_database_handler_(*this), | 39 plugin_database_handler_(*this), |
| 40 plugin_download_url_for_display_(false) { | 40 plugin_download_url_for_display_(false) { |
| 41 } | 41 } |
| 42 | 42 |
| 43 PluginInstallerImpl::~PluginInstallerImpl() { | 43 PluginInstallerImpl::~PluginInstallerImpl() { |
| 44 installation_job_monitor_thread_->Stop(); | 44 installation_job_monitor_thread_->Stop(); |
| 45 | 45 |
| 46 if (bold_font_) | 46 if (bold_font_) |
| 47 DeleteObject(bold_font_); | 47 ::DeleteObject(bold_font_); |
| 48 | 48 |
| 49 if (underline_font_) | 49 if (underline_font_) |
| 50 DeleteObject(underline_font_); | 50 ::DeleteObject(underline_font_); |
| 51 | 51 |
| 52 if (activex_installer_) { | 52 if (activex_installer_) { |
| 53 activex_installer_->Cleanup(); | 53 activex_installer_->Cleanup(); |
| 54 activex_installer_->Release(); | 54 activex_installer_->Release(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 if (tooltip_) | 57 if (tooltip_) |
| 58 DestroyWindow(tooltip_); | 58 ::DestroyWindow(tooltip_); |
| 59 } | 59 } |
| 60 | 60 |
| 61 bool PluginInstallerImpl::Initialize(HINSTANCE module_handle, NPP instance, | 61 bool PluginInstallerImpl::Initialize(HINSTANCE module_handle, NPP instance, |
| 62 NPMIMEType mime_type, int16 argc, | 62 NPMIMEType mime_type, int16 argc, |
| 63 char* argn[], char* argv[]) { | 63 char* argn[], char* argv[]) { |
| 64 DLOG(INFO) << __FUNCTION__ << " Mime Type : " << mime_type; | 64 DLOG(INFO) << __FUNCTION__ << " Mime Type : " << mime_type; |
| 65 DCHECK(instance != NULL); | 65 DCHECK(instance != NULL); |
| 66 DCHECK(module_handle != NULL); | 66 DCHECK(module_handle != NULL); |
| 67 | 67 |
| 68 instance_ = instance; | 68 instance_ = instance; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 plugin_database_handler_.DownloadPluginsFileIfNeeded(plugin_finder_url_); | 111 plugin_database_handler_.DownloadPluginsFileIfNeeded(plugin_finder_url_); |
| 112 } | 112 } |
| 113 | 113 |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 void PluginInstallerImpl::Shutdown() { | 117 void PluginInstallerImpl::Shutdown() { |
| 118 if (install_dialog_.IsWindow()) { | 118 if (install_dialog_.IsWindow()) { |
| 119 install_dialog_.DestroyWindow(); | 119 install_dialog_.DestroyWindow(); |
| 120 } | 120 } |
| 121 if (IsWindow(hwnd())) { | 121 if (IsWindow()) { |
| 122 DestroyWindow(hwnd()); | 122 DestroyWindow(); |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 | 125 |
| 126 void PluginInstallerImpl::NewStream(NPStream* stream) { | 126 void PluginInstallerImpl::NewStream(NPStream* stream) { |
| 127 plugin_install_stream_ = stream; | 127 plugin_install_stream_ = stream; |
| 128 } | 128 } |
| 129 | 129 |
| 130 void PluginInstallerImpl::DestroyStream(NPStream* stream, NPError reason) { | 130 void PluginInstallerImpl::DestroyStream(NPStream* stream, NPError reason) { |
| 131 if (stream == plugin_install_stream_) | 131 if (stream == plugin_install_stream_) |
| 132 plugin_install_stream_ = NULL; | 132 plugin_install_stream_ = NULL; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 161 } | 161 } |
| 162 | 162 |
| 163 void PluginInstallerImpl::ClearDisplay() { | 163 void PluginInstallerImpl::ClearDisplay() { |
| 164 enable_click_ = false; | 164 enable_click_ = false; |
| 165 command_.clear(); | 165 command_.clear(); |
| 166 optional_additional_message_.clear(); | 166 optional_additional_message_.clear(); |
| 167 get_plugin_link_message_.clear(); | 167 get_plugin_link_message_.clear(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 void PluginInstallerImpl::RefreshDisplay() { | 170 void PluginInstallerImpl::RefreshDisplay() { |
| 171 if (!IsWindow(hwnd())) | 171 if (!IsWindow()) |
| 172 return; | 172 return; |
| 173 UpdateToolTip(); | 173 UpdateToolTip(); |
| 174 | 174 |
| 175 InvalidateRect(hwnd(), NULL, TRUE); | 175 InvalidateRect(NULL, TRUE); |
| 176 UpdateWindow(hwnd()); | 176 UpdateWindow(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 bool PluginInstallerImpl::CreateToolTip() { | 179 bool PluginInstallerImpl::CreateToolTip() { |
| 180 DWORD ex_styles = IsRTLLayout() ? WS_EX_LAYOUTRTL : 0; | 180 DWORD ex_styles = IsRTLLayout() ? WS_EX_LAYOUTRTL : 0; |
| 181 tooltip_ = CreateWindowEx(ex_styles, TOOLTIPS_CLASS, NULL, | 181 tooltip_ = CreateWindowEx(ex_styles, TOOLTIPS_CLASS, NULL, |
| 182 WS_POPUP | TTS_ALWAYSTIP, | 182 WS_POPUP | TTS_ALWAYSTIP, |
| 183 CW_USEDEFAULT, CW_USEDEFAULT, | 183 CW_USEDEFAULT, CW_USEDEFAULT, |
| 184 CW_USEDEFAULT, CW_USEDEFAULT, | 184 CW_USEDEFAULT, CW_USEDEFAULT, |
| 185 hwnd(), NULL, NULL, NULL); | 185 m_hWnd, NULL, NULL, NULL); |
| 186 if (!tooltip_) | 186 if (!tooltip_) |
| 187 return false; | 187 return false; |
| 188 | 188 |
| 189 // Associate the ToolTip with the tool. | 189 // Associate the ToolTip with the tool. |
| 190 TOOLINFO tool_info = {0}; | 190 TOOLINFO tool_info = {0}; |
| 191 tool_info.cbSize = sizeof(tool_info); | 191 tool_info.cbSize = sizeof(tool_info); |
| 192 tool_info.hwnd = hwnd(); | 192 tool_info.hwnd = m_hWnd; |
| 193 tool_info.uFlags = TTF_IDISHWND | TTF_SUBCLASS; | 193 tool_info.uFlags = TTF_IDISHWND | TTF_SUBCLASS; |
| 194 tool_info.uId = reinterpret_cast<UINT_PTR>(hwnd()); | 194 tool_info.uId = reinterpret_cast<UINT_PTR>(m_hWnd); |
| 195 tool_info.lpszText = NULL; | 195 tool_info.lpszText = NULL; |
| 196 SendMessage(tooltip_, TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&tool_info)); | 196 SendMessage(tooltip_, TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&tool_info)); |
| 197 SendMessage(tooltip_, TTM_SETMAXTIPWIDTH, 0, TOOLTIP_MAX_WIDTH); | 197 SendMessage(tooltip_, TTM_SETMAXTIPWIDTH, 0, TOOLTIP_MAX_WIDTH); |
| 198 return true; | 198 return true; |
| 199 } | 199 } |
| 200 | 200 |
| 201 void PluginInstallerImpl::UpdateToolTip() { | 201 void PluginInstallerImpl::UpdateToolTip() { |
| 202 if (tooltip_ == NULL) | 202 if (tooltip_ == NULL) |
| 203 return; | 203 return; |
| 204 std::wstring tip = command_; | 204 std::wstring tip = command_; |
| 205 if (!optional_additional_message_.empty()) | 205 if (!optional_additional_message_.empty()) |
| 206 tip += std::wstring(L"\n\r") + optional_additional_message_; | 206 tip += std::wstring(L"\n\r") + optional_additional_message_; |
| 207 | 207 |
| 208 TOOLINFO tool_info = {0}; | 208 TOOLINFO tool_info = {0}; |
| 209 tool_info.cbSize = sizeof(tool_info); | 209 tool_info.cbSize = sizeof(tool_info); |
| 210 tool_info.hwnd = hwnd(); | 210 tool_info.hwnd = m_hWnd; |
| 211 tool_info.uFlags = TTF_IDISHWND; | 211 tool_info.uFlags = TTF_IDISHWND; |
| 212 tool_info.uId = reinterpret_cast<UINT_PTR>(hwnd()); | 212 tool_info.uId = reinterpret_cast<UINT_PTR>(m_hWnd); |
| 213 tool_info.lpszText = const_cast<LPWSTR>(tip.c_str()); | 213 tool_info.lpszText = const_cast<LPWSTR>(tip.c_str()); |
| 214 SendMessage(tooltip_, TTM_UPDATETIPTEXT, 0, (LPARAM)&tool_info); | 214 SendMessage(tooltip_, TTM_UPDATETIPTEXT, 0, (LPARAM)&tool_info); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void PluginInstallerImpl::DisplayAvailablePluginStatus() { | 217 void PluginInstallerImpl::DisplayAvailablePluginStatus() { |
| 218 ClearDisplay(); | 218 ClearDisplay(); |
| 219 enable_click_ = true; | 219 enable_click_ = true; |
| 220 command_ = ReplaceStringForPossibleEmptyReplacement( | 220 command_ = ReplaceStringForPossibleEmptyReplacement( |
| 221 IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG, | 221 IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG, |
| 222 IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG_NO_PLUGIN_NAME, | 222 IDS_DEFAULT_PLUGIN_GET_PLUGIN_MSG_NO_PLUGIN_NAME, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 return webkit_glue::GetLocalizedString(messsage_id_without_placeholders); | 309 return webkit_glue::GetLocalizedString(messsage_id_without_placeholders); |
| 310 } else { | 310 } else { |
| 311 std::wstring string_with_placeholders = | 311 std::wstring string_with_placeholders = |
| 312 webkit_glue::GetLocalizedString(message_id_with_placeholders); | 312 webkit_glue::GetLocalizedString(message_id_with_placeholders); |
| 313 return ReplaceStringPlaceholders(string_with_placeholders, | 313 return ReplaceStringPlaceholders(string_with_placeholders, |
| 314 replacement_string, NULL); | 314 replacement_string, NULL); |
| 315 } | 315 } |
| 316 } | 316 } |
| 317 | 317 |
| 318 bool PluginInstallerImpl::SetWindow(HWND parent_window) { | 318 bool PluginInstallerImpl::SetWindow(HWND parent_window) { |
| 319 if (!IsWindow(parent_window)) { | 319 if (!::IsWindow(parent_window)) { |
| 320 // No window created yet. Ignore this call. | 320 // No window created yet. Ignore this call. |
| 321 if (!IsWindow(hwnd())) | 321 if (!IsWindow()) |
| 322 return true; | 322 return true; |
| 323 // Parent window has been destroyed. | 323 // Parent window has been destroyed. |
| 324 Shutdown(); | 324 Shutdown(); |
| 325 return true; | 325 return true; |
| 326 } | 326 } |
| 327 | 327 |
| 328 RECT parent_rect = {0}; | 328 RECT parent_rect = {0}; |
| 329 | 329 |
| 330 if (IsWindow(hwnd())) { | 330 if (IsWindow()) { |
| 331 GetClientRect(parent_window, &parent_rect); | 331 ::GetClientRect(parent_window, &parent_rect); |
| 332 SetWindowPos(hwnd(), NULL, parent_rect.left, parent_rect.top, | 332 SetWindowPos(NULL, &parent_rect, SWP_SHOWWINDOW); |
| 333 parent_rect.right - parent_rect.left, | |
| 334 parent_rect.bottom - parent_rect.top, SWP_SHOWWINDOW); | |
| 335 return true; | 333 return true; |
| 336 } | 334 } |
| 337 // First time in -- no window created by plugin yet. | 335 // First time in -- no window created by plugin yet. |
| 338 GetClientRect(parent_window, &parent_rect); | 336 ::GetClientRect(parent_window, &parent_rect); |
| 339 set_window_style(WS_CHILD | WS_BORDER); | 337 Create(parent_window, parent_rect, NULL, WS_CHILD | WS_BORDER); |
| 340 Init(parent_window, gfx::Rect(parent_rect)); | 338 DCHECK(IsWindow()); |
| 341 DCHECK(IsWindow(hwnd())); | 339 installation_job_monitor_thread_->set_plugin_window(m_hWnd); |
| 342 installation_job_monitor_thread_->set_plugin_window(hwnd()); | |
| 343 | 340 |
| 344 CreateToolTip(); | 341 CreateToolTip(); |
| 345 UpdateToolTip(); | 342 UpdateToolTip(); |
| 346 | 343 |
| 347 UpdateWindow(hwnd()); | 344 UpdateWindow(); |
| 348 ShowWindow(hwnd(), SW_SHOW); | 345 ShowWindow(SW_SHOW); |
| 349 | 346 |
| 350 return true; | 347 return true; |
| 351 } | 348 } |
| 352 | 349 |
| 353 void PluginInstallerImpl::DownloadPlugin() { | 350 void PluginInstallerImpl::DownloadPlugin() { |
| 354 set_plugin_installer_state(PluginDownloadInitiated); | 351 set_plugin_installer_state(PluginDownloadInitiated); |
| 355 | 352 |
| 356 DLOG(INFO) << "Initiating download for plugin URL " | 353 DLOG(INFO) << "Initiating download for plugin URL " |
| 357 << plugin_download_url_.c_str(); | 354 << plugin_download_url_.c_str(); |
| 358 | 355 |
| 359 DisplayStatus(IDS_DEFAULT_PLUGIN_DOWNLOADING_PLUGIN_MSG); | 356 DisplayStatus(IDS_DEFAULT_PLUGIN_DOWNLOADING_PLUGIN_MSG); |
| 360 | 357 |
| 361 if (is_activex_) { | 358 if (is_activex_) { |
| 362 if (activex_installer_ == NULL) { | 359 if (activex_installer_ == NULL) { |
| 363 CComObject<ActiveXInstaller>::CreateInstance(&activex_installer_); | 360 CComObject<ActiveXInstaller>::CreateInstance(&activex_installer_); |
| 364 activex_installer_->AddRef(); | 361 activex_installer_->AddRef(); |
| 365 } | 362 } |
| 366 activex_installer_->StartDownload(activex_clsid_, activex_codebase_, | 363 activex_installer_->StartDownload(activex_clsid_, activex_codebase_, m_hWnd, |
| 367 hwnd(), kActivexInstallResult); | 364 kActivexInstallResult); |
| 368 } else { | 365 } else { |
| 369 if (!plugin_download_url_for_display_) { | 366 if (!plugin_download_url_for_display_) { |
| 370 webkit_glue::DownloadUrl(plugin_download_url_, hwnd()); | 367 webkit_glue::DownloadUrl(plugin_download_url_, m_hWnd); |
| 371 } else { | 368 } else { |
| 372 default_plugin::g_browser->geturl(instance(), | 369 default_plugin::g_browser->geturl(instance(), |
| 373 plugin_download_url_.c_str(), | 370 plugin_download_url_.c_str(), |
| 374 "_blank"); | 371 "_blank"); |
| 375 set_plugin_installer_state(PluginInstallerLaunchSuccess); | 372 set_plugin_installer_state(PluginInstallerLaunchSuccess); |
| 376 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG); | 373 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG); |
| 377 enable_click_ = true; | 374 enable_click_ = true; |
| 378 RefreshDisplay(); | 375 RefreshDisplay(); |
| 379 } | 376 } |
| 380 } | 377 } |
| 381 } | 378 } |
| 382 | 379 |
| 383 void PluginInstallerImpl::DownloadCancelled() { | 380 void PluginInstallerImpl::DownloadCancelled() { |
| 384 DisplayAvailablePluginStatus(); | 381 DisplayAvailablePluginStatus(); |
| 385 } | 382 } |
| 386 | 383 |
| 387 LRESULT PluginInstallerImpl::OnEraseBackGround(UINT message, WPARAM wparam, | 384 LRESULT PluginInstallerImpl::OnEraseBackGround(UINT message, WPARAM wparam, |
| 388 LPARAM lparam, BOOL& handled) { | 385 LPARAM lparam, BOOL& handled) { |
| 389 HDC paint_device_context = reinterpret_cast<HDC>(wparam); | 386 HDC paint_device_context = reinterpret_cast<HDC>(wparam); |
| 390 RECT erase_rect = {0}; | 387 RECT erase_rect = {0}; |
| 391 GetClipBox(paint_device_context, &erase_rect); | 388 ::GetClipBox(paint_device_context, &erase_rect); |
| 392 HBRUSH brush = ::CreateSolidBrush(RGB(252, 235, 162)); | 389 HBRUSH brush = ::CreateSolidBrush(RGB(252, 235, 162)); |
| 393 DCHECK(brush); | 390 DCHECK(brush); |
| 394 FillRect(paint_device_context, &erase_rect, brush); | 391 ::FillRect(paint_device_context, &erase_rect, brush); |
| 395 DeleteObject(brush); | 392 ::DeleteObject(brush); |
| 396 return 1; | 393 return 1; |
| 397 } | 394 } |
| 398 | 395 |
| 399 // Use ICU in order to determine whether the locale is right-to-left. | 396 // Use ICU in order to determine whether the locale is right-to-left. |
| 400 // | 397 // |
| 401 // TODO(idana) bug# 1246452: there is already code in | 398 // TODO(idana) bug# 1246452: there is already code in |
| 402 // app/l10n_util.h/cc that uses ICU to determine the locale direction. We don't | 399 // app/l10n_util.h/cc that uses ICU to determine the locale direction. We don't |
| 403 // currently use this code since code in WebKit should not depend on code in | 400 // currently use this code since code in WebKit should not depend on code in |
| 404 // Chrome. We can fix this by pulling (at least part of) the l10n_util | 401 // Chrome. We can fix this by pulling (at least part of) the l10n_util |
| 405 // functionality up into the Base module. | 402 // functionality up into the Base module. |
| 406 bool PluginInstallerImpl::IsRTLLayout() const { | 403 bool PluginInstallerImpl::IsRTLLayout() const { |
| 407 const Locale& locale = Locale::getDefault(); | 404 const Locale& locale = Locale::getDefault(); |
| 408 const char* lang = locale.getLanguage(); | 405 const char* lang = locale.getLanguage(); |
| 409 | 406 |
| 410 // Check only for Arabic and Hebrew languages for now. | 407 // Check only for Arabic and Hebrew languages for now. |
| 411 if (strcmp(lang, "ar") == 0 || strcmp(lang, "he") == 0) { | 408 if (strcmp(lang, "ar") == 0 || strcmp(lang, "he") == 0) { |
| 412 return true; | 409 return true; |
| 413 } | 410 } |
| 414 return false; | 411 return false; |
| 415 } | 412 } |
| 416 | 413 |
| 417 LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam, | 414 LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam, |
| 418 BOOL& handled) { | 415 BOOL& handled) { |
| 419 PAINTSTRUCT paint_struct = {0}; | 416 PAINTSTRUCT paint_struct = {0}; |
| 420 BeginPaint(hwnd(), &paint_struct); | 417 BeginPaint(&paint_struct); |
| 421 | 418 |
| 422 int save_dc_context = SaveDC(paint_struct.hdc); | 419 int save_dc_context = SaveDC(paint_struct.hdc); |
| 423 // The drawing order is as below:- | 420 // The drawing order is as below:- |
| 424 // 1. The Get plugin link at the top left corner. | 421 // 1. The Get plugin link at the top left corner. |
| 425 // 2. The plugin icon. | 422 // 2. The plugin icon. |
| 426 // 3. The text describing user actions to the right of the icon. | 423 // 3. The text describing user actions to the right of the icon. |
| 427 SIZE get_plugin_link_extents = {0}; | 424 SIZE get_plugin_link_extents = {0}; |
| 428 HFONT old_font = | 425 HFONT old_font = |
| 429 reinterpret_cast<HFONT>(SelectObject(paint_struct.hdc, regular_font_)); | 426 reinterpret_cast<HFONT>(SelectObject(paint_struct.hdc, regular_font_)); |
| 430 | 427 |
| 431 GetTextExtentPoint32(paint_struct.hdc, get_plugin_link_message_.c_str(), | 428 GetTextExtentPoint32(paint_struct.hdc, get_plugin_link_message_.c_str(), |
| 432 static_cast<int>(get_plugin_link_message_.length()), | 429 static_cast<int>(get_plugin_link_message_.length()), |
| 433 &get_plugin_link_extents); | 430 &get_plugin_link_extents); |
| 434 | 431 |
| 435 POINT device_point = {0}; | 432 POINT device_point = {0}; |
| 436 device_point.x = get_plugin_link_extents.cx; | 433 device_point.x = get_plugin_link_extents.cx; |
| 437 device_point.y = get_plugin_link_extents.cy; | 434 device_point.y = get_plugin_link_extents.cy; |
| 438 LPtoDP(paint_struct.hdc, &device_point, 1); | 435 LPtoDP(paint_struct.hdc, &device_point, 1); |
| 439 | 436 |
| 440 RECT text_rect = {0}; | 437 RECT text_rect = {0}; |
| 441 text_rect.left = 5; | 438 text_rect.left = 5; |
| 442 text_rect.right = text_rect.left + device_point.x; | 439 text_rect.right = text_rect.left + device_point.x; |
| 443 text_rect.top = 5; | 440 text_rect.top = 5; |
| 444 text_rect.bottom = text_rect.top + device_point.y; | 441 text_rect.bottom = text_rect.top + device_point.y; |
| 445 | 442 |
| 446 RECT client_rect = {0}; | 443 RECT client_rect = {0}; |
| 447 GetClientRect(hwnd(), &client_rect); | 444 GetClientRect(&client_rect); |
| 448 | 445 |
| 449 int icon_width = GetSystemMetrics(SM_CXICON); | 446 int icon_width = GetSystemMetrics(SM_CXICON); |
| 450 int icon_height = GetSystemMetrics(SM_CYICON); | 447 int icon_height = GetSystemMetrics(SM_CYICON); |
| 451 | 448 |
| 452 int x = (client_rect.right / 2) - icon_width / 2; | 449 int x = (client_rect.right / 2) - icon_width / 2; |
| 453 int y = (client_rect.bottom / 2) - icon_height / 2; | 450 int y = (client_rect.bottom / 2) - icon_height / 2; |
| 454 | 451 |
| 455 DCHECK(icon_); | 452 DCHECK(icon_); |
| 456 DrawIcon(paint_struct.hdc, x, y, icon_); | 453 DrawIcon(paint_struct.hdc, x, y, icon_); |
| 457 | 454 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 487 // over the plugin window. | 484 // over the plugin window. |
| 488 int window_width = client_rect.right - client_rect.left; | 485 int window_width = client_rect.right - client_rect.left; |
| 489 int window_height = client_rect.bottom - client_rect.top; | 486 int window_height = client_rect.bottom - client_rect.top; |
| 490 | 487 |
| 491 if ((x_origin + command_extents.cx <= window_width) && | 488 if ((x_origin + command_extents.cx <= window_width) && |
| 492 (y_origin + command_extents.cy <= window_height)) { | 489 (y_origin + command_extents.cy <= window_height)) { |
| 493 PaintUserActionInformation(paint_struct.hdc, x_origin, y_origin); | 490 PaintUserActionInformation(paint_struct.hdc, x_origin, y_origin); |
| 494 } | 491 } |
| 495 | 492 |
| 496 RestoreDC(paint_struct.hdc, save_dc_context); | 493 RestoreDC(paint_struct.hdc, save_dc_context); |
| 497 EndPaint(hwnd(), &paint_struct); | 494 EndPaint(&paint_struct); |
| 498 return 0; | 495 return 0; |
| 499 } | 496 } |
| 500 | 497 |
| 501 void PluginInstallerImpl::PaintUserActionInformation(HDC paint_dc, | 498 void PluginInstallerImpl::PaintUserActionInformation(HDC paint_dc, |
| 502 int x_origin, | 499 int x_origin, |
| 503 int y_origin) { | 500 int y_origin) { |
| 504 SelectObject(paint_dc, regular_font_); | 501 SelectObject(paint_dc, regular_font_); |
| 505 | 502 |
| 506 SIZE command_extents = {0}; | 503 SIZE command_extents = {0}; |
| 507 GetTextExtentPoint32(paint_dc, command_.c_str(), | 504 GetTextExtentPoint32(paint_dc, command_.c_str(), |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 | 544 |
| 548 DrawText(paint_dc, optional_additional_message_.c_str(), | 545 DrawText(paint_dc, optional_additional_message_.c_str(), |
| 549 static_cast<int>(optional_additional_message_.length()), | 546 static_cast<int>(optional_additional_message_.length()), |
| 550 &text_rect, DT_CENTER | DT_VCENTER | additional_dt_flags); | 547 &text_rect, DT_CENTER | DT_VCENTER | additional_dt_flags); |
| 551 } | 548 } |
| 552 } | 549 } |
| 553 | 550 |
| 554 void PluginInstallerImpl::ShowInstallDialog() { | 551 void PluginInstallerImpl::ShowInstallDialog() { |
| 555 enable_click_ = false; | 552 enable_click_ = false; |
| 556 install_dialog_.Initialize(this, plugin_name_); | 553 install_dialog_.Initialize(this, plugin_name_); |
| 557 install_dialog_.Create(hwnd(), NULL); | 554 install_dialog_.Create(m_hWnd, NULL); |
| 558 install_dialog_.ShowWindow(SW_SHOW); | 555 install_dialog_.ShowWindow(SW_SHOW); |
| 559 } | 556 } |
| 560 | 557 |
| 561 LRESULT PluginInstallerImpl::OnLButtonDown(UINT message, WPARAM wparam, | 558 LRESULT PluginInstallerImpl::OnLButtonDown(UINT message, WPARAM wparam, |
| 562 LPARAM lparam, BOOL& handled) { | 559 LPARAM lparam, BOOL& handled) { |
| 563 if (!enable_click_) | 560 if (!enable_click_) |
| 564 return 0; | 561 return 0; |
| 565 if (plugin_installer_state() == PluginListDownloaded) { | 562 if (plugin_installer_state() == PluginListDownloaded) { |
| 566 ShowInstallDialog(); | 563 ShowInstallDialog(); |
| 567 NotifyPluginStatus(default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD); | 564 NotifyPluginStatus(default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD); |
| 568 } else if (plugin_installer_state_ == PluginInstallerLaunchSuccess) { | 565 } else if (plugin_installer_state_ == PluginInstallerLaunchSuccess) { |
| 569 DCHECK(default_plugin::g_browser); | 566 DCHECK(default_plugin::g_browser); |
| 570 DCHECK(default_plugin::g_browser->geturl); | 567 DCHECK(default_plugin::g_browser->geturl); |
| 571 default_plugin::g_browser->geturl( | 568 default_plugin::g_browser->geturl( |
| 572 instance_, | 569 instance_, |
| 573 "javascript:navigator.plugins.refresh(true)", | 570 "javascript:navigator.plugins.refresh(true)", |
| 574 "_self"); | 571 "_self"); |
| 575 default_plugin::g_browser->geturl( | 572 default_plugin::g_browser->geturl( |
| 576 instance_, | 573 instance_, |
| 577 "javascript:window.location.reload(true)", | 574 "javascript:window.location.reload(true)", |
| 578 "_self"); | 575 "_self"); |
| 579 } | 576 } |
| 580 | 577 |
| 581 return 0; | 578 return 0; |
| 582 } | 579 } |
| 583 | 580 |
| 584 LRESULT PluginInstallerImpl::OnSetCursor(UINT message, WPARAM wparam, | 581 LRESULT PluginInstallerImpl::OnSetCursor(UINT message, WPARAM wparam, |
| 585 LPARAM lparam, BOOL& handled) { | 582 LPARAM lparam, BOOL& handled) { |
| 586 if (enable_click_) { | 583 if (enable_click_) { |
| 587 SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); | 584 ::SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); |
| 588 return 1; | 585 return 1; |
| 589 } | 586 } |
| 590 handled = FALSE; | 587 handled = FALSE; |
| 591 return 0; | 588 return 0; |
| 592 } | 589 } |
| 593 | 590 |
| 594 LRESULT PluginInstallerImpl::OnRefreshPlugins(UINT message, WPARAM wparam, | 591 LRESULT PluginInstallerImpl::OnRefreshPlugins(UINT message, WPARAM wparam, |
| 595 LPARAM lparam, BOOL& handled) { | 592 LPARAM lparam, BOOL& handled) { |
| 596 DCHECK(default_plugin::g_browser); | 593 DCHECK(default_plugin::g_browser); |
| 597 DCHECK(default_plugin::g_browser->geturl); | 594 DCHECK(default_plugin::g_browser->geturl); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 650 |
| 654 LRESULT PluginInstallerImpl::OnActiveXInstallResult(UINT message, | 651 LRESULT PluginInstallerImpl::OnActiveXInstallResult(UINT message, |
| 655 WPARAM wparam, | 652 WPARAM wparam, |
| 656 LPARAM lparam, | 653 LPARAM lparam, |
| 657 BOOL& handled) { | 654 BOOL& handled) { |
| 658 handled = TRUE; | 655 handled = TRUE; |
| 659 | 656 |
| 660 if (SUCCEEDED(wparam)) { | 657 if (SUCCEEDED(wparam)) { |
| 661 set_plugin_installer_state(PluginInstallerLaunchSuccess); | 658 set_plugin_installer_state(PluginInstallerLaunchSuccess); |
| 662 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG); | 659 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG); |
| 663 PostMessage(hwnd(), kRefreshPluginsMessage, 0, 0); | 660 PostMessage(kRefreshPluginsMessage, 0, 0); |
| 664 } else if ((wparam == INET_E_UNKNOWN_PROTOCOL) || | 661 } else if ((wparam == INET_E_UNKNOWN_PROTOCOL) || |
| 665 (wparam == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND))) { | 662 (wparam == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND))) { |
| 666 set_plugin_installer_state(PluginDownloadFailed); | 663 set_plugin_installer_state(PluginDownloadFailed); |
| 667 DisplayPluginDownloadFailedStatus(); | 664 DisplayPluginDownloadFailedStatus(); |
| 668 } else { | 665 } else { |
| 669 set_plugin_installer_state(PluginInstallerLaunchFailure); | 666 set_plugin_installer_state(PluginInstallerLaunchFailure); |
| 670 DisplayStatus(IDS_DEFAULT_PLUGIN_INSTALLATION_FAILED_MSG); | 667 DisplayStatus(IDS_DEFAULT_PLUGIN_INSTALLATION_FAILED_MSG); |
| 671 } | 668 } |
| 672 return 0; | 669 return 0; |
| 673 } | 670 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 return true; | 772 return true; |
| 776 } | 773 } |
| 777 | 774 |
| 778 void PluginInstallerImpl::NotifyPluginStatus(int status) { | 775 void PluginInstallerImpl::NotifyPluginStatus(int status) { |
| 779 default_plugin::g_browser->getvalue( | 776 default_plugin::g_browser->getvalue( |
| 780 instance_, | 777 instance_, |
| 781 static_cast<NPNVariable>( | 778 static_cast<NPNVariable>( |
| 782 default_plugin::kMissingPluginStatusStart + status), | 779 default_plugin::kMissingPluginStatusStart + status), |
| 783 NULL); | 780 NULL); |
| 784 } | 781 } |
| OLD | NEW |