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" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 DCHECK(versions_.find(version) == versions_.end()); | 89 DCHECK(versions_.find(version) == versions_.end()); |
90 versions_[version] = status; | 90 versions_[version] = status; |
91 } | 91 } |
92 | 92 |
93 PluginInstaller::SecurityStatus PluginInstaller::GetSecurityStatus( | 93 PluginInstaller::SecurityStatus PluginInstaller::GetSecurityStatus( |
94 const webkit::WebPluginInfo& plugin) const { | 94 const webkit::WebPluginInfo& plugin) const { |
95 // If there are no versions defined, the plug-in should require authorization. | 95 // If there are no versions defined, the plug-in should require authorization. |
96 if (versions_.empty()) | 96 if (versions_.empty()) |
97 return SECURITY_STATUS_REQUIRES_AUTHORIZATION; | 97 return SECURITY_STATUS_REQUIRES_AUTHORIZATION; |
98 | 98 |
99 scoped_ptr<Version> version( | 99 Version version; |
100 webkit::npapi::PluginGroup::CreateVersionFromString(plugin.version)); | 100 webkit::npapi::PluginGroup::CreateVersionFromString(plugin.version, &version); |
101 if (!version.get()) | 101 if (!version.IsValid()) |
102 version.reset(new Version("0")); | 102 version = Version("0"); |
103 | 103 |
104 // |lower_bound| returns the latest version that is not newer than |version|. | 104 // |lower_bound| returns the latest version that is not newer than |version|. |
105 std::map<Version, SecurityStatus, VersionComparator>::const_iterator it = | 105 std::map<Version, SecurityStatus, VersionComparator>::const_iterator it = |
106 versions_.lower_bound(*version); | 106 versions_.lower_bound(version); |
107 // If there is at least one version defined, everything older than the oldest | 107 // If there is at least one version defined, everything older than the oldest |
108 // defined version is considered out-of-date. | 108 // defined version is considered out-of-date. |
109 if (it == versions_.end()) | 109 if (it == versions_.end()) |
110 return SECURITY_STATUS_OUT_OF_DATE; | 110 return SECURITY_STATUS_OUT_OF_DATE; |
111 | 111 |
112 return it->second; | 112 return it->second; |
113 } | 113 } |
114 | 114 |
115 bool PluginInstaller::VersionComparator::operator() (const Version& lhs, | 115 bool PluginInstaller::VersionComparator::operator() (const Version& lhs, |
116 const Version& rhs) const { | 116 const Version& rhs) const { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); | 245 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); |
246 state_ = INSTALLER_STATE_IDLE; | 246 state_ = INSTALLER_STATE_IDLE; |
247 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); | 247 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadError(msg)); |
248 } | 248 } |
249 | 249 |
250 void PluginInstaller::DownloadCancelled() { | 250 void PluginInstaller::DownloadCancelled() { |
251 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); | 251 DCHECK_EQ(INSTALLER_STATE_DOWNLOADING, state_); |
252 state_ = INSTALLER_STATE_IDLE; | 252 state_ = INSTALLER_STATE_IDLE; |
253 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); | 253 FOR_EACH_OBSERVER(PluginInstallerObserver, observers_, DownloadCancelled()); |
254 } | 254 } |
OLD | NEW |