Revert 285173 "Removed InProcessBrowserTest::CleanUpOnMainThread()"
[chromium-blink-merge.git] / chrome / browser / extensions / pending_extension_info.cc
blobb0c052f098313f6c9770fc3f2c58d15088f59cfe
1 // Copyright 2014 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"
9 namespace extensions {
11 PendingExtensionInfo::PendingExtensionInfo(
12 const std::string& id,
13 const std::string& install_parameter,
14 const GURL& update_url,
15 const Version& version,
16 ShouldAllowInstallPredicate should_allow_install,
17 bool is_from_sync,
18 bool install_silently,
19 Manifest::Location install_source,
20 int creation_flags,
21 bool mark_acknowledged,
22 bool remote_install)
23 : id_(id),
24 update_url_(update_url),
25 version_(version),
26 install_parameter_(install_parameter),
27 should_allow_install_(should_allow_install),
28 is_from_sync_(is_from_sync),
29 install_silently_(install_silently),
30 install_source_(install_source),
31 creation_flags_(creation_flags),
32 mark_acknowledged_(mark_acknowledged),
33 remote_install_(remote_install) {
36 PendingExtensionInfo::PendingExtensionInfo()
37 : update_url_(),
38 should_allow_install_(NULL),
39 is_from_sync_(true),
40 install_silently_(false),
41 install_source_(Manifest::INVALID_LOCATION),
42 creation_flags_(0),
43 mark_acknowledged_(false),
44 remote_install_(false) {
47 PendingExtensionInfo::~PendingExtensionInfo() {}
49 bool PendingExtensionInfo::operator==(const PendingExtensionInfo& rhs) const {
50 return id_ == rhs.id_;
53 int PendingExtensionInfo::CompareTo(const PendingExtensionInfo& other) const {
54 DCHECK_EQ(id_, other.id_);
55 if (version_.IsValid() && other.version_.IsValid()) {
56 int comparison = version_.CompareTo(other.version_);
58 // If the versions differ then return the version comparison result.
59 if (comparison != 0)
60 return comparison;
63 // The versions aren't specified, or they are the same version. Check
64 // the install source.
65 if (install_source_ == other.install_source_) {
66 // Same install source, so |this| has the same precedence as |other|.
67 return 0;
70 // Different install sources; |this| has higher precedence if
71 // |install_source_| is the higher priority source.
72 Manifest::Location higher_priority_source =
73 Manifest::GetHigherPriorityLocation(
74 install_source_, other.install_source_);
76 return higher_priority_source == install_source_ ? 1 : -1;
79 } // namespace extensions