| OLD | NEW |
| 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/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "chrome/browser/extensions/app_host_installer.h" |
| 15 | 16 |
| 16 class ExtensionService; | 17 class ExtensionService; |
| 17 | 18 |
| 18 namespace extensions { | 19 namespace extensions { |
| 19 | 20 |
| 20 class Extension; | 21 class Extension; |
| 21 class RequirementsChecker; | 22 class RequirementsChecker; |
| 22 | 23 |
| 23 // 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 |
| 24 // 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 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 64 |
| 64 // Must be called from the UI thread. | 65 // Must be called from the UI thread. |
| 65 void CheckRequirements(); | 66 void CheckRequirements(); |
| 66 | 67 |
| 67 // Callback from RequirementsChecker. | 68 // Callback from RequirementsChecker. |
| 68 void OnRequirementsChecked(std::vector<std::string> requirement_errors); | 69 void OnRequirementsChecked(std::vector<std::string> requirement_errors); |
| 69 | 70 |
| 70 // Verifies if loading unpacked extensions is allowed. | 71 // Verifies if loading unpacked extensions is allowed. |
| 71 bool IsLoadingUnpackedAllowed() const; | 72 bool IsLoadingUnpackedAllowed() const; |
| 72 | 73 |
| 73 // We change the input extension path to an absolute path, on the file thread. | 74 // We change the input extension path to an absolute path, on the FILE thread. |
| 74 // Then we need to check the file access preference, which needs | 75 // Then we need to check the file access preference, which needs |
| 75 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on | 76 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on |
| 76 // the UI thread. In turn, once that gets the pref, it goes back to the | 77 // the UI thread. In turn, once that gets the pref, it goes back to the |
| 77 // file thread with LoadWithFileAccess. | 78 // FILE thread with LoadWithFileAccess. |
| 78 // TODO(yoz): It would be nice to remove this ping-pong, but we need to know | 79 // TODO(yoz): It would be nice to remove this ping-pong, but we need to know |
| 79 // what file access flags to pass to extension_file_util::LoadExtension. | 80 // what file access flags to pass to extension_file_util::LoadExtension. |
| 80 void GetAbsolutePath(); | 81 void GetAbsolutePath(); |
| 81 void CheckExtensionFileAccess(); | 82 void CheckExtensionFileAccess(); |
| 82 void LoadWithFileAccess(int flags); | 83 void LoadWithFileAccess(int flags); |
| 83 | 84 |
| 84 // Notify the frontend that there was an error loading an extension. | 85 // Notify the frontend that there was an error loading an extension. |
| 85 void ReportExtensionLoadError(const std::string& error); | 86 void ReportExtensionLoadError(const std::string& error); |
| 86 | 87 |
| 87 // Called when an unpacked extension has been loaded and installed. | 88 // Called when an unpacked extension has been loaded and installed. |
| 88 void OnLoaded(); | 89 void OnLoaded(); |
| 89 | 90 |
| 91 // Runs on UI thread. If App Host is not installed, calls installer and |
| 92 // posts OnAppHostInstallationComplete() as call back. Else proceeds to |
| 93 // CompleteInstall(). |
| 94 void BeginInstall(); |
| 95 |
| 96 // Runs on UI thread. Callback function for AppHostInstaller. |
| 97 // If not |success|, shows error message. Else proceeds to CompleteInstall(). |
| 98 void OnAppHostInstallation(bool success); |
| 99 |
| 100 // Runs on UI thread. Installs the unpacked extension into the profile and |
| 101 // notifies the frontend. |
| 102 void CompleteInstall(); |
| 103 |
| 90 // Helper to get the Extension::CreateFlags for the installing extension. | 104 // Helper to get the Extension::CreateFlags for the installing extension. |
| 91 int GetFlags(); | 105 int GetFlags(); |
| 92 | 106 |
| 93 base::WeakPtr<ExtensionService> service_weak_; | 107 base::WeakPtr<ExtensionService> service_weak_; |
| 94 | 108 |
| 95 // The pathname of the directory to load from, which is an absolute path | 109 // The pathname of the directory to load from, which is an absolute path |
| 96 // after GetAbsolutePath has been called. | 110 // after GetAbsolutePath has been called. |
| 97 FilePath extension_path_; | 111 FilePath extension_path_; |
| 98 | 112 |
| 99 // If true and the extension contains plugins, we prompt the user before | 113 // If true and the extension contains plugins, we prompt the user before |
| 100 // loading. | 114 // loading. |
| 101 bool prompt_for_plugins_; | 115 bool prompt_for_plugins_; |
| 102 | 116 |
| 103 scoped_ptr<RequirementsChecker> requirements_checker_; | 117 scoped_ptr<RequirementsChecker> requirements_checker_; |
| 104 | 118 |
| 105 scoped_refptr<const Extension> extension_; | 119 scoped_refptr<const Extension> extension_; |
| 106 | 120 |
| 107 // Whether to require the extension installed to have a modern manifest | 121 // Whether to require the extension installed to have a modern manifest |
| 108 // version. | 122 // version. |
| 109 bool require_modern_manifest_version_; | 123 bool require_modern_manifest_version_; |
| 110 | 124 |
| 125 // Helper to install App Host. |
| 126 AppHostInstaller app_host_installer_; |
| 127 |
| 111 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); | 128 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); |
| 112 }; | 129 }; |
| 113 | 130 |
| 114 } // namespace extensions | 131 } // namespace extensions |
| 115 | 132 |
| 116 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ | 133 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| OLD | NEW |