OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_CRX_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 // working with it, eg: | 37 // working with it, eg: |
38 // | 38 // |
39 // scoped_refptr<CrxInstaller> installer(new CrxInstaller(...)); | 39 // scoped_refptr<CrxInstaller> installer(new CrxInstaller(...)); |
40 // installer->set_foo(); | 40 // installer->set_foo(); |
41 // installer->set_bar(); | 41 // installer->set_bar(); |
42 // installer->InstallCrx(...); | 42 // installer->InstallCrx(...); |
43 class CrxInstaller | 43 class CrxInstaller |
44 : public SandboxedExtensionUnpackerClient, | 44 : public SandboxedExtensionUnpackerClient, |
45 public ExtensionInstallUI::Delegate { | 45 public ExtensionInstallUI::Delegate { |
46 public: | 46 public: |
| 47 |
| 48 // This is pretty lame, but given the difficulty of connecting a particular |
| 49 // ExtensionFunction to a resulting download in the download manager, it's |
| 50 // currently necessary. This is the |id| of an extension to be installed |
| 51 // *by the web store only* which should not get the permissions install |
| 52 // prompt. |
| 53 // crbug.com/54916 |
| 54 static void SetWhitelistedInstallId(const std::string& id); |
| 55 |
| 56 // Returns whether |id| was found and removed (was whitelisted). |
| 57 static bool ClearWhitelistedInstallId(const std::string& id); |
| 58 |
47 // Constructor. Extensions will be unpacked to |install_directory|. | 59 // Constructor. Extensions will be unpacked to |install_directory|. |
48 // Extension objects will be sent to |frontend|, and any UI will be shown | 60 // Extension objects will be sent to |frontend|, and any UI will be shown |
49 // via |client|. For silent install, pass NULL for |client|. | 61 // via |client|. For silent install, pass NULL for |client|. |
50 CrxInstaller(const FilePath& install_directory, | 62 CrxInstaller(const FilePath& install_directory, |
51 ExtensionsService* frontend, | 63 ExtensionsService* frontend, |
52 ExtensionInstallUI* client); | 64 ExtensionInstallUI* client); |
53 | 65 |
54 // Install the crx in |source_file|. Note that this will most likely | 66 // Install the crx in |source_file|. Note that this will most likely |
55 // complete asynchronously. | 67 // complete asynchronously. |
56 void InstallCrx(const FilePath& source_file); | 68 void InstallCrx(const FilePath& source_file); |
(...skipping 19 matching lines...) Expand all Loading... |
76 void set_expected_id(const std::string& val) { expected_id_ = val; } | 88 void set_expected_id(const std::string& val) { expected_id_ = val; } |
77 | 89 |
78 bool delete_source() const { return delete_source_; } | 90 bool delete_source() const { return delete_source_; } |
79 void set_delete_source(bool val) { delete_source_ = val; } | 91 void set_delete_source(bool val) { delete_source_ = val; } |
80 | 92 |
81 bool allow_privilege_increase() const { return allow_privilege_increase_; } | 93 bool allow_privilege_increase() const { return allow_privilege_increase_; } |
82 void set_allow_privilege_increase(bool val) { | 94 void set_allow_privilege_increase(bool val) { |
83 allow_privilege_increase_ = val; | 95 allow_privilege_increase_ = val; |
84 } | 96 } |
85 | 97 |
| 98 bool allow_silent_install() const { return allow_silent_install_; } |
| 99 void set_allow_silent_install(bool val) { allow_silent_install_ = val; } |
| 100 |
86 bool limit_web_extent_to_download_host() const { | 101 bool limit_web_extent_to_download_host() const { |
87 return limit_web_extent_to_download_host_; | 102 return limit_web_extent_to_download_host_; |
88 } | 103 } |
89 void set_limit_web_extent_to_download_host(bool val) { | 104 void set_limit_web_extent_to_download_host(bool val) { |
90 limit_web_extent_to_download_host_ = val; | 105 limit_web_extent_to_download_host_ = val; |
91 } | 106 } |
92 | 107 |
93 // If |apps_require_extension_mime_type_| is set to true, be sure to set | 108 // If |apps_require_extension_mime_type_| is set to true, be sure to set |
94 // |original_mime_type_| as well. | 109 // |original_mime_type_| as well. |
95 void set_apps_require_extension_mime_type( | 110 void set_apps_require_extension_mime_type( |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 ExtensionInstallUI* client_; | 211 ExtensionInstallUI* client_; |
197 | 212 |
198 // The root of the unpacked extension directory. This is a subdirectory of | 213 // The root of the unpacked extension directory. This is a subdirectory of |
199 // temp_dir_, so we don't have to delete it explicitly. | 214 // temp_dir_, so we don't have to delete it explicitly. |
200 FilePath unpacked_extension_root_; | 215 FilePath unpacked_extension_root_; |
201 | 216 |
202 // True when the CRX being installed was just downloaded. | 217 // True when the CRX being installed was just downloaded. |
203 // Used to trigger extra checks before installing. | 218 // Used to trigger extra checks before installing. |
204 bool apps_require_extension_mime_type_; | 219 bool apps_require_extension_mime_type_; |
205 | 220 |
| 221 // Allows for the possibility of a normal install (one in which a |client| |
| 222 // is provided in the ctor) to procede without showing the permissions prompt |
| 223 // dialog. Note that this will only take place if |allow_silent_install_| |
| 224 // is true AND the unpacked id of the extension is whitelisted with |
| 225 // SetWhitelistedInstallId(). |
| 226 bool allow_silent_install_; |
| 227 |
206 // The value of the content type header sent with the CRX. | 228 // The value of the content type header sent with the CRX. |
207 // Ignorred unless |require_extension_mime_type_| is true. | 229 // Ignorred unless |require_extension_mime_type_| is true. |
208 std::string original_mime_type_; | 230 std::string original_mime_type_; |
209 | 231 |
210 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 232 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
211 }; | 233 }; |
212 | 234 |
213 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 235 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
OLD | NEW |