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
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/pending_extension_info.h"
7 #include "base/logging.h"
11 PendingExtensionInfo::PendingExtensionInfo(
12 const std::string
& id
,
13 const GURL
& update_url
,
14 const Version
& version
,
15 ShouldAllowInstallPredicate should_allow_install
,
17 bool install_silently
,
18 Manifest::Location install_source
)
20 update_url_(update_url
),
22 should_allow_install_(should_allow_install
),
23 is_from_sync_(is_from_sync
),
24 install_silently_(install_silently
),
25 install_source_(install_source
) {}
27 PendingExtensionInfo::PendingExtensionInfo()
29 should_allow_install_(NULL
),
31 install_silently_(false),
32 install_source_(Manifest::INVALID_LOCATION
) {}
34 bool PendingExtensionInfo::operator==(const PendingExtensionInfo
& rhs
) const {
35 return id_
== rhs
.id_
;
38 int PendingExtensionInfo::CompareTo(const PendingExtensionInfo
& other
) const {
39 DCHECK_EQ(id_
, other
.id_
);
40 if (version_
.IsValid() && other
.version_
.IsValid()) {
41 int comparison
= version_
.CompareTo(other
.version_
);
43 // If the versions differ then return the version comparison result.
48 // The versions aren't specified, or they are the same version. Check
49 // the install source.
50 if (install_source_
== other
.install_source_
) {
51 // Same install source, so |this| has the same precedence as |other|.
55 // Different install sources; |this| has higher precedence if
56 // |install_source_| is the higher priority source.
57 Manifest::Location higher_priority_source
=
58 Manifest::GetHigherPriorityLocation(
59 install_source_
, other
.install_source_
);
61 return higher_priority_source
== install_source_
? 1 : -1;
64 } // namespace extensions