diff options
author | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-12 14:00:43 +0000 |
---|---|---|
committer | rsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-12 14:00:43 +0000 |
commit | 88ca491d78b19e7b681943216483710322985fc5 (patch) | |
tree | e1fe0286f7afff7c402db198ddc1c0b252c14079 /chrome/browser/ui | |
parent | 588be018436093781847593513ec1e5875a532db (diff) | |
download | chromium_src-88ca491d78b19e7b681943216483710322985fc5.zip chromium_src-88ca491d78b19e7b681943216483710322985fc5.tar.gz chromium_src-88ca491d78b19e7b681943216483710322985fc5.tar.bz2 |
Finish moving plugin probing out of process.
This moves all browser-side synchronous callers to use the asynchronous
PluginService interface.
BUG=17863,95114
TEST=Covered by tests. Plugins still work.
Review URL: http://codereview.chromium.org/8071013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105069 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r-- | chrome/browser/ui/browser.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/drag_util.mm | 3 | ||||
-rw-r--r-- | chrome/browser/ui/webui/flash_ui.cc | 35 |
3 files changed, 32 insertions, 11 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 1cafc10..ea188b2 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -135,6 +135,7 @@ #include "content/browser/download/download_manager.h" #include "content/browser/download/save_package.h" #include "content/browser/host_zoom_map.h" +#include "content/browser/plugin_service.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/site_instance.h" #include "content/browser/tab_contents/interstitial_page.h" @@ -188,8 +189,6 @@ #include "chrome/browser/extensions/file_manager_util.h" #endif -#include "webkit/plugins/npapi/plugin_list.h" - using base::TimeDelta; /////////////////////////////////////////////////////////////////////////////// @@ -2509,7 +2508,7 @@ void Browser::CrashedPluginHelper(TabContents* tab, string16 plugin_name = plugin_path.LossyDisplayName(); webkit::WebPluginInfo plugin_info; - if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( + if (PluginService::GetInstance()->GetPluginInfoByPath( plugin_path, &plugin_info) && !plugin_info.name.empty()) { plugin_name = plugin_info.name; diff --git a/chrome/browser/ui/cocoa/drag_util.mm b/chrome/browser/ui/cocoa/drag_util.mm index a1e1462..2d3b4b2 100644 --- a/chrome/browser/ui/cocoa/drag_util.mm +++ b/chrome/browser/ui/cocoa/drag_util.mm @@ -84,14 +84,13 @@ static BOOL IsSupportedFileURL(Profile* profile, const GURL& url) { // TODO(bauerb): This possibly uses stale information, but it's guaranteed not // to do disk access. bool allow_wildcard = false; - bool stale = false; webkit::WebPluginInfo plugin; return PluginService::GetInstance()->GetPluginInfo( -1, // process ID MSG_ROUTING_NONE, // routing ID profile->GetResourceContext(), url, GURL(), mime_type, allow_wildcard, - &stale, &plugin, NULL); + NULL, &plugin, NULL); } BOOL IsUnsupportedDropData(Profile* profile, id<NSDraggingInfo> info) { diff --git a/chrome/browser/ui/webui/flash_ui.cc b/chrome/browser/ui/webui/flash_ui.cc index 0dd1076..074a687 100644 --- a/chrome/browser/ui/webui/flash_ui.cc +++ b/chrome/browser/ui/webui/flash_ui.cc @@ -12,6 +12,7 @@ #include "base/bind_helpers.h" #include "base/callback_old.h" #include "base/i18n/time_formatting.h" +#include "base/memory/weak_ptr.h" #include "base/string_number_conversions.h" #include "base/stringprintf.h" #include "base/threading/thread_restrictions.h" @@ -26,6 +27,7 @@ #include "chrome/common/chrome_version_info.h" #include "chrome/common/url_constants.h" #include "content/browser/gpu/gpu_data_manager.h" +#include "content/browser/plugin_service.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/user_metrics.h" #include "grit/browser_resources.h" @@ -34,7 +36,6 @@ #include "grit/theme_resources.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" -#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/webplugininfo.h" #if defined(OS_WIN) @@ -82,6 +83,9 @@ class FlashDOMHandler : public WebUIMessageHandler, // Callback for the GPU information update. void OnGpuInfoUpdate(); + // Callback for the Flash plugin information. + void OnGotPlugins(const std::vector<webkit::WebPluginInfo>& plugins); + private: // Called when we think we might have enough information to return data back // to the page. @@ -104,20 +108,27 @@ class FlashDOMHandler : public WebUIMessageHandler, // Crash list. scoped_refptr<CrashUploadList> upload_list_; + // Factory for the creating refs in callbacks. + base::WeakPtrFactory<FlashDOMHandler> weak_ptr_factory_; + // Whether the list of all crashes is available. bool crash_list_available_; // Whether the page has requested data. bool page_has_requested_data_; // Whether the GPU data has been collected. bool has_gpu_info_; + // Whether the plugin information is ready. + bool has_plugin_info_; DISALLOW_COPY_AND_ASSIGN(FlashDOMHandler); }; FlashDOMHandler::FlashDOMHandler() - : crash_list_available_(false), + : weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), + crash_list_available_(false), page_has_requested_data_(false), - has_gpu_info_(false) { + has_gpu_info_(false), + has_plugin_info_(false) { // Request Crash data asynchronously. upload_list_ = CrashUploadList::Create(this); upload_list_->LoadCrashListAsynchronously(); @@ -137,6 +148,9 @@ FlashDOMHandler::FlashDOMHandler() if (!gpu_data_manager_->GpuAccessAllowed()) OnGpuInfoUpdate(); + PluginService::GetInstance()->GetPlugins(base::Bind( + &FlashDOMHandler::OnGotPlugins, weak_ptr_factory_.GetWeakPtr())); + // And lastly, we fire off a timer to make sure we never get stuck at the // "Loading..." message. timeout_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kTimeout), @@ -175,11 +189,18 @@ void FlashDOMHandler::OnGpuInfoUpdate() { MaybeRespondToPage(); } +void FlashDOMHandler::OnGotPlugins( + const std::vector<webkit::WebPluginInfo>& plugins) { + has_plugin_info_ = true; + MaybeRespondToPage(); +} + void FlashDOMHandler::OnTimeout() { // We don't set page_has_requested_data_ because that is guaranteed to appear // and we shouldn't be responding to the page before then. has_gpu_info_ = true; crash_list_available_ = true; + has_plugin_info_ = true; MaybeRespondToPage(); } @@ -187,8 +208,10 @@ void FlashDOMHandler::MaybeRespondToPage() { // We don't reply until everything is ready. The page is showing a 'loading' // message until then. If you add criteria to this list, please update the // function OnTimeout() as well. - if (!page_has_requested_data_ || !crash_list_available_ || !has_gpu_info_) + if (!page_has_requested_data_ || !crash_list_available_ || !has_gpu_info_ || + !has_plugin_info_) { return; + } timeout_.Stop(); @@ -232,8 +255,8 @@ void FlashDOMHandler::MaybeRespondToPage() { // Obtain the version of the Flash plugins. std::vector<webkit::WebPluginInfo> info_array; - webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( - GURL(), "application/x-shockwave-flash", false, NULL, &info_array, NULL); + PluginService::GetInstance()->GetPluginInfoArray( + GURL(), "application/x-shockwave-flash", false, &info_array, NULL); string16 flash_version; if (info_array.empty()) { AddPair(list, ASCIIToUTF16("Flash plugin"), "Disabled"); |