File: pending_extension_info.cc

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (79 lines) | stat: -rw-r--r-- 2,537 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/logging.h"
#include "chrome/browser/extensions/pending_extension_info.h"
#include "extensions/common/extension.h"

namespace extensions {

PendingExtensionInfo::PendingExtensionInfo(
    const std::string& id,
    const std::string& install_parameter,
    const GURL& update_url,
    const base::Version& version,
    ShouldAllowInstallPredicate should_allow_install,
    bool is_from_sync,
    Manifest::Location install_source,
    int creation_flags,
    bool mark_acknowledged,
    bool remote_install)
    : id_(id),
      update_url_(update_url),
      version_(version),
      install_parameter_(install_parameter),
      should_allow_install_(should_allow_install),
      is_from_sync_(is_from_sync),
      install_source_(install_source),
      creation_flags_(creation_flags),
      mark_acknowledged_(mark_acknowledged),
      remote_install_(remote_install) {
}

PendingExtensionInfo::PendingExtensionInfo()
    : update_url_(),
      should_allow_install_(NULL),
      is_from_sync_(true),
      install_source_(Manifest::INVALID_LOCATION),
      creation_flags_(Extension::NO_FLAGS),
      mark_acknowledged_(false),
      remote_install_(false) {
}

PendingExtensionInfo::PendingExtensionInfo(const PendingExtensionInfo& other) =
    default;

PendingExtensionInfo::~PendingExtensionInfo() {}

bool PendingExtensionInfo::operator==(const PendingExtensionInfo& rhs) const {
  return id_ == rhs.id_;
}

int PendingExtensionInfo::CompareTo(const PendingExtensionInfo& other) const {
  DCHECK_EQ(id_, other.id_);
  if (version_.IsValid() && other.version_.IsValid()) {
    int comparison = version_.CompareTo(other.version_);

    // If the versions differ then return the version comparison result.
    if (comparison != 0)
      return comparison;
  }

  // The versions aren't specified, or they are the same version. Check
  // the install source.
  if (install_source_ == other.install_source_) {
    // Same install source, so |this| has the same precedence as |other|.
    return 0;
  }

  // Different install sources; |this| has higher precedence if
  // |install_source_| is the higher priority source.
  Manifest::Location higher_priority_source =
      Manifest::GetHigherPriorityLocation(
          install_source_, other.install_source_);

  return higher_priority_source == install_source_ ? 1 : -1;
}

}  // namespace extensions