Make default apps cache multiprofile friendly
[chromium-blink-merge.git] / chrome / browser / extensions / pending_extension_info.cc
bloba1e93d873fbda8e3903e2dc53f77c6a402b2453e
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"
9 namespace extensions {
11 PendingExtensionInfo::PendingExtensionInfo(
12 const std::string& id,
13 const GURL& update_url,
14 const Version& version,
15 ShouldAllowInstallPredicate should_allow_install,
16 bool is_from_sync,
17 bool install_silently,
18 Manifest::Location install_source)
19 : id_(id),
20 update_url_(update_url),
21 version_(version),
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()
28 : update_url_(),
29 should_allow_install_(NULL),
30 is_from_sync_(true),
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.
44 if (comparison != 0)
45 return comparison;
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|.
52 return 0;
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