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/default_plugin/plugin_impl_win.h" | 5 #include "chrome/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" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "chrome/default_plugin/plugin_main.h" | 13 #include "chrome/default_plugin/plugin_main.h" |
14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
15 #include "grit/webkit_strings.h" | 15 #include "grit/webkit_strings.h" |
16 #include "unicode/locid.h" | 16 #include "unicode/locid.h" |
17 #include "webkit/glue/webkit_glue.h" | 17 #include "webkit/glue/webkit_glue.h" |
18 #include "webkit/plugins/npapi/default_plugin_shared.h" | 18 #include "webkit/glue/plugins/default_plugin_shared.h" |
19 | 19 |
20 static const int TOOLTIP_MAX_WIDTH = 500; | 20 static const int TOOLTIP_MAX_WIDTH = 500; |
21 | 21 |
22 PluginInstallerImpl::PluginInstallerImpl(int16 mode) | 22 PluginInstallerImpl::PluginInstallerImpl(int16 mode) |
23 : instance_(NULL), | 23 : instance_(NULL), |
24 mode_(mode), | 24 mode_(mode), |
25 plugin_install_stream_(NULL), | 25 plugin_install_stream_(NULL), |
26 plugin_installer_state_(PluginInstallerStateUndefined), | 26 plugin_installer_state_(PluginInstallerStateUndefined), |
27 install_dialog_(NULL), | 27 install_dialog_(NULL), |
28 enable_click_(false), | 28 enable_click_(false), |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 } else { | 243 } else { |
244 DLOG(WARNING) << "Failed to download plugin list"; | 244 DLOG(WARNING) << "Failed to download plugin list"; |
245 set_plugin_installer_state(PluginListDownloadFailed); | 245 set_plugin_installer_state(PluginListDownloadFailed); |
246 | 246 |
247 plugin_database_handler_.Close(true); | 247 plugin_database_handler_.Close(true); |
248 } | 248 } |
249 | 249 |
250 if (plugin_available) { | 250 if (plugin_available) { |
251 DVLOG(1) << "Plugin available for mime type " << mime_type_; | 251 DVLOG(1) << "Plugin available for mime type " << mime_type_; |
252 DisplayAvailablePluginStatus(); | 252 DisplayAvailablePluginStatus(); |
253 NotifyPluginStatus( | 253 NotifyPluginStatus(default_plugin::MISSING_PLUGIN_AVAILABLE); |
254 webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE); | |
255 } else { | 254 } else { |
256 DLOG(WARNING) << "No plugin available for mime type " << mime_type_; | 255 DLOG(WARNING) << "No plugin available for mime type " << mime_type_; |
257 DisplayStatus(IDS_DEFAULT_PLUGIN_NO_PLUGIN_AVAILABLE_MSG); | 256 DisplayStatus(IDS_DEFAULT_PLUGIN_NO_PLUGIN_AVAILABLE_MSG); |
258 } | 257 } |
259 } | 258 } |
260 } | 259 } |
261 | 260 |
262 int16 PluginInstallerImpl::NPP_HandleEvent(void* event) { | 261 int16 PluginInstallerImpl::NPP_HandleEvent(void* event) { |
263 NPEvent* npp_event = static_cast<NPEvent*>(event); | 262 NPEvent* npp_event = static_cast<NPEvent*>(event); |
264 if (npp_event->event == | 263 if (npp_event->event == default_plugin::kInstallMissingPluginMessage) { |
265 webkit::npapi::default_plugin::kInstallMissingPluginMessage) { | |
266 // We could get this message because InfoBar may not be in sync with our | 264 // We could get this message because InfoBar may not be in sync with our |
267 // internal processing. So we need to check the status. | 265 // internal processing. So we need to check the status. |
268 if (plugin_installer_state() == PluginListDownloaded) { | 266 if (plugin_installer_state() == PluginListDownloaded) { |
269 ShowInstallDialog(); | 267 ShowInstallDialog(); |
270 } | 268 } |
271 } | 269 } |
272 return 0; | 270 return 0; |
273 } | 271 } |
274 | 272 |
275 std::wstring PluginInstallerImpl::ReplaceStringForPossibleEmptyReplacement( | 273 std::wstring PluginInstallerImpl::ReplaceStringForPossibleEmptyReplacement( |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 enable_click_ = false; | 520 enable_click_ = false; |
523 install_dialog_->ShowInstallDialog(hwnd()); | 521 install_dialog_->ShowInstallDialog(hwnd()); |
524 } | 522 } |
525 | 523 |
526 LRESULT PluginInstallerImpl::OnLButtonDown(UINT message, WPARAM wparam, | 524 LRESULT PluginInstallerImpl::OnLButtonDown(UINT message, WPARAM wparam, |
527 LPARAM lparam, BOOL& handled) { | 525 LPARAM lparam, BOOL& handled) { |
528 if (!enable_click_) | 526 if (!enable_click_) |
529 return 0; | 527 return 0; |
530 if (plugin_installer_state() == PluginListDownloaded) { | 528 if (plugin_installer_state() == PluginListDownloaded) { |
531 ShowInstallDialog(); | 529 ShowInstallDialog(); |
532 NotifyPluginStatus( | 530 NotifyPluginStatus(default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD); |
533 webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD); | |
534 } else if (plugin_installer_state_ == PluginInstallerLaunchSuccess) { | 531 } else if (plugin_installer_state_ == PluginInstallerLaunchSuccess) { |
535 DCHECK(default_plugin::g_browser); | 532 DCHECK(default_plugin::g_browser); |
536 DCHECK(default_plugin::g_browser->geturl); | 533 DCHECK(default_plugin::g_browser->geturl); |
537 default_plugin::g_browser->geturl( | 534 default_plugin::g_browser->geturl( |
538 instance_, | 535 instance_, |
539 "javascript:navigator.plugins.refresh(true)", | 536 "javascript:navigator.plugins.refresh(true)", |
540 "_self"); | 537 "_self"); |
541 default_plugin::g_browser->geturl( | 538 default_plugin::g_browser->geturl( |
542 instance_, | 539 instance_, |
543 "javascript:window.location.reload(true)", | 540 "javascript:window.location.reload(true)", |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 font_info.lfUnderline = TRUE; | 635 font_info.lfUnderline = TRUE; |
639 underline_font_ = CreateFontIndirect(&font_info); | 636 underline_font_ = CreateFontIndirect(&font_info); |
640 DCHECK(underline_font_ != NULL); | 637 DCHECK(underline_font_ != NULL); |
641 return true; | 638 return true; |
642 } | 639 } |
643 | 640 |
644 void PluginInstallerImpl::NotifyPluginStatus(int status) { | 641 void PluginInstallerImpl::NotifyPluginStatus(int status) { |
645 default_plugin::g_browser->getvalue( | 642 default_plugin::g_browser->getvalue( |
646 instance_, | 643 instance_, |
647 static_cast<NPNVariable>( | 644 static_cast<NPNVariable>( |
648 webkit::npapi::default_plugin::kMissingPluginStatusStart + status), | 645 default_plugin::kMissingPluginStatusStart + status), |
649 NULL); | 646 NULL); |
650 } | 647 } |
OLD | NEW |