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

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

Issue 381553002: Update the CrxInstaller and UnpackedInstaller to use the ExtensionInstallChecker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved include to correct file Created 6 years, 5 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "chrome/browser/extensions/extension_installer.h" 16 #include "chrome/browser/extensions/extension_install_checker.h"
17 17
18 class ExtensionService; 18 class ExtensionService;
19 19
20 namespace extensions { 20 namespace extensions {
21 21
22 class Extension; 22 class Extension;
23 class RequirementsChecker;
24 23
25 // Installs and loads an unpacked extension. Because internal state needs to be 24 // 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 25 // held about the instalation process, only one call to Load*() should be made
27 // per UnpackedInstaller. 26 // per UnpackedInstaller.
28 // TODO(erikkay): It might be useful to be able to load a packed extension 27 // TODO(erikkay): It might be useful to be able to load a packed extension
29 // (presumably into memory) without installing it. 28 // (presumably into memory) without installing it.
30 class UnpackedInstaller 29 class UnpackedInstaller
31 : public base::RefCountedThreadSafe<UnpackedInstaller> { 30 : public base::RefCountedThreadSafe<UnpackedInstaller> {
32 public: 31 public:
33 typedef base::Callback<void(const base::FilePath&, const std::string&)> 32 typedef base::Callback<void(const base::FilePath&, const std::string&)>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 74
76 private: 75 private:
77 friend class base::RefCountedThreadSafe<UnpackedInstaller>; 76 friend class base::RefCountedThreadSafe<UnpackedInstaller>;
78 77
79 explicit UnpackedInstaller(ExtensionService* extension_service); 78 explicit UnpackedInstaller(ExtensionService* extension_service);
80 virtual ~UnpackedInstaller(); 79 virtual ~UnpackedInstaller();
81 80
82 // Must be called from the UI thread. 81 // Must be called from the UI thread.
83 void ShowInstallPrompt(); 82 void ShowInstallPrompt();
84 83
85 // Calls CheckRequirements. 84 // Begin management policy and requirements checks.
86 void CallCheckRequirements(); 85 void StartInstallChecks();
87 86
88 // Callback from RequirementsChecker. 87 // Callback from ExtensionInstallChecker.
89 void OnRequirementsChecked(std::vector<std::string> requirement_errors); 88 void OnInstallChecksComplete(int failed_checks);
90 89
91 // Verifies if loading unpacked extensions is allowed. 90 // Verifies if loading unpacked extensions is allowed.
92 bool IsLoadingUnpackedAllowed() const; 91 bool IsLoadingUnpackedAllowed() const;
93 92
94 // We change the input extension path to an absolute path, on the file thread. 93 // We change the input extension path to an absolute path, on the file thread.
95 // Then we need to check the file access preference, which needs 94 // Then we need to check the file access preference, which needs
96 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on 95 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on
97 // the UI thread. In turn, once that gets the pref, it goes back to the 96 // the UI thread. In turn, once that gets the pref, it goes back to the
98 // file thread with LoadWithFileAccess. 97 // file thread with LoadWithFileAccess.
99 // TODO(yoz): It would be nice to remove this ping-pong, but we need to know 98 // TODO(yoz): It would be nice to remove this ping-pong, but we need to know
100 // what file access flags to pass to file_util::LoadExtension. 99 // what file access flags to pass to file_util::LoadExtension.
101 void GetAbsolutePath(); 100 void GetAbsolutePath();
102 void CheckExtensionFileAccess(); 101 void CheckExtensionFileAccess();
103 void LoadWithFileAccess(int flags); 102 void LoadWithFileAccess(int flags);
104 103
105 // Notify the frontend that an attempt to retry will not be necessary. 104 // Notify the frontend that an attempt to retry will not be necessary.
106 void UnregisterLoadRetryListener(); 105 void UnregisterLoadRetryListener();
107 106
108 // Notify the frontend that there was an error loading an extension. 107 // Notify the frontend that there was an error loading an extension.
109 void ReportExtensionLoadError(const std::string& error); 108 void ReportExtensionLoadError(const std::string& error);
110 109
111 // Called when an unpacked extension has been loaded and installed. 110 // Passes the extension onto extension service.
112 void ConfirmInstall(); 111 void InstallExtension();
113 112
114 // Helper to get the Extension::CreateFlags for the installing extension. 113 // Helper to get the Extension::CreateFlags for the installing extension.
115 int GetFlags(); 114 int GetFlags();
116 115
116 const Extension* extension() { return install_checker_.extension().get(); }
117
117 // The service we will report results back to. 118 // The service we will report results back to.
118 base::WeakPtr<ExtensionService> service_weak_; 119 base::WeakPtr<ExtensionService> service_weak_;
119 120
120 // The pathname of the directory to load from, which is an absolute path 121 // The pathname of the directory to load from, which is an absolute path
121 // after GetAbsolutePath has been called. 122 // after GetAbsolutePath has been called.
122 base::FilePath extension_path_; 123 base::FilePath extension_path_;
123 124
124 // If true and the extension contains plugins, we prompt the user before 125 // If true and the extension contains plugins, we prompt the user before
125 // loading. 126 // loading.
126 bool prompt_for_plugins_; 127 bool prompt_for_plugins_;
127 128
128 // Whether to require the extension installed to have a modern manifest 129 // Whether to require the extension installed to have a modern manifest
129 // version. 130 // version.
130 bool require_modern_manifest_version_; 131 bool require_modern_manifest_version_;
131 132
132 // An optional callback to set in order to be notified of failure. 133 // An optional callback to set in order to be notified of failure.
133 OnFailureCallback on_failure_callback_; 134 OnFailureCallback on_failure_callback_;
134 135
135 // Whether or not to be noisy (show a dialog) on failure. Defaults to true. 136 // Whether or not to be noisy (show a dialog) on failure. Defaults to true.
136 bool be_noisy_on_failure_; 137 bool be_noisy_on_failure_;
137 138
138 // Gives access to common methods and data of an extension installer. 139 // Checks management policies and requirements before the extension can be
139 ExtensionInstaller installer_; 140 // installed.
141 ExtensionInstallChecker install_checker_;
140 142
141 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); 143 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller);
142 }; 144 };
143 145
144 } // namespace extensions 146 } // namespace extensions
145 147
146 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ 148 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_installer.cc ('k') | chrome/browser/extensions/unpacked_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698