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 | 10 |
10 #include "base/file_path.h" | 11 #include "base/file_path.h" |
11 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
13 | 15 |
14 class ExtensionService; | 16 class ExtensionService; |
15 | 17 |
16 namespace extensions { | 18 namespace extensions { |
17 | 19 |
18 class Extension; | 20 class Extension; |
| 21 class RequirementsChecker; |
19 | 22 |
20 // Installs and loads an unpacked extension. | 23 // Installs and loads an unpacked extension. |
21 // TODO(erikkay): It might be useful to be able to load a packed extension | 24 // TODO(erikkay): It might be useful to be able to load a packed extension |
22 // (presumably into memory) without installing it. | 25 // (presumably into memory) without installing it. |
23 class UnpackedInstaller | 26 class UnpackedInstaller |
24 : public base::RefCountedThreadSafe<UnpackedInstaller> { | 27 : public base::RefCountedThreadSafe<UnpackedInstaller> { |
25 public: | 28 public: |
26 static scoped_refptr<UnpackedInstaller> Create( | 29 static scoped_refptr<UnpackedInstaller> Create( |
27 ExtensionService* extension_service); | 30 ExtensionService* extension_service); |
28 | 31 |
(...skipping 11 matching lines...) Expand all Loading... |
40 // Allows prompting for plugins to be disabled; intended for testing only. | 43 // Allows prompting for plugins to be disabled; intended for testing only. |
41 bool prompt_for_plugins() { return prompt_for_plugins_; } | 44 bool prompt_for_plugins() { return prompt_for_plugins_; } |
42 void set_prompt_for_plugins(bool val) { prompt_for_plugins_ = val; } | 45 void set_prompt_for_plugins(bool val) { prompt_for_plugins_ = val; } |
43 | 46 |
44 private: | 47 private: |
45 friend class base::RefCountedThreadSafe<UnpackedInstaller>; | 48 friend class base::RefCountedThreadSafe<UnpackedInstaller>; |
46 | 49 |
47 explicit UnpackedInstaller(ExtensionService* extension_service); | 50 explicit UnpackedInstaller(ExtensionService* extension_service); |
48 virtual ~UnpackedInstaller(); | 51 virtual ~UnpackedInstaller(); |
49 | 52 |
| 53 // Callback from RequirementsChecker. |
| 54 void RequirementsChecked(std::vector<std::string> errors); |
| 55 |
50 // Verifies if loading unpacked extensions is allowed. | 56 // Verifies if loading unpacked extensions is allowed. |
51 bool IsLoadingUnpackedAllowed() const; | 57 bool IsLoadingUnpackedAllowed() const; |
52 | 58 |
53 // We change the input extension path to an absolute path, on the file thread. | 59 // We change the input extension path to an absolute path, on the file thread. |
54 // Then we need to check the file access preference, which needs | 60 // Then we need to check the file access preference, which needs |
55 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on | 61 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on |
56 // the UI thread. In turn, once that gets the pref, it goes back to the | 62 // the UI thread. In turn, once that gets the pref, it goes back to the |
57 // file thread with LoadWithFileAccess. | 63 // file thread with LoadWithFileAccess. |
58 // TODO(yoz): It would be nice to remove this ping-pong, but we need to know | 64 // TODO(yoz): It would be nice to remove this ping-pong, but we need to know |
59 // what file access flags to pass to extension_file_util::LoadExtension. | 65 // what file access flags to pass to extension_file_util::LoadExtension. |
60 void GetAbsolutePath(); | 66 void GetAbsolutePath(); |
61 void CheckExtensionFileAccess(); | 67 void CheckExtensionFileAccess(); |
62 void LoadWithFileAccess(bool allow_file_access); | 68 void LoadWithFileAccess(bool allow_file_access); |
63 | 69 |
64 // Notify the frontend that there was an error loading an extension. | 70 // Notify the frontend that there was an error loading an extension. |
65 void ReportExtensionLoadError(const std::string& error); | 71 void ReportExtensionLoadError(const std::string& error); |
66 | 72 |
67 // Called when an unpacked extension has been loaded and installed. | 73 // Called when an unpacked extension has been loaded and installed. |
68 void OnLoaded(const scoped_refptr<const Extension>& extension); | 74 void OnLoaded(); |
69 | 75 |
70 base::WeakPtr<ExtensionService> service_weak_; | 76 base::WeakPtr<ExtensionService> service_weak_; |
71 | 77 |
72 // The pathname of the directory to load from, which is an absolute path | 78 // The pathname of the directory to load from, which is an absolute path |
73 // after GetAbsolutePath has been called. | 79 // after GetAbsolutePath has been called. |
74 FilePath extension_path_; | 80 FilePath extension_path_; |
75 | 81 |
76 // If true and the extension contains plugins, we prompt the user before | 82 // If true and the extension contains plugins, we prompt the user before |
77 // loading. | 83 // loading. |
78 bool prompt_for_plugins_; | 84 bool prompt_for_plugins_; |
79 | 85 |
| 86 scoped_ptr<RequirementsChecker> requirements_checker_; |
| 87 |
| 88 scoped_refptr<const Extension> extension_; |
| 89 |
80 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); | 90 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); |
81 }; | 91 }; |
82 | 92 |
83 } // namespace extensions | 93 } // namespace extensions |
84 | 94 |
85 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ | 95 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
OLD | NEW |