blob: 0a148a45012387f5f87e260146110acd231698bd [file] [log] [blame]
[email protected]a12ce8b22012-01-17 18:40:531// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]8e4560b62011-01-14 10:09:142// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]5df038b2012-07-16 19:03:275#ifndef CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_
6#define CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_
[email protected]8e4560b62011-01-14 10:09:147
[email protected]c51225632011-11-11 21:40:378#include <string>
9
[email protected]3b63f8f42011-03-28 01:54:1510#include "base/memory/ref_counted.h"
[email protected]5df038b2012-07-16 19:03:2711#include "chrome/browser/extensions/external_loader.h"
[email protected]301116c62013-11-26 10:37:4512#include "extensions/browser/external_provider_interface.h"
[email protected]d42c11152013-08-22 19:36:3213#include "extensions/common/manifest.h"
[email protected]8e4560b62011-01-14 10:09:1414
[email protected]8e4560b62011-01-14 10:09:1415class Profile;
[email protected]8e4560b62011-01-14 10:09:1416
[email protected]f3a1c642011-07-12 19:15:0317namespace base {
18class DictionaryValue;
[email protected]1f04ef42013-04-22 07:35:5019class Version;
[email protected]f3a1c642011-07-12 19:15:0320}
21
[email protected]1c321ee2012-05-21 03:02:3422namespace extensions {
[email protected]1c321ee2012-05-21 03:02:3423
[email protected]5df038b2012-07-16 19:03:2724// 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.
28class ExternalProviderImpl : public ExternalProviderInterface {
[email protected]8e4560b62011-01-14 10:09:1429 public:
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
[email protected]1d5e58b2013-01-31 08:41:4036 // be initialized as Manifest::INVALID_LOCATION.
[email protected]5df038b2012-07-16 19:03:2737 ExternalProviderImpl(VisitorInterface* service,
[email protected]af984882013-10-21 21:08:5138 const scoped_refptr<ExternalLoader>& loader,
[email protected]19eac6d2013-05-30 06:51:0339 Profile* profile,
[email protected]1d5e58b2013-01-31 08:41:4040 Manifest::Location crx_location,
41 Manifest::Location download_location,
[email protected]5df038b2012-07-16 19:03:2742 int creation_flags);
[email protected]8e4560b62011-01-14 10:09:1443
[email protected]5df038b2012-07-16 19:03:2744 virtual ~ExternalProviderImpl();
[email protected]8e4560b62011-01-14 10:09:1445
46 // Populates a list with providers for all known sources.
47 static void CreateExternalProviders(
48 VisitorInterface* service,
49 Profile* profile,
50 ProviderCollection* provider_list);
51
52 // Sets underlying prefs and notifies provider. Only to be called by the
[email protected]5df038b2012-07-16 19:03:2753 // owned ExternalLoader instance.
[email protected]937cf9d2012-08-30 03:51:5554 virtual void SetPrefs(base::DictionaryValue* prefs);
[email protected]8e4560b62011-01-14 10:09:1455
[email protected]5df038b2012-07-16 19:03:2756 // ExternalProvider implementation:
[email protected]51a7a9d2011-09-27 17:21:4157 virtual void ServiceShutdown() OVERRIDE;
[email protected]d190cef2011-11-09 02:09:2458 virtual void VisitRegisteredExtension() OVERRIDE;
[email protected]51a7a9d2011-09-27 17:21:4159 virtual bool HasExtension(const std::string& id) const OVERRIDE;
[email protected]1f04ef42013-04-22 07:35:5060 virtual bool GetExtensionDetails(
61 const std::string& id,
62 Manifest::Location* location,
63 scoped_ptr<base::Version>* version) const OVERRIDE;
[email protected]8e4560b62011-01-14 10:09:1464
[email protected]1cc91fe2011-11-21 14:48:4365 virtual bool IsReady() const OVERRIDE;
[email protected]8e4560b62011-01-14 10:09:1466
[email protected]8e4560b62011-01-14 10:09:1467 static const char kExternalCrx[];
68 static const char kExternalVersion[];
69 static const char kExternalUpdateUrl[];
[email protected]d8fd0fd2014-03-24 13:16:0670 static const char kInstallParam[];
[email protected]f121003b2012-05-04 21:57:4771 static const char kIsBookmarkApp[];
[email protected]7425d7df2012-11-28 14:35:4272 static const char kIsFromWebstore[];
[email protected]19eac6d2013-05-30 06:51:0373 static const char kKeepIfPresent[];
[email protected]d8fd0fd2014-03-24 13:16:0674 static const char kSupportedLocales[];
[email protected]bf9fd5ae2014-04-09 22:50:0675 static const char kWasInstalledByOem[];
[email protected]8e4560b62011-01-14 10:09:1476
[email protected]47fc70c2011-12-06 07:29:5177 void set_auto_acknowledge(bool auto_acknowledge) {
78 auto_acknowledge_ = auto_acknowledge;
79 }
80
[email protected]8e4560b62011-01-14 10:09:1481 private:
82 // Location for external extensions that are provided by this provider from
83 // local crx files.
[email protected]1d5e58b2013-01-31 08:41:4084 const Manifest::Location crx_location_;
[email protected]8e4560b62011-01-14 10:09:1485
86 // Location for external extensions that are provided by this provider from
87 // update URLs.
[email protected]1d5e58b2013-01-31 08:41:4088 const Manifest::Location download_location_;
[email protected]8e4560b62011-01-14 10:09:1489
[email protected]8e4560b62011-01-14 10:09:1490 // Weak pointer to the object that consumes the external extensions.
91 // This is zeroed out by: ServiceShutdown()
92 VisitorInterface* service_; // weak
93
94 // Dictionary of the external extensions that are provided by this provider.
[email protected]f3a1c642011-07-12 19:15:0395 scoped_ptr<base::DictionaryValue> prefs_;
[email protected]8e4560b62011-01-14 10:09:1496
97 // Indicates that the extensions provided by this provider are loaded
98 // entirely.
99 bool ready_;
100
101 // The loader that loads the list of external extensions and reports them
102 // via |SetPrefs|.
[email protected]5df038b2012-07-16 19:03:27103 scoped_refptr<ExternalLoader> loader_;
[email protected]8e4560b62011-01-14 10:09:14104
[email protected]19eac6d2013-05-30 06:51:03105 // The profile that will be used to install external extensions.
106 Profile* profile_;
107
[email protected]1bf73cc2011-10-26 22:38:31108 // Creation flags to use for the extension. These flags will be used
[email protected]1d5e58b2013-01-31 08:41:40109 // when calling Extension::Create() by the crx installer.
[email protected]1bf73cc2011-10-26 22:38:31110 int creation_flags_;
111
[email protected]47fc70c2011-12-06 07:29:51112 // Whether loaded extensions should be automatically acknowledged, so that
113 // the user doesn't see an alert about them.
114 bool auto_acknowledge_;
115
[email protected]5df038b2012-07-16 19:03:27116 DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl);
[email protected]8e4560b62011-01-14 10:09:14117};
118
[email protected]5df038b2012-07-16 19:03:27119} // namespace extensions
120
121#endif // CHROME_BROWSER_EXTENSIONS_EXTERNAL_PROVIDER_IMPL_H_