| 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/extensions/pending_extension_info.h" | 5 #include "chrome/browser/extensions/pending_extension_info.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace extensions { | 9 namespace extensions { |
| 10 | 10 |
| 11 PendingExtensionInfo::PendingExtensionInfo( | 11 PendingExtensionInfo::PendingExtensionInfo( |
| 12 const std::string& id, | 12 const std::string& id, |
| 13 const GURL& update_url, | 13 const GURL& update_url, |
| 14 const Version& version, | 14 const Version& version, |
| 15 ShouldAllowInstallPredicate should_allow_install, | 15 ShouldAllowInstallPredicate should_allow_install, |
| 16 bool is_from_sync, | 16 bool is_from_sync, |
| 17 bool install_silently, | 17 bool install_silently, |
| 18 Extension::Location install_source) | 18 Manifest::Location install_source) |
| 19 : id_(id), | 19 : id_(id), |
| 20 update_url_(update_url), | 20 update_url_(update_url), |
| 21 version_(version), | 21 version_(version), |
| 22 should_allow_install_(should_allow_install), | 22 should_allow_install_(should_allow_install), |
| 23 is_from_sync_(is_from_sync), | 23 is_from_sync_(is_from_sync), |
| 24 install_silently_(install_silently), | 24 install_silently_(install_silently), |
| 25 install_source_(install_source) {} | 25 install_source_(install_source) {} |
| 26 | 26 |
| 27 PendingExtensionInfo::PendingExtensionInfo() | 27 PendingExtensionInfo::PendingExtensionInfo() |
| 28 : id_(""), | 28 : id_(""), |
| 29 update_url_(), | 29 update_url_(), |
| 30 should_allow_install_(NULL), | 30 should_allow_install_(NULL), |
| 31 is_from_sync_(true), | 31 is_from_sync_(true), |
| 32 install_silently_(false), | 32 install_silently_(false), |
| 33 install_source_(Extension::INVALID) {} | 33 install_source_(Manifest::INVALID_LOCATION) {} |
| 34 | 34 |
| 35 bool PendingExtensionInfo::operator==(const PendingExtensionInfo& rhs) const { | 35 bool PendingExtensionInfo::operator==(const PendingExtensionInfo& rhs) const { |
| 36 return id_ == rhs.id_; | 36 return id_ == rhs.id_; |
| 37 } | 37 } |
| 38 | 38 |
| 39 int PendingExtensionInfo::CompareTo(const PendingExtensionInfo& other) const { | 39 int PendingExtensionInfo::CompareTo(const PendingExtensionInfo& other) const { |
| 40 DCHECK_EQ(id_, other.id_); | 40 DCHECK_EQ(id_, other.id_); |
| 41 if (version_.IsValid() && other.version_.IsValid()) { | 41 if (version_.IsValid() && other.version_.IsValid()) { |
| 42 int comparison = version_.CompareTo(other.version_); | 42 int comparison = version_.CompareTo(other.version_); |
| 43 | 43 |
| 44 // If the versions differ then return the version comparison result. | 44 // If the versions differ then return the version comparison result. |
| 45 if (comparison != 0) | 45 if (comparison != 0) |
| 46 return comparison; | 46 return comparison; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // The versions aren't specified, or they are the same version. Check | 49 // The versions aren't specified, or they are the same version. Check |
| 50 // the install source. | 50 // the install source. |
| 51 if (install_source_ == other.install_source_) { | 51 if (install_source_ == other.install_source_) { |
| 52 // Same install source, so |this| has the same precedence as |other|. | 52 // Same install source, so |this| has the same precedence as |other|. |
| 53 return 0; | 53 return 0; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Different install sources; |this| has higher precedence if | 56 // Different install sources; |this| has higher precedence if |
| 57 // |install_source_| is the higher priority source. | 57 // |install_source_| is the higher priority source. |
| 58 Extension::Location higher_priority_source = | 58 Manifest::Location higher_priority_source = |
| 59 Extension::GetHigherPriorityLocation( | 59 Manifest::GetHigherPriorityLocation( |
| 60 install_source_, other.install_source_); | 60 install_source_, other.install_source_); |
| 61 | 61 |
| 62 return higher_priority_source == install_source_ ? 1 : -1; | 62 return higher_priority_source == install_source_ ? 1 : -1; |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace extensions | 65 } // namespace extensions |
| OLD | NEW |