Chromium Code Reviews

Side by Side Diff: chrome/browser/extensions/external_extension_provider_impl.h

Issue 5742008: Clean up threading model of external extension providers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: final rebase Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_
7 #pragma once
8
9 #include "chrome/browser/extensions/external_extension_provider_interface.h"
10
11 #include "base/ref_counted.h"
12 #include "chrome/browser/extensions/external_extension_loader.h"
13
14 class DictionaryValue;
15 class ExternalExtensionLoader;
16 class Profile;
17 class ValueSerializer;
18 class Version;
19
20 // A specialization of the ExternalExtensionProvider that uses an instance
21 // of ExternalExtensionLoader to provide external extensions. This class
22 // can be seen as a bridge between the extension system and an
23 // ExternalExtensionLoader. Instances live their entire life on the UI thread.
24 class ExternalExtensionProviderImpl
25 : public ExternalExtensionProviderInterface {
26 public:
27 // The constructed provider will provide the extensions loaded from |loader|
28 // to |service|, that will deal with the installation. The location
29 // attributes of the provided extensions are also specified here:
30 // |crx_location|: extensions originating from crx files
31 // |download_location|: extensions originating from update URLs
32 // If either of the origins is not supported by this provider, then it should
33 // be initialized as Extensions::INVALID.
34 ExternalExtensionProviderImpl(
35 VisitorInterface* service,
36 ExternalExtensionLoader* loader,
37 Extension::Location crx_location,
38 Extension::Location download_location);
39
40 virtual ~ExternalExtensionProviderImpl();
41
42 // Populates a list with providers for all known sources.
43 static void CreateExternalProviders(
44 VisitorInterface* service,
45 Profile* profile,
46 ProviderCollection* provider_list);
47
48 // Sets underlying prefs and notifies provider. Only to be called by the
49 // owned ExternalExtensionLoader instance.
50 void SetPrefs(DictionaryValue* prefs);
51
52 // ExternalExtensionProvider implementation:
53 virtual void VisitRegisteredExtension() const;
54
55 virtual bool HasExtension(const std::string& id) const;
56
57 virtual bool GetExtensionDetails(const std::string& id,
58 Extension::Location* location,
59 scoped_ptr<Version>* version) const;
60
61 virtual void ServiceShutdown();
62
63 virtual bool IsReady();
64
65 static const char kLocation[];
66 static const char kState[];
67 static const char kExternalCrx[];
68 static const char kExternalVersion[];
69 static const char kExternalUpdateUrl[];
70
71 private:
72 // Location for external extensions that are provided by this provider from
73 // local crx files.
74 const Extension::Location crx_location_;
75
76 // Location for external extensions that are provided by this provider from
77 // update URLs.
78 const Extension::Location download_location_;
79
80 private:
81 // Weak pointer to the object that consumes the external extensions.
82 // This is zeroed out by: ServiceShutdown()
83 VisitorInterface* service_; // weak
84
85 // Dictionary of the external extensions that are provided by this provider.
86 scoped_ptr<DictionaryValue> prefs_;
87
88 // Indicates that the extensions provided by this provider are loaded
89 // entirely.
90 bool ready_;
91
92 // The loader that loads the list of external extensions and reports them
93 // via |SetPrefs|.
94 scoped_refptr<ExternalExtensionLoader> loader_;
95
96 DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl);
97 };
98
99 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_EXTENSION_PROVIDER_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_extension_loader.cc ('k') | chrome/browser/extensions/external_extension_provider_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine