1 // Copyright 2013 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_EXTENSION_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALLER_H_
11 #include "base/memory/weak_ptr.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/requirements_checker.h"
15 #include "chrome/common/extensions/extension.h"
23 namespace extensions {
26 // Holds common methods and data of extension installers.
27 class ExtensionInstaller {
29 typedef base::Callback<void(std::vector<std::string>)> RequirementsCallback;
31 explicit ExtensionInstaller(Profile* profile);
32 ~ExtensionInstaller();
34 // Called on the UI thread to start the requirements check on the extension
35 void CheckRequirements(const RequirementsCallback& callback);
37 // Checks the management policy if the extension can be installed.
38 string16 CheckManagementPolicy();
40 Profile* profile() const {
44 void set_extension(const Extension* extension) {
45 extension_ = extension;
48 scoped_refptr<const Extension> extension() {
53 scoped_ptr<RequirementsChecker> requirements_checker_;
55 // The Profile where the extension is being installed in.
58 // The extension we're installing. We either pass it off to ExtensionService
59 // on success, or drop the reference on failure.
60 scoped_refptr<const Extension> extension_;
62 base::WeakPtrFactory<ExtensionInstaller> weak_ptr_factory_;
64 DISALLOW_COPY_AND_ASSIGN(ExtensionInstaller);
67 } // namespace extensions
69 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INSTALLER_H_