Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / extensions / external_provider_impl.h
bloba75bdfe2b3a5c25c4bf3c937419cfd5059892811
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[];
78 static const char kDoNotInstallForEnterprise[];
80 void set_auto_acknowledge(bool auto_acknowledge) {
81 auto_acknowledge_ = auto_acknowledge;
84 void set_install_immediately(bool install_immediately) {
85 install_immediately_ = install_immediately;
88 private:
89 bool HandleMinProfileVersion(const base::DictionaryValue* extension,
90 const std::string& extension_id,
91 std::set<std::string>* unsupported_extensions);
93 bool HandleDoNotInstallForEnterprise(
94 const base::DictionaryValue* extension,
95 const std::string& extension_id,
96 std::set<std::string>* unsupported_extensions);
98 // Location for external extensions that are provided by this provider from
99 // local crx files.
100 const Manifest::Location crx_location_;
102 // Location for external extensions that are provided by this provider from
103 // update URLs.
104 const Manifest::Location download_location_;
106 // Weak pointer to the object that consumes the external extensions.
107 // This is zeroed out by: ServiceShutdown()
108 VisitorInterface* service_; // weak
110 // Dictionary of the external extensions that are provided by this provider.
111 scoped_ptr<base::DictionaryValue> prefs_;
113 // Indicates that the extensions provided by this provider are loaded
114 // entirely.
115 bool ready_;
117 // The loader that loads the list of external extensions and reports them
118 // via |SetPrefs|.
119 scoped_refptr<ExternalLoader> loader_;
121 // The profile that will be used to install external extensions.
122 Profile* profile_;
124 // Creation flags to use for the extension. These flags will be used
125 // when calling Extension::Create() by the crx installer.
126 int creation_flags_;
128 // Whether loaded extensions should be automatically acknowledged, so that
129 // the user doesn't see an alert about them.
130 bool auto_acknowledge_;
132 // Whether the extensions from this provider should be installed immediately.
133 bool install_immediately_;
135 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl);
138 } // namespace extensions
140 #endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_