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

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

Issue 252593003: Improve UI for unpacked extensions failing to load (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android fix Created 6 years, 7 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 | Annotate | Revision Log
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/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
15 #include "chrome/browser/extensions/extension_installer.h" 16 #include "chrome/browser/extensions/extension_installer.h"
16 17
17 class ExtensionService; 18 class ExtensionService;
18 19
19 namespace extensions { 20 namespace extensions {
20 21
21 class Extension; 22 class Extension;
22 class RequirementsChecker; 23 class RequirementsChecker;
23 24
24 // Installs and loads an unpacked extension. Because internal state needs to be 25 // Installs and loads an unpacked extension. Because internal state needs to be
25 // held about the instalation process, only one call to Load*() should be made 26 // held about the instalation process, only one call to Load*() should be made
26 // per UnpackedInstaller. 27 // per UnpackedInstaller.
27 // TODO(erikkay): It might be useful to be able to load a packed extension 28 // TODO(erikkay): It might be useful to be able to load a packed extension
28 // (presumably into memory) without installing it. 29 // (presumably into memory) without installing it.
29 class UnpackedInstaller 30 class UnpackedInstaller
30 : public base::RefCountedThreadSafe<UnpackedInstaller> { 31 : public base::RefCountedThreadSafe<UnpackedInstaller> {
31 public: 32 public:
33 typedef base::Callback<void(const base::FilePath&, const std::string&)>
34 OnFailureCallback;
35
32 static scoped_refptr<UnpackedInstaller> Create( 36 static scoped_refptr<UnpackedInstaller> Create(
33 ExtensionService* extension_service); 37 ExtensionService* extension_service);
34 38
35 // Loads the extension from the directory |extension_path|, which is 39 // Loads the extension from the directory |extension_path|, which is
36 // the top directory of a specific extension where its manifest file lives. 40 // the top directory of a specific extension where its manifest file lives.
37 // Errors are reported through ExtensionErrorReporter. On success, 41 // Errors are reported through ExtensionErrorReporter. On success,
38 // ExtensionService::AddExtension() is called. 42 // ExtensionService::AddExtension() is called.
39 void Load(const base::FilePath& extension_path); 43 void Load(const base::FilePath& extension_path);
40 44
41 // Loads the extension from the directory |extension_path|; 45 // Loads the extension from the directory |extension_path|;
(...skipping 12 matching lines...) Expand all
54 58
55 // Allows overriding of whether modern manifest versions are required; 59 // Allows overriding of whether modern manifest versions are required;
56 // intended for testing. 60 // intended for testing.
57 bool require_modern_manifest_version() const { 61 bool require_modern_manifest_version() const {
58 return require_modern_manifest_version_; 62 return require_modern_manifest_version_;
59 } 63 }
60 void set_require_modern_manifest_version(bool val) { 64 void set_require_modern_manifest_version(bool val) {
61 require_modern_manifest_version_ = val; 65 require_modern_manifest_version_ = val;
62 } 66 }
63 67
68 void set_on_failure_callback(const OnFailureCallback& callback) {
69 on_failure_callback_ = callback;
70 }
71
64 private: 72 private:
65 friend class base::RefCountedThreadSafe<UnpackedInstaller>; 73 friend class base::RefCountedThreadSafe<UnpackedInstaller>;
66 74
67 explicit UnpackedInstaller(ExtensionService* extension_service); 75 explicit UnpackedInstaller(ExtensionService* extension_service);
68 virtual ~UnpackedInstaller(); 76 virtual ~UnpackedInstaller();
69 77
70 // Must be called from the UI thread. 78 // Must be called from the UI thread.
71 void ShowInstallPrompt(); 79 void ShowInstallPrompt();
72 80
73 // Calls CheckRequirements. 81 // Calls CheckRequirements.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 base::FilePath extension_path_; 118 base::FilePath extension_path_;
111 119
112 // If true and the extension contains plugins, we prompt the user before 120 // If true and the extension contains plugins, we prompt the user before
113 // loading. 121 // loading.
114 bool prompt_for_plugins_; 122 bool prompt_for_plugins_;
115 123
116 // Whether to require the extension installed to have a modern manifest 124 // Whether to require the extension installed to have a modern manifest
117 // version. 125 // version.
118 bool require_modern_manifest_version_; 126 bool require_modern_manifest_version_;
119 127
128 // An optional callback to set in order to be notified of failure.
129 OnFailureCallback on_failure_callback_;
130
120 // Gives access to common methods and data of an extension installer. 131 // Gives access to common methods and data of an extension installer.
121 ExtensionInstaller installer_; 132 ExtensionInstaller installer_;
122 133
123 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); 134 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller);
124 }; 135 };
125 136
126 } // namespace extensions 137 } // namespace extensions
127 138
128 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ 139 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/installed_loader.cc ('k') | chrome/browser/extensions/unpacked_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698