summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/extensions/extension_basic_info.cc
blob: 3a0c247cd65780073f273e404b86678a3aaf43c5 (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
// 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 "chrome/browser/ui/webui/extensions/extension_basic_info.h"

#include "base/values.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handlers/kiosk_mode_info.h"
#include "extensions/common/manifest_handlers/offline_enabled_info.h"
#include "extensions/common/manifest_handlers/options_page_info.h"
#include "extensions/common/manifest_url_handlers.h"

namespace {

// Keys in the dictionary returned by GetExtensionBasicInfo().
const char kDescriptionKey[] = "description";
const char kEnabledKey[] = "enabled";
const char kHomepageUrlKey[] = "homepageUrl";
const char kIdKey[] = "id";
const char kNameKey[] = "name";
const char kKioskEnabledKey[] = "kioskEnabled";
const char kKioskOnlyKey[] = "kioskOnly";
const char kOfflineEnabledKey[] = "offlineEnabled";
const char kOptionsUrlKey[] = "optionsUrl";
const char kDetailsUrlKey[] = "detailsUrl";
const char kVersionKey[] = "version";
const char kPackagedAppKey[] = "packagedApp";

}  // namespace

namespace extensions {

void GetExtensionBasicInfo(const Extension* extension,
                           bool enabled,
                           base::DictionaryValue* info) {
  info->SetString(kIdKey, extension->id());
  info->SetString(kNameKey, extension->name());
  info->SetBoolean(kEnabledKey, enabled);
  info->SetBoolean(kKioskEnabledKey,
                   KioskModeInfo::IsKioskEnabled(extension));
  info->SetBoolean(kKioskOnlyKey,
                   KioskModeInfo::IsKioskOnly(extension));
  info->SetBoolean(kOfflineEnabledKey,
                   OfflineEnabledInfo::IsOfflineEnabled(extension));
  info->SetString(kVersionKey, extension->GetVersionForDisplay());
  info->SetString(kDescriptionKey, extension->description());
  info->SetString(
      kOptionsUrlKey,
      OptionsPageInfo::GetOptionsPage(extension).possibly_invalid_spec());
  info->SetString(
      kHomepageUrlKey,
      ManifestURL::GetHomepageURL(extension).possibly_invalid_spec());
  info->SetString(
      kDetailsUrlKey,
      ManifestURL::GetDetailsURL(extension).possibly_invalid_spec());
  info->SetBoolean(kPackagedAppKey, extension->is_platform_app());
}

}  // namespace extensions