Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Side by Side Diff: chrome/browser/extensions/unpacked_installer.h

Issue 2751013002: Simplify ExtensionInstallChecker into a single-use class (Closed)
Patch Set: todo Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "chrome/browser/extensions/extension_install_checker.h"
18 17
19 class ExtensionService; 18 class ExtensionService;
19 class Profile;
20 20
21 namespace extensions { 21 namespace extensions {
22 22
23 class Extension; 23 class Extension;
24 class ExtensionInstallChecker;
24 25
25 // Installs and loads an unpacked extension. Because internal state needs to be 26 // Installs and loads an unpacked extension. Because internal state needs to be
26 // held about the instalation process, only one call to Load*() should be made 27 // held about the instalation process, only one call to Load*() should be made
27 // per UnpackedInstaller. 28 // per UnpackedInstaller.
28 // TODO(erikkay): It might be useful to be able to load a packed extension 29 // TODO(erikkay): It might be useful to be able to load a packed extension
29 // (presumably into memory) without installing it. 30 // (presumably into memory) without installing it.
30 class UnpackedInstaller 31 class UnpackedInstaller
31 : public base::RefCountedThreadSafe<UnpackedInstaller> { 32 : public base::RefCountedThreadSafe<UnpackedInstaller> {
32 public: 33 public:
33 using CompletionCallback = base::Callback<void(const Extension* extension, 34 using CompletionCallback = base::Callback<void(const Extension* extension,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 111
111 // Notify the frontend that there was an error loading an extension. 112 // Notify the frontend that there was an error loading an extension.
112 void ReportExtensionLoadError(const std::string& error); 113 void ReportExtensionLoadError(const std::string& error);
113 114
114 // Passes the extension onto extension service. 115 // Passes the extension onto extension service.
115 void InstallExtension(); 116 void InstallExtension();
116 117
117 // Helper to get the Extension::CreateFlags for the installing extension. 118 // Helper to get the Extension::CreateFlags for the installing extension.
118 int GetFlags(); 119 int GetFlags();
119 120
120 const Extension* extension() { return install_checker_.extension().get(); } 121 const Extension* extension() { return extension_.get(); }
121 122
122 // The service we will report results back to. 123 // The service we will report results back to.
123 base::WeakPtr<ExtensionService> service_weak_; 124 base::WeakPtr<ExtensionService> service_weak_;
124 125
126 // The Profile the extension is being installed in.
127 Profile* profile_;
128
125 // The pathname of the directory to load from, which is an absolute path 129 // The pathname of the directory to load from, which is an absolute path
126 // after GetAbsolutePath has been called. 130 // after GetAbsolutePath has been called.
127 base::FilePath extension_path_; 131 base::FilePath extension_path_;
128 132
133 // The extension being installed.
134 scoped_refptr<const Extension> extension_;
135
129 // If true and the extension contains plugins, we prompt the user before 136 // If true and the extension contains plugins, we prompt the user before
130 // loading. 137 // loading.
131 bool prompt_for_plugins_; 138 bool prompt_for_plugins_;
132 139
133 // Whether to require the extension installed to have a modern manifest 140 // Whether to require the extension installed to have a modern manifest
134 // version. 141 // version.
135 bool require_modern_manifest_version_; 142 bool require_modern_manifest_version_;
136 143
137 // Whether or not to be noisy (show a dialog) on failure. Defaults to true. 144 // Whether or not to be noisy (show a dialog) on failure. Defaults to true.
138 bool be_noisy_on_failure_; 145 bool be_noisy_on_failure_;
139 146
140 // Checks management policies and requirements before the extension can be 147 // Checks management policies and requirements before the extension can be
141 // installed. 148 // installed.
142 ExtensionInstallChecker install_checker_; 149 std::unique_ptr<ExtensionInstallChecker> install_checker_;
143 150
144 CompletionCallback callback_; 151 CompletionCallback callback_;
145 152
146 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); 153 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller);
147 }; 154 };
148 155
149 } // namespace extensions 156 } // namespace extensions
150 157
151 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ 158 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_checker_unittest.cc ('k') | chrome/browser/extensions/unpacked_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698