summaryrefslogtreecommitdiff
path: root/chromium/extensions/common/features/feature.cc
blob: 026ac06cc596c8530c0b53de5aba249114dec0fd (plain)
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
// Copyright 2013 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 "extensions/common/features/feature.h"

#include <map>

#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest.h"

namespace extensions {

// static
Feature::Platform Feature::GetCurrentPlatform() {
// TODO(https://crbug.com/1052397): For readability, this should become
// defined(OS_CHROMEOS) && BUILDFLAG(IS_CHROMEOS_LACROS). The second conditional
// should be defined(OS_CHROMEOS) && BUILDFLAG(IS_CHROMEOS_ASH).
#if BUILDFLAG(IS_CHROMEOS_LACROS)
  return LACROS_PLATFORM;
#elif BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_CHROMEOS_LACROS)
  return CHROMEOS_PLATFORM;
#elif defined(OS_LINUX)
  return LINUX_PLATFORM;
#elif defined(OS_MAC)
  return MACOSX_PLATFORM;
#elif defined(OS_WIN)
  return WIN_PLATFORM;
#else
  return UNSPECIFIED_PLATFORM;
#endif
}

Feature::Availability Feature::IsAvailableToExtension(
    const Extension* extension) const {
  return IsAvailableToManifest(extension->hashed_id(), extension->GetType(),
                               extension->location(),
                               extension->manifest_version());
}

Feature::Feature() : no_parent_(false) {}

Feature::~Feature() {}

void Feature::set_name(base::StringPiece name) {
  name_ = name.as_string();
}

void Feature::set_alias(base::StringPiece alias) {
  alias_ = alias.as_string();
}

void Feature::set_source(base::StringPiece source) {
  source_ = source.as_string();
}

}  // namespace extensions