Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: webkit/default_plugin/plugin_impl_win.cc

Issue 165469: Change PluginInstallImpl to use base::WindowImpl instead of CWindowImpl to re... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/default_plugin/plugin_impl_win.h ('k') | webkit/tools/test_shell/foreground_helper.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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()) { 121 if (IsWindow(hwnd())) {
122 DestroyWindow(); 122 DestroyWindow(hwnd());
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
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()) 171 if (!IsWindow(hwnd()))
172 return; 172 return;
173 UpdateToolTip(); 173 UpdateToolTip();
174 174
175 InvalidateRect(NULL, TRUE); 175 InvalidateRect(hwnd(), NULL, TRUE);
176 UpdateWindow(); 176 UpdateWindow(hwnd());
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 m_hWnd, NULL, NULL, NULL); 185 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 = m_hWnd; 192 tool_info.hwnd = 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>(m_hWnd); 194 tool_info.uId = reinterpret_cast<UINT_PTR>(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 = m_hWnd; 210 tool_info.hwnd = hwnd();
211 tool_info.uFlags = TTF_IDISHWND; 211 tool_info.uFlags = TTF_IDISHWND;
212 tool_info.uId = reinterpret_cast<UINT_PTR>(m_hWnd); 212 tool_info.uId = reinterpret_cast<UINT_PTR>(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
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()) 321 if (!IsWindow(hwnd()))
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()) { 330 if (IsWindow(hwnd())) {
331 ::GetClientRect(parent_window, &parent_rect); 331 GetClientRect(parent_window, &parent_rect);
332 SetWindowPos(NULL, &parent_rect, SWP_SHOWWINDOW); 332 SetWindowPos(hwnd(), NULL, parent_rect.left, parent_rect.top,
333 parent_rect.right - parent_rect.left,
334 parent_rect.bottom - parent_rect.top, SWP_SHOWWINDOW);
333 return true; 335 return true;
334 } 336 }
335 // First time in -- no window created by plugin yet. 337 // First time in -- no window created by plugin yet.
336 ::GetClientRect(parent_window, &parent_rect); 338 GetClientRect(parent_window, &parent_rect);
337 Create(parent_window, parent_rect, NULL, WS_CHILD | WS_BORDER); 339 set_window_style(WS_CHILD | WS_BORDER);
338 DCHECK(IsWindow()); 340 Init(parent_window, gfx::Rect(parent_rect));
339 installation_job_monitor_thread_->set_plugin_window(m_hWnd); 341 DCHECK(IsWindow(hwnd()));
342 installation_job_monitor_thread_->set_plugin_window(hwnd());
340 343
341 CreateToolTip(); 344 CreateToolTip();
342 UpdateToolTip(); 345 UpdateToolTip();
343 346
344 UpdateWindow(); 347 UpdateWindow(hwnd());
345 ShowWindow(SW_SHOW); 348 ShowWindow(hwnd(), SW_SHOW);
346 349
347 return true; 350 return true;
348 } 351 }
349 352
350 void PluginInstallerImpl::DownloadPlugin() { 353 void PluginInstallerImpl::DownloadPlugin() {
351 set_plugin_installer_state(PluginDownloadInitiated); 354 set_plugin_installer_state(PluginDownloadInitiated);
352 355
353 DLOG(INFO) << "Initiating download for plugin URL " 356 DLOG(INFO) << "Initiating download for plugin URL "
354 << plugin_download_url_.c_str(); 357 << plugin_download_url_.c_str();
355 358
356 DisplayStatus(IDS_DEFAULT_PLUGIN_DOWNLOADING_PLUGIN_MSG); 359 DisplayStatus(IDS_DEFAULT_PLUGIN_DOWNLOADING_PLUGIN_MSG);
357 360
358 if (is_activex_) { 361 if (is_activex_) {
359 if (activex_installer_ == NULL) { 362 if (activex_installer_ == NULL) {
360 CComObject<ActiveXInstaller>::CreateInstance(&activex_installer_); 363 CComObject<ActiveXInstaller>::CreateInstance(&activex_installer_);
361 activex_installer_->AddRef(); 364 activex_installer_->AddRef();
362 } 365 }
363 activex_installer_->StartDownload(activex_clsid_, activex_codebase_, m_hWnd, 366 activex_installer_->StartDownload(activex_clsid_, activex_codebase_,
364 kActivexInstallResult); 367 hwnd(), kActivexInstallResult);
365 } else { 368 } else {
366 if (!plugin_download_url_for_display_) { 369 if (!plugin_download_url_for_display_) {
367 webkit_glue::DownloadUrl(plugin_download_url_, m_hWnd); 370 webkit_glue::DownloadUrl(plugin_download_url_, hwnd());
368 } else { 371 } else {
369 default_plugin::g_browser->geturl(instance(), 372 default_plugin::g_browser->geturl(instance(),
370 plugin_download_url_.c_str(), 373 plugin_download_url_.c_str(),
371 "_blank"); 374 "_blank");
372 set_plugin_installer_state(PluginInstallerLaunchSuccess); 375 set_plugin_installer_state(PluginInstallerLaunchSuccess);
373 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG); 376 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG);
374 enable_click_ = true; 377 enable_click_ = true;
375 RefreshDisplay(); 378 RefreshDisplay();
376 } 379 }
377 } 380 }
378 } 381 }
379 382
380 void PluginInstallerImpl::DownloadCancelled() { 383 void PluginInstallerImpl::DownloadCancelled() {
381 DisplayAvailablePluginStatus(); 384 DisplayAvailablePluginStatus();
382 } 385 }
383 386
384 LRESULT PluginInstallerImpl::OnEraseBackGround(UINT message, WPARAM wparam, 387 LRESULT PluginInstallerImpl::OnEraseBackGround(UINT message, WPARAM wparam,
385 LPARAM lparam, BOOL& handled) { 388 LPARAM lparam, BOOL& handled) {
386 HDC paint_device_context = reinterpret_cast<HDC>(wparam); 389 HDC paint_device_context = reinterpret_cast<HDC>(wparam);
387 RECT erase_rect = {0}; 390 RECT erase_rect = {0};
388 ::GetClipBox(paint_device_context, &erase_rect); 391 GetClipBox(paint_device_context, &erase_rect);
389 HBRUSH brush = ::CreateSolidBrush(RGB(252, 235, 162)); 392 HBRUSH brush = ::CreateSolidBrush(RGB(252, 235, 162));
390 DCHECK(brush); 393 DCHECK(brush);
391 ::FillRect(paint_device_context, &erase_rect, brush); 394 FillRect(paint_device_context, &erase_rect, brush);
392 ::DeleteObject(brush); 395 DeleteObject(brush);
393 return 1; 396 return 1;
394 } 397 }
395 398
396 // Use ICU in order to determine whether the locale is right-to-left. 399 // Use ICU in order to determine whether the locale is right-to-left.
397 // 400 //
398 // TODO(idana) bug# 1246452: there is already code in 401 // TODO(idana) bug# 1246452: there is already code in
399 // app/l10n_util.h/cc that uses ICU to determine the locale direction. We don't 402 // app/l10n_util.h/cc that uses ICU to determine the locale direction. We don't
400 // currently use this code since code in WebKit should not depend on code in 403 // currently use this code since code in WebKit should not depend on code in
401 // Chrome. We can fix this by pulling (at least part of) the l10n_util 404 // Chrome. We can fix this by pulling (at least part of) the l10n_util
402 // functionality up into the Base module. 405 // functionality up into the Base module.
403 bool PluginInstallerImpl::IsRTLLayout() const { 406 bool PluginInstallerImpl::IsRTLLayout() const {
404 const Locale& locale = Locale::getDefault(); 407 const Locale& locale = Locale::getDefault();
405 const char* lang = locale.getLanguage(); 408 const char* lang = locale.getLanguage();
406 409
407 // Check only for Arabic and Hebrew languages for now. 410 // Check only for Arabic and Hebrew languages for now.
408 if (strcmp(lang, "ar") == 0 || strcmp(lang, "he") == 0) { 411 if (strcmp(lang, "ar") == 0 || strcmp(lang, "he") == 0) {
409 return true; 412 return true;
410 } 413 }
411 return false; 414 return false;
412 } 415 }
413 416
414 LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam, 417 LRESULT PluginInstallerImpl::OnPaint(UINT message, WPARAM wparam, LPARAM lparam,
415 BOOL& handled) { 418 BOOL& handled) {
416 PAINTSTRUCT paint_struct = {0}; 419 PAINTSTRUCT paint_struct = {0};
417 BeginPaint(&paint_struct); 420 BeginPaint(hwnd(), &paint_struct);
418 421
419 int save_dc_context = SaveDC(paint_struct.hdc); 422 int save_dc_context = SaveDC(paint_struct.hdc);
420 // The drawing order is as below:- 423 // The drawing order is as below:-
421 // 1. The Get plugin link at the top left corner. 424 // 1. The Get plugin link at the top left corner.
422 // 2. The plugin icon. 425 // 2. The plugin icon.
423 // 3. The text describing user actions to the right of the icon. 426 // 3. The text describing user actions to the right of the icon.
424 SIZE get_plugin_link_extents = {0}; 427 SIZE get_plugin_link_extents = {0};
425 HFONT old_font = 428 HFONT old_font =
426 reinterpret_cast<HFONT>(SelectObject(paint_struct.hdc, regular_font_)); 429 reinterpret_cast<HFONT>(SelectObject(paint_struct.hdc, regular_font_));
427 430
428 GetTextExtentPoint32(paint_struct.hdc, get_plugin_link_message_.c_str(), 431 GetTextExtentPoint32(paint_struct.hdc, get_plugin_link_message_.c_str(),
429 static_cast<int>(get_plugin_link_message_.length()), 432 static_cast<int>(get_plugin_link_message_.length()),
430 &get_plugin_link_extents); 433 &get_plugin_link_extents);
431 434
432 POINT device_point = {0}; 435 POINT device_point = {0};
433 device_point.x = get_plugin_link_extents.cx; 436 device_point.x = get_plugin_link_extents.cx;
434 device_point.y = get_plugin_link_extents.cy; 437 device_point.y = get_plugin_link_extents.cy;
435 LPtoDP(paint_struct.hdc, &device_point, 1); 438 LPtoDP(paint_struct.hdc, &device_point, 1);
436 439
437 RECT text_rect = {0}; 440 RECT text_rect = {0};
438 text_rect.left = 5; 441 text_rect.left = 5;
439 text_rect.right = text_rect.left + device_point.x; 442 text_rect.right = text_rect.left + device_point.x;
440 text_rect.top = 5; 443 text_rect.top = 5;
441 text_rect.bottom = text_rect.top + device_point.y; 444 text_rect.bottom = text_rect.top + device_point.y;
442 445
443 RECT client_rect = {0}; 446 RECT client_rect = {0};
444 GetClientRect(&client_rect); 447 GetClientRect(hwnd(), &client_rect);
445 448
446 int icon_width = GetSystemMetrics(SM_CXICON); 449 int icon_width = GetSystemMetrics(SM_CXICON);
447 int icon_height = GetSystemMetrics(SM_CYICON); 450 int icon_height = GetSystemMetrics(SM_CYICON);
448 451
449 int x = (client_rect.right / 2) - icon_width / 2; 452 int x = (client_rect.right / 2) - icon_width / 2;
450 int y = (client_rect.bottom / 2) - icon_height / 2; 453 int y = (client_rect.bottom / 2) - icon_height / 2;
451 454
452 DCHECK(icon_); 455 DCHECK(icon_);
453 DrawIcon(paint_struct.hdc, x, y, icon_); 456 DrawIcon(paint_struct.hdc, x, y, icon_);
454 457
(...skipping 29 matching lines...) Expand all
484 // over the plugin window. 487 // over the plugin window.
485 int window_width = client_rect.right - client_rect.left; 488 int window_width = client_rect.right - client_rect.left;
486 int window_height = client_rect.bottom - client_rect.top; 489 int window_height = client_rect.bottom - client_rect.top;
487 490
488 if ((x_origin + command_extents.cx <= window_width) && 491 if ((x_origin + command_extents.cx <= window_width) &&
489 (y_origin + command_extents.cy <= window_height)) { 492 (y_origin + command_extents.cy <= window_height)) {
490 PaintUserActionInformation(paint_struct.hdc, x_origin, y_origin); 493 PaintUserActionInformation(paint_struct.hdc, x_origin, y_origin);
491 } 494 }
492 495
493 RestoreDC(paint_struct.hdc, save_dc_context); 496 RestoreDC(paint_struct.hdc, save_dc_context);
494 EndPaint(&paint_struct); 497 EndPaint(hwnd(), &paint_struct);
495 return 0; 498 return 0;
496 } 499 }
497 500
498 void PluginInstallerImpl::PaintUserActionInformation(HDC paint_dc, 501 void PluginInstallerImpl::PaintUserActionInformation(HDC paint_dc,
499 int x_origin, 502 int x_origin,
500 int y_origin) { 503 int y_origin) {
501 SelectObject(paint_dc, regular_font_); 504 SelectObject(paint_dc, regular_font_);
502 505
503 SIZE command_extents = {0}; 506 SIZE command_extents = {0};
504 GetTextExtentPoint32(paint_dc, command_.c_str(), 507 GetTextExtentPoint32(paint_dc, command_.c_str(),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 547
545 DrawText(paint_dc, optional_additional_message_.c_str(), 548 DrawText(paint_dc, optional_additional_message_.c_str(),
546 static_cast<int>(optional_additional_message_.length()), 549 static_cast<int>(optional_additional_message_.length()),
547 &text_rect, DT_CENTER | DT_VCENTER | additional_dt_flags); 550 &text_rect, DT_CENTER | DT_VCENTER | additional_dt_flags);
548 } 551 }
549 } 552 }
550 553
551 void PluginInstallerImpl::ShowInstallDialog() { 554 void PluginInstallerImpl::ShowInstallDialog() {
552 enable_click_ = false; 555 enable_click_ = false;
553 install_dialog_.Initialize(this, plugin_name_); 556 install_dialog_.Initialize(this, plugin_name_);
554 install_dialog_.Create(m_hWnd, NULL); 557 install_dialog_.Create(hwnd(), NULL);
555 install_dialog_.ShowWindow(SW_SHOW); 558 install_dialog_.ShowWindow(SW_SHOW);
556 } 559 }
557 560
558 LRESULT PluginInstallerImpl::OnLButtonDown(UINT message, WPARAM wparam, 561 LRESULT PluginInstallerImpl::OnLButtonDown(UINT message, WPARAM wparam,
559 LPARAM lparam, BOOL& handled) { 562 LPARAM lparam, BOOL& handled) {
560 if (!enable_click_) 563 if (!enable_click_)
561 return 0; 564 return 0;
562 if (plugin_installer_state() == PluginListDownloaded) { 565 if (plugin_installer_state() == PluginListDownloaded) {
563 ShowInstallDialog(); 566 ShowInstallDialog();
564 NotifyPluginStatus(default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD); 567 NotifyPluginStatus(default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD);
565 } else if (plugin_installer_state_ == PluginInstallerLaunchSuccess) { 568 } else if (plugin_installer_state_ == PluginInstallerLaunchSuccess) {
566 DCHECK(default_plugin::g_browser); 569 DCHECK(default_plugin::g_browser);
567 DCHECK(default_plugin::g_browser->geturl); 570 DCHECK(default_plugin::g_browser->geturl);
568 default_plugin::g_browser->geturl( 571 default_plugin::g_browser->geturl(
569 instance_, 572 instance_,
570 "javascript:navigator.plugins.refresh(true)", 573 "javascript:navigator.plugins.refresh(true)",
571 "_self"); 574 "_self");
572 default_plugin::g_browser->geturl( 575 default_plugin::g_browser->geturl(
573 instance_, 576 instance_,
574 "javascript:window.location.reload(true)", 577 "javascript:window.location.reload(true)",
575 "_self"); 578 "_self");
576 } 579 }
577 580
578 return 0; 581 return 0;
579 } 582 }
580 583
581 LRESULT PluginInstallerImpl::OnSetCursor(UINT message, WPARAM wparam, 584 LRESULT PluginInstallerImpl::OnSetCursor(UINT message, WPARAM wparam,
582 LPARAM lparam, BOOL& handled) { 585 LPARAM lparam, BOOL& handled) {
583 if (enable_click_) { 586 if (enable_click_) {
584 ::SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); 587 SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND)));
585 return 1; 588 return 1;
586 } 589 }
587 handled = FALSE; 590 handled = FALSE;
588 return 0; 591 return 0;
589 } 592 }
590 593
591 LRESULT PluginInstallerImpl::OnRefreshPlugins(UINT message, WPARAM wparam, 594 LRESULT PluginInstallerImpl::OnRefreshPlugins(UINT message, WPARAM wparam,
592 LPARAM lparam, BOOL& handled) { 595 LPARAM lparam, BOOL& handled) {
593 DCHECK(default_plugin::g_browser); 596 DCHECK(default_plugin::g_browser);
594 DCHECK(default_plugin::g_browser->geturl); 597 DCHECK(default_plugin::g_browser->geturl);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 653
651 LRESULT PluginInstallerImpl::OnActiveXInstallResult(UINT message, 654 LRESULT PluginInstallerImpl::OnActiveXInstallResult(UINT message,
652 WPARAM wparam, 655 WPARAM wparam,
653 LPARAM lparam, 656 LPARAM lparam,
654 BOOL& handled) { 657 BOOL& handled) {
655 handled = TRUE; 658 handled = TRUE;
656 659
657 if (SUCCEEDED(wparam)) { 660 if (SUCCEEDED(wparam)) {
658 set_plugin_installer_state(PluginInstallerLaunchSuccess); 661 set_plugin_installer_state(PluginInstallerLaunchSuccess);
659 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG); 662 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG);
660 PostMessage(kRefreshPluginsMessage, 0, 0); 663 PostMessage(hwnd(), kRefreshPluginsMessage, 0, 0);
661 } else if ((wparam == INET_E_UNKNOWN_PROTOCOL) || 664 } else if ((wparam == INET_E_UNKNOWN_PROTOCOL) ||
662 (wparam == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND))) { 665 (wparam == HRESULT_FROM_WIN32(ERROR_MOD_NOT_FOUND))) {
663 set_plugin_installer_state(PluginDownloadFailed); 666 set_plugin_installer_state(PluginDownloadFailed);
664 DisplayPluginDownloadFailedStatus(); 667 DisplayPluginDownloadFailedStatus();
665 } else { 668 } else {
666 set_plugin_installer_state(PluginInstallerLaunchFailure); 669 set_plugin_installer_state(PluginInstallerLaunchFailure);
667 DisplayStatus(IDS_DEFAULT_PLUGIN_INSTALLATION_FAILED_MSG); 670 DisplayStatus(IDS_DEFAULT_PLUGIN_INSTALLATION_FAILED_MSG);
668 } 671 }
669 return 0; 672 return 0;
670 } 673 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 return true; 775 return true;
773 } 776 }
774 777
775 void PluginInstallerImpl::NotifyPluginStatus(int status) { 778 void PluginInstallerImpl::NotifyPluginStatus(int status) {
776 default_plugin::g_browser->getvalue( 779 default_plugin::g_browser->getvalue(
777 instance_, 780 instance_,
778 static_cast<NPNVariable>( 781 static_cast<NPNVariable>(
779 default_plugin::kMissingPluginStatusStart + status), 782 default_plugin::kMissingPluginStatusStart + status),
780 NULL); 783 NULL);
781 } 784 }
OLDNEW
« no previous file with comments | « webkit/default_plugin/plugin_impl_win.h ('k') | webkit/tools/test_shell/foreground_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698