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 ~ExternalProviderImpl() override
;
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 void ServiceShutdown() override
;
58 void VisitRegisteredExtension() override
;
59 bool HasExtension(const std::string
& id
) const override
;
60 bool GetExtensionDetails(const std::string
& id
,
61 Manifest::Location
* location
,
62 scoped_ptr
<base::Version
>* version
) const override
;
64 bool IsReady() const override
;
66 static const char kExternalCrx
[];
67 static const char kExternalVersion
[];
68 static const char kExternalUpdateUrl
[];
69 static const char kInstallParam
[];
70 static const char kIsBookmarkApp
[];
71 static const char kIsFromWebstore
[];
72 static const char kKeepIfPresent
[];
73 static const char kSupportedLocales
[];
74 static const char kWasInstalledByOem
[];
75 static const char kMayBeUntrusted
[];
77 void set_auto_acknowledge(bool auto_acknowledge
) {
78 auto_acknowledge_
= auto_acknowledge
;
81 void set_install_immediately(bool install_immediately
) {
82 install_immediately_
= install_immediately
;
86 // Location for external extensions that are provided by this provider from
88 const Manifest::Location crx_location_
;
90 // Location for external extensions that are provided by this provider from
92 const Manifest::Location download_location_
;
94 // Weak pointer to the object that consumes the external extensions.
95 // This is zeroed out by: ServiceShutdown()
96 VisitorInterface
* service_
; // weak
98 // Dictionary of the external extensions that are provided by this provider.
99 scoped_ptr
<base::DictionaryValue
> prefs_
;
101 // Indicates that the extensions provided by this provider are loaded
105 // The loader that loads the list of external extensions and reports them
107 scoped_refptr
<ExternalLoader
> loader_
;
109 // The profile that will be used to install external extensions.
112 // Creation flags to use for the extension. These flags will be used
113 // when calling Extension::Create() by the crx installer.
116 // Whether loaded extensions should be automatically acknowledged, so that
117 // the user doesn't see an alert about them.
118 bool auto_acknowledge_
;
120 // Whether the extensions from this provider should be installed immediately.
121 bool install_immediately_
;
123 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl
);
126 } // namespace extensions
128 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_