summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/extensions/external_pref_cache_loader.h
blob: 72e8d87d44f46cd390569300424a65399b48a514 (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
// Copyright (c) 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.

#ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_PREF_CACHE_LOADER_H_
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_PREF_CACHE_LOADER_H_

#include "base/memory/ref_counted.h"
#include "chrome/browser/extensions/external_pref_loader.h"

class Profile;

namespace chromeos {

class ExternalCacheDispatcher;

// A specialization of the ExternalPrefLoader that caches crx files for external
// extensions with update URL in a common place for all users on the machine.
class ExternalPrefCacheLoader : public extensions::ExternalPrefLoader {
 public:
  // All instances of ExternalPrefCacheLoader use the same cache so
  // |base_path_id| must be the same for all profile in session.
  // It is checked in run-time with CHECK. |profile| is used to check if the
  // extension is installed to keep providing.
  ExternalPrefCacheLoader(int base_path_id, Profile* profile);

  void OnExtensionListsUpdated(const base::DictionaryValue* prefs);

 private:
  friend class base::RefCountedThreadSafe<ExternalLoader>;

  virtual ~ExternalPrefCacheLoader();

  virtual void StartLoading() OVERRIDE;
  virtual void LoadFinished() OVERRIDE;

  Profile* profile_;
  scoped_refptr<ExternalCacheDispatcher> cache_dispatcher_;

  DISALLOW_COPY_AND_ASSIGN(ExternalPrefCacheLoader);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_EXTENSIONS_EXTERNAL_PREF_CACHE_LOADER_H_