| 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 "content/common/child_thread.h" | 14 #include "content/common/child_thread.h" |
| 15 #include "content/common/plugin_messages.h" | 15 #include "content/common/plugin_messages.h" |
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 #include "grit/webkit_strings.h" | 17 #include "grit/webkit_strings.h" |
| 18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 19 #include "unicode/locid.h" | 19 #include "unicode/locid.h" |
| 20 #include "webkit/glue/webkit_glue.h" | 20 #include "webkit/glue/webkit_glue.h" |
| 21 #include "webkit/plugins/npapi/default_plugin_shared.h" | 21 #include "webkit/plugins/npapi/default_plugin_shared.h" |
| 22 | 22 |
| 23 static const int TOOLTIP_MAX_WIDTH = 500; | 23 static const int TOOLTIP_MAX_WIDTH = 500; |
| 24 | 24 |
| 25 namespace { | |
| 26 | |
| 27 bool GetPluginFinderURL(std::string* plugin_finder_url) { | |
| 28 if (!plugin_finder_url) { | |
| 29 NOTREACHED(); | |
| 30 return false; | |
| 31 } | |
| 32 | |
| 33 ChildThread::current()->Send( | |
| 34 new PluginProcessHostMsg_GetPluginFinderUrl(plugin_finder_url)); | |
| 35 // If we get an empty string back this means the plugin finder has been | |
| 36 // disabled. | |
| 37 return true; | |
| 38 } | |
| 39 | |
| 40 bool DownloadUrl(const std::string& url, HWND caller_window) { | |
| 41 return ChildThread::current()->Send( | |
| 42 new PluginProcessHostMsg_DownloadUrl(MSG_ROUTING_NONE, url, | |
| 43 ::GetCurrentProcessId(), | |
| 44 caller_window)); | |
| 45 } | |
| 46 | |
| 47 } | |
| 48 | |
| 49 PluginInstallerImpl::PluginInstallerImpl(int16 mode) | 25 PluginInstallerImpl::PluginInstallerImpl(int16 mode) |
| 50 : instance_(NULL), | 26 : instance_(NULL), |
| 51 mode_(mode), | 27 mode_(mode), |
| 52 disable_plugin_finder_(false), | 28 disable_plugin_finder_(false), |
| 53 plugin_install_stream_(NULL), | 29 plugin_install_stream_(NULL), |
| 54 plugin_installer_state_(PluginInstallerStateUndefined), | 30 plugin_installer_state_(PluginInstallerStateUndefined), |
| 55 install_dialog_(NULL), | 31 install_dialog_(NULL), |
| 56 enable_click_(false), | 32 enable_click_(false), |
| 57 icon_(NULL), | 33 icon_(NULL), |
| 58 bold_font_(NULL), | 34 bold_font_(NULL), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 87 DCHECK(module_handle != NULL); | 63 DCHECK(module_handle != NULL); |
| 88 | 64 |
| 89 if (mime_type == NULL || strlen(mime_type) == 0) { | 65 if (mime_type == NULL || strlen(mime_type) == 0) { |
| 90 NOTREACHED() << __FUNCTION__ << " Invalid parameters passed in"; | 66 NOTREACHED() << __FUNCTION__ << " Invalid parameters passed in"; |
| 91 return false; | 67 return false; |
| 92 } | 68 } |
| 93 | 69 |
| 94 instance_ = instance; | 70 instance_ = instance; |
| 95 mime_type_ = mime_type; | 71 mime_type_ = mime_type; |
| 96 | 72 |
| 97 if (!GetPluginFinderURL(&plugin_finder_url_)) { | 73 ChildThread::current()->Send( |
| 98 NOTREACHED() << __FUNCTION__ << " Failed to get the plugin finder URL"; | 74 new PluginProcessHostMsg_GetPluginFinderUrl(&plugin_finder_url_)); |
| 99 return false; | |
| 100 } | |
| 101 | |
| 102 if (plugin_finder_url_.empty()) | 75 if (plugin_finder_url_.empty()) |
| 103 disable_plugin_finder_ = true; | 76 disable_plugin_finder_ = true; |
| 104 | 77 |
| 105 InitializeResources(module_handle); | 78 InitializeResources(module_handle); |
| 106 | 79 |
| 107 if (!disable_plugin_finder_) { | 80 if (!disable_plugin_finder_) { |
| 108 if (!installation_job_monitor_thread_->Initialize()) { | 81 if (!installation_job_monitor_thread_->Initialize()) { |
| 109 NOTREACHED() << "Failed to initialize plugin install job"; | 82 NOTREACHED() << "Failed to initialize plugin install job"; |
| 110 return false; | 83 return false; |
| 111 } | 84 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 334 |
| 362 void PluginInstallerImpl::DownloadPlugin() { | 335 void PluginInstallerImpl::DownloadPlugin() { |
| 363 set_plugin_installer_state(PluginDownloadInitiated); | 336 set_plugin_installer_state(PluginDownloadInitiated); |
| 364 | 337 |
| 365 DVLOG(1) << "Initiating download for plugin URL " | 338 DVLOG(1) << "Initiating download for plugin URL " |
| 366 << plugin_download_url_.c_str(); | 339 << plugin_download_url_.c_str(); |
| 367 | 340 |
| 368 DisplayStatus(IDS_DEFAULT_PLUGIN_DOWNLOADING_PLUGIN_MSG); | 341 DisplayStatus(IDS_DEFAULT_PLUGIN_DOWNLOADING_PLUGIN_MSG); |
| 369 | 342 |
| 370 if (!plugin_download_url_for_display_) { | 343 if (!plugin_download_url_for_display_) { |
| 371 DownloadUrl(plugin_download_url_, hwnd()); | 344 ChildThread::current()->Send(new PluginProcessHostMsg_DownloadUrl( |
| 345 plugin_download_url_, ::GetCurrentProcessId(), hwnd())); |
| 372 } else { | 346 } else { |
| 373 default_plugin::g_browser->geturl(instance(), | 347 default_plugin::g_browser->geturl(instance(), |
| 374 plugin_download_url_.c_str(), | 348 plugin_download_url_.c_str(), |
| 375 "_blank"); | 349 "_blank"); |
| 376 set_plugin_installer_state(PluginInstallerLaunchSuccess); | 350 set_plugin_installer_state(PluginInstallerLaunchSuccess); |
| 377 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG); | 351 DisplayStatus(IDS_DEFAULT_PLUGIN_REFRESH_PLUGIN_MSG); |
| 378 enable_click_ = true; | 352 enable_click_ = true; |
| 379 RefreshDisplay(); | 353 RefreshDisplay(); |
| 380 } | 354 } |
| 381 } | 355 } |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 return true; | 648 return true; |
| 675 } | 649 } |
| 676 | 650 |
| 677 void PluginInstallerImpl::NotifyPluginStatus(int status) { | 651 void PluginInstallerImpl::NotifyPluginStatus(int status) { |
| 678 default_plugin::g_browser->getvalue( | 652 default_plugin::g_browser->getvalue( |
| 679 instance_, | 653 instance_, |
| 680 static_cast<NPNVariable>( | 654 static_cast<NPNVariable>( |
| 681 webkit::npapi::default_plugin::kMissingPluginStatusStart + status), | 655 webkit::npapi::default_plugin::kMissingPluginStatusStart + status), |
| 682 NULL); | 656 NULL); |
| 683 } | 657 } |
| OLD | NEW |