summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/stateful_external_extension_provider.h
blob: 506873d64049aa692ae22b1d1ca5cea0635f5424 (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
// Copyright (c) 2009 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_STATEFUL_EXTERNAL_EXTENSION_PROVIDER_H_
#define CHROME_BROWSER_EXTENSIONS_STATEFUL_EXTERNAL_EXTENSION_PROVIDER_H_
#pragma once

#include <set>
#include <string>

#include "chrome/browser/extensions/external_extension_provider.h"

class DictionaryValue;
class ValueSerializer;
class Version;

// A specialization of the ExternalExtensionProvider that stores the registered
// external extensions in a dictionary. This dictionary (|prefs_|) will be used
// by HasExtension() and GetExtensionDetails() to return information about the
// stored external extensions. It is the responsibility of specialized
// subclasses to initialize this internal dictionary.
// This provider can provide external extensions from two sources: crx files
// and udpate URLs. The locations that the provider will report for these
// are specified at the constructor.
class StatefulExternalExtensionProvider : public ExternalExtensionProvider {
 public:
  // Initialize the location for external extensions originating from crx
  // files: |crx_location|, and originating from update URLs:
  // |download_location|. If either of the origins is not supported by this
  // provider, then it should be initialized as Extensions::INVALID.
  StatefulExternalExtensionProvider(
      Extension::Location crx_location,
      Extension::Location download_location);
  virtual ~StatefulExternalExtensionProvider();

  // ExternalExtensionProvider implementation:
  virtual void VisitRegisteredExtension(
      Visitor* visitor, const std::set<std::string>& ids_to_ignore) const;

  virtual bool HasExtension(const std::string& id) const;

  virtual bool GetExtensionDetails(const std::string& id,
                                   Extension::Location* location,
                                   scoped_ptr<Version>* version) const;
 protected:
  // Location for external extensions that are provided by this provider from
  // local crx files.
  const Extension::Location crx_location_;
  // Location for external extensions that are provided by this provider from
  // update URLs.
  const Extension::Location download_location_;
  // Dictionary of the external extensions that are provided by this provider.
  scoped_ptr<DictionaryValue> prefs_;
};

#endif  // CHROME_BROWSER_EXTENSIONS_STATEFUL_EXTERNAL_EXTENSION_PROVIDER_H_