| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/plugin_installer.h" | 5 #include "chrome/browser/plugin_installer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/process.h" | 10 #include "base/process.h" |
| 11 #include "chrome/browser/download/download_service.h" | 11 #include "chrome/browser/download/download_service.h" |
| 12 #include "chrome/browser/download/download_service_factory.h" | 12 #include "chrome/browser/download/download_service_factory.h" |
| 13 #include "chrome/browser/download/download_util.h" | 13 #include "chrome/browser/download/download_util.h" |
| 14 #include "chrome/browser/platform_util.h" | 14 #include "chrome/browser/platform_util.h" |
| 15 #include "chrome/browser/plugin_installer_observer.h" | 15 #include "chrome/browser/plugin_installer_observer.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 17 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
| 19 #include "content/public/browser/download_id.h" | 19 #include "content/public/browser/download_id.h" |
| 20 #include "content/public/browser/download_item.h" | 20 #include "content/public/browser/download_item.h" |
| 21 #include "content/public/browser/download_manager.h" | 21 #include "content/public/browser/download_manager.h" |
| 22 #include "content/public/browser/download_save_info.h" | 22 #include "content/public/browser/download_save_info.h" |
| 23 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
| 25 #include "content/public/browser/resource_context.h" | 25 #include "content/public/browser/resource_context.h" |
| 26 #include "content/public/browser/resource_dispatcher_host.h" | 26 #include "content/public/browser/resource_dispatcher_host.h" |
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
| 29 #include "webkit/plugins/npapi/plugin_group.h" | 29 #include "webkit/plugins/npapi/plugin_utils.h" |
| 30 #include "webkit/plugins/webplugininfo.h" |
| 30 | 31 |
| 31 using content::BrowserContext; | 32 using content::BrowserContext; |
| 32 using content::BrowserThread; | 33 using content::BrowserThread; |
| 33 using content::DownloadItem; | 34 using content::DownloadItem; |
| 34 using content::DownloadManager; | 35 using content::DownloadManager; |
| 35 using content::ResourceDispatcherHost; | 36 using content::ResourceDispatcherHost; |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| 39 void BeginDownload( | 40 void BeginDownload( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 versions_[version] = status; | 91 versions_[version] = status; |
| 91 } | 92 } |
| 92 | 93 |
| 93 PluginInstaller::SecurityStatus PluginInstaller::GetSecurityStatus( | 94 PluginInstaller::SecurityStatus PluginInstaller::GetSecurityStatus( |
| 94 const webkit::WebPluginInfo& plugin) const { | 95 const webkit::WebPluginInfo& plugin) const { |
| 95 // If there are no versions defined, the plug-in should require authorization. | 96 // If there are no versions defined, the plug-in should require authorization. |
| 96 if (versions_.empty()) | 97 if (versions_.empty()) |
| 97 return SECURITY_STATUS_REQUIRES_AUTHORIZATION; | 98 return SECURITY_STATUS_REQUIRES_AUTHORIZATION; |
| 98 | 99 |
| 99 Version version; | 100 Version version; |
| 100 webkit::npapi::PluginGroup::CreateVersionFromString(plugin.version, &version); | 101 webkit::npapi::CreateVersionFromString(plugin.version, &version); |
| 101 if (!version.IsValid()) | 102 if (!version.IsValid()) |
| 102 version = Version("0"); | 103 version = Version("0"); |
| 103 | 104 |
| 104 // |lower_bound| returns the latest version that is not newer than |version|. | 105 // |lower_bound| returns the latest version that is not newer than |version|. |
| 105 std::map<Version, SecurityStatus, VersionComparator>::const_iterator it = | 106 std::map<Version, SecurityStatus, VersionComparator>::const_iterator it = |
| 106 versions_.lower_bound(version); | 107 versions_.lower_bound(version); |
| 107 // If there is at least one version defined, everything older than the oldest | 108 // If there is at least one version defined, everything older than the oldest |
| 108 // defined version is considered out-of-date. | 109 // defined version is considered out-of-date. |
| 109 if (it == versions_.end()) | 110 if (it == versions_.end()) |
| 110 return SECURITY_STATUS_OUT_OF_DATE; | 111 return SECURITY_STATUS_OUT_OF_DATE; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); | 244 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); |
| 244 state_ = INSTALLER_STATE_IDLE; | 245 state_ = INSTALLER_STATE_IDLE; |
| 245 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); | 246 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); |
| 246 } | 247 } |
| 247 | 248 |
| 248 void PluginInstaller::DownloadCancelled() { | 249 void PluginInstaller::DownloadCancelled() { |
| 249 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); | 250 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); |
| 250 state_ = INSTALLER_STATE_IDLE; | 251 state_ = INSTALLER_STATE_IDLE; |
| 251 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); | 252 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); |
| 252 } | 253 } |
| OLD | NEW |