1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_
10 #include "base/memory/ref_counted.h"
11 #include "chrome/browser/extensions/external_loader.h"
12 #include "extensions/browser/external_provider_interface.h"
13 #include "extensions/common/manifest.h"
18 class DictionaryValue
;
22 namespace extensions
{
24 // A specialization of the ExternalProvider that uses an instance of
25 // ExternalLoader to provide external extensions. This class can be seen as a
26 // bridge between the extension system and an ExternalLoader. Instances live
27 // their entire life on the UI thread.
28 class ExternalProviderImpl
: public ExternalProviderInterface
{
30 // The constructed provider will provide the extensions loaded from |loader|
31 // to |service|, that will deal with the installation. The location
32 // attributes of the provided extensions are also specified here:
33 // |crx_location|: extensions originating from crx files
34 // |download_location|: extensions originating from update URLs
35 // If either of the origins is not supported by this provider, then it should
36 // be initialized as Manifest::INVALID_LOCATION.
37 ExternalProviderImpl(VisitorInterface
* service
,
38 const scoped_refptr
<ExternalLoader
>& loader
,
40 Manifest::Location crx_location
,
41 Manifest::Location download_location
,
44 virtual ~ExternalProviderImpl();
46 // Populates a list with providers for all known sources.
47 static void CreateExternalProviders(
48 VisitorInterface
* service
,
50 ProviderCollection
* provider_list
);
52 // Sets underlying prefs and notifies provider. Only to be called by the
53 // owned ExternalLoader instance.
54 virtual void SetPrefs(base::DictionaryValue
* prefs
);
56 // ExternalProvider implementation:
57 virtual void ServiceShutdown() OVERRIDE
;
58 virtual void VisitRegisteredExtension() OVERRIDE
;
59 virtual bool HasExtension(const std::string
& id
) const OVERRIDE
;
60 virtual bool GetExtensionDetails(
61 const std::string
& id
,
62 Manifest::Location
* location
,
63 scoped_ptr
<base::Version
>* version
) const OVERRIDE
;
65 virtual bool IsReady() const OVERRIDE
;
67 static const char kExternalCrx
[];
68 static const char kExternalVersion
[];
69 static const char kExternalUpdateUrl
[];
70 static const char kSupportedLocales
[];
71 static const char kIsBookmarkApp
[];
72 static const char kIsFromWebstore
[];
73 static const char kKeepIfPresent
[];
75 void set_auto_acknowledge(bool auto_acknowledge
) {
76 auto_acknowledge_
= auto_acknowledge
;
80 // Location for external extensions that are provided by this provider from
82 const Manifest::Location crx_location_
;
84 // Location for external extensions that are provided by this provider from
86 const Manifest::Location download_location_
;
88 // Weak pointer to the object that consumes the external extensions.
89 // This is zeroed out by: ServiceShutdown()
90 VisitorInterface
* service_
; // weak
92 // Dictionary of the external extensions that are provided by this provider.
93 scoped_ptr
<base::DictionaryValue
> prefs_
;
95 // Indicates that the extensions provided by this provider are loaded
99 // The loader that loads the list of external extensions and reports them
101 scoped_refptr
<ExternalLoader
> loader_
;
103 // The profile that will be used to install external extensions.
106 // Creation flags to use for the extension. These flags will be used
107 // when calling Extension::Create() by the crx installer.
110 // Whether loaded extensions should be automatically acknowledged, so that
111 // the user doesn't see an alert about them.
112 bool auto_acknowledge_
;
114 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl
);
117 } // namespace extensions
119 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_