Revert of Don't install OEM default apps for enterprise users (patchset #1 id:1 of...
[chromium-blink-merge.git] / chrome / browser / extensions / external_provider_impl.h
blob5a69b312981730061daca7f4219c95a12b8f7565
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_
8 #include <set>
9 #include <string>
11 #include "base/memory/ref_counted.h"
12 #include "chrome/browser/extensions/external_loader.h"
13 #include "extensions/browser/external_provider_interface.h"
14 #include "extensions/common/manifest.h"
16 class Profile;
18 namespace base {
19 class DictionaryValue;
20 class Version;
23 namespace extensions {
25 // A specialization of the ExternalProvider that uses an instance of
26 // ExternalLoader to provide external extensions. This class can be seen as a
27 // bridge between the extension system and an ExternalLoader. Instances live
28 // their entire life on the UI thread.
29 class ExternalProviderImpl : public ExternalProviderInterface {
30 public:
31 // The constructed provider will provide the extensions loaded from |loader|
32 // to |service|, that will deal with the installation. The location
33 // attributes of the provided extensions are also specified here:
34 // |crx_location|: extensions originating from crx files
35 // |download_location|: extensions originating from update URLs
36 // If either of the origins is not supported by this provider, then it should
37 // be initialized as Manifest::INVALID_LOCATION.
38 ExternalProviderImpl(VisitorInterface* service,
39 const scoped_refptr<ExternalLoader>& loader,
40 Profile* profile,
41 Manifest::Location crx_location,
42 Manifest::Location download_location,
43 int creation_flags);
45 ~ExternalProviderImpl() override;
47 // Populates a list with providers for all known sources.
48 static void CreateExternalProviders(
49 VisitorInterface* service,
50 Profile* profile,
51 ProviderCollection* provider_list);
53 // Sets underlying prefs and notifies provider. Only to be called by the
54 // owned ExternalLoader instance.
55 virtual void SetPrefs(base::DictionaryValue* prefs);
57 // ExternalProvider implementation:
58 void ServiceShutdown() override;
59 void VisitRegisteredExtension() override;
60 bool HasExtension(const std::string& id) const override;
61 bool GetExtensionDetails(const std::string& id,
62 Manifest::Location* location,
63 scoped_ptr<base::Version>* version) const override;
65 bool IsReady() const override;
67 static const char kExternalCrx[];
68 static const char kExternalVersion[];
69 static const char kExternalUpdateUrl[];
70 static const char kInstallParam[];
71 static const char kIsBookmarkApp[];
72 static const char kIsFromWebstore[];
73 static const char kKeepIfPresent[];
74 static const char kSupportedLocales[];
75 static const char kWasInstalledByOem[];
76 static const char kMayBeUntrusted[];
77 static const char kMinProfileCreatedByVersion[];
79 void set_auto_acknowledge(bool auto_acknowledge) {
80 auto_acknowledge_ = auto_acknowledge;
83 void set_install_immediately(bool install_immediately) {
84 install_immediately_ = install_immediately;
87 private:
88 bool HandleMinProfileVersion(const base::DictionaryValue* extension,
89 const std::string& extension_id,
90 std::set<std::string>* unsupported_extensions);
92 // Location for external extensions that are provided by this provider from
93 // local crx files.
94 const Manifest::Location crx_location_;
96 // Location for external extensions that are provided by this provider from
97 // update URLs.
98 const Manifest::Location download_location_;
100 // Weak pointer to the object that consumes the external extensions.
101 // This is zeroed out by: ServiceShutdown()
102 VisitorInterface* service_; // weak
104 // Dictionary of the external extensions that are provided by this provider.
105 scoped_ptr<base::DictionaryValue> prefs_;
107 // Indicates that the extensions provided by this provider are loaded
108 // entirely.
109 bool ready_;
111 // The loader that loads the list of external extensions and reports them
112 // via |SetPrefs|.
113 scoped_refptr<ExternalLoader> loader_;
115 // The profile that will be used to install external extensions.
116 Profile* profile_;
118 // Creation flags to use for the extension. These flags will be used
119 // when calling Extension::Create() by the crx installer.
120 int creation_flags_;
122 // Whether loaded extensions should be automatically acknowledged, so that
123 // the user doesn't see an alert about them.
124 bool auto_acknowledge_;
126 // Whether the extensions from this provider should be installed immediately.
127 bool install_immediately_;
129 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl);
132 } // namespace extensions
134 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_