blob: f8c6bbc715ab1ba6f1e8336b9902755c13eb9681 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright (c) 2011 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.
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_
#pragma once
#include <map>
#include <string>
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/memory/ref_counted.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_extent.h"
#include "googleurl/src/gurl.h"
class Extension;
// Contains extension data that needs to be accessed on the IO thread. It can
// be created/destroyed on any thread, but all other methods must be called on
// the IO thread.
//
// TODO(mpcomplete): consider simplifying this class to return the StaticData
// object itself, since most methods are simple property accessors.
class ExtensionInfoMap : public base::RefCountedThreadSafe<ExtensionInfoMap> {
public:
ExtensionInfoMap();
~ExtensionInfoMap();
// Callback for when new extensions are loaded.
void AddExtension(const Extension* extension);
// Callback for when an extension is unloaded.
void RemoveExtension(const std::string& id,
const UnloadedExtensionInfo::Reason reason);
// Gets the name for the specified extension.
std::string GetNameForExtension(const std::string& id) const;
// Gets the path to the directory for the specified extension.
FilePath GetPathForExtension(const std::string& id) const;
// Gets the path to the directory for the specified disabled extension.
FilePath GetPathForDisabledExtension(const std::string& id) const;
// Returns true if the specified extension exists and has a non-empty web
// extent.
bool ExtensionHasWebExtent(const std::string& id) const;
// Returns true if the specified extension exists and can load in incognito
// contexts.
bool ExtensionCanLoadInIncognito(const std::string& id) const;
// Returns an empty string if the extension with |id| doesn't have a default
// locale.
std::string GetDefaultLocaleForExtension(const std::string& id) const;
// Gets the effective host permissions for the extension with |id|.
ExtensionExtent
GetEffectiveHostPermissionsForExtension(const std::string& id) const;
// Determine whether a URL has access to the specified extension permission.
bool CheckURLAccessToExtensionPermission(const GURL& url,
const char* permission_name) const;
// Returns true if the specified URL references the icon for an extension.
bool URLIsForExtensionIcon(const GURL& url) const;
private:
// Map of extension info by extension id.
typedef std::map<std::string, scoped_refptr<const Extension> > Map;
Map extension_info_;
Map disabled_extension_info_;
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INFO_MAP_H_
|