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

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

Issue 406713002: Allow drag-and-drop of zipped extensions on chrome://extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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/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_install_checker.h" 16 #include "chrome/browser/extensions/extension_install_checker.h"
17 #include "chrome/browser/extensions/sandboxed_unpacker.h"
17 18
18 class ExtensionService; 19 class ExtensionService;
19 20
20 namespace extensions { 21 namespace extensions {
21 22
22 class Extension; 23 class Extension;
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 : public SandboxedUnpackerClient {
30 : public base::RefCountedThreadSafe<UnpackedInstaller> {
31 public: 31 public:
32 typedef base::Callback<void(const base::FilePath&, const std::string&)> 32 typedef base::Callback<void(const base::FilePath&, const std::string&)>
33 OnFailureCallback; 33 OnFailureCallback;
34 34
35 static scoped_refptr<UnpackedInstaller> Create( 35 static scoped_refptr<UnpackedInstaller> Create(
36 ExtensionService* extension_service); 36 ExtensionService* extension_service);
37 37
38 // Loads the extension from the directory |extension_path|, which is 38 // Loads the extension from the directory |extension_path|, which is
39 // the top directory of a specific extension where its manifest file lives. 39 // the top directory of a specific extension where its manifest file lives.
40 // Errors are reported through ExtensionErrorReporter. On success, 40 // Errors are reported through ExtensionErrorReporter. On success,
41 // ExtensionService::AddExtension() is called. 41 // ExtensionService::AddExtension() is called.
42 void Load(const base::FilePath& extension_path); 42 void Load(const base::FilePath& extension_path);
43 43
44 // Loads the extension from the directory |extension_path|; 44 // Loads the extension from the directory |extension_path|;
45 // for use with command line switch --load-extension=path or 45 // for use with command line switch --load-extension=path or
46 // --load-and-launch-app=path. 46 // --load-and-launch-app=path.
47 // This is equivalent to Load, except that it reads the extension from 47 // This is equivalent to Load, except that it reads the extension from
48 // |extension_path| synchronously. 48 // |extension_path| synchronously.
49 // The return value indicates whether the installation has begun successfully. 49 // The return value indicates whether the installation has begun successfully.
50 // The id of the extension being loaded is returned in |extension_id|. 50 // The id of the extension being loaded is returned in |extension_id|.
51 bool LoadFromCommandLine(const base::FilePath& extension_path, 51 bool LoadFromCommandLine(const base::FilePath& extension_path,
52 std::string* extension_id); 52 std::string* extension_id);
53 53
54 void LoadFromZipFile(const base::FilePath& zip_path);
55
56 // SandboxedUnpackerClient
57 virtual void OnUnpackSuccess(const base::FilePath& temp_dir,
58 const base::FilePath& extension_root,
59 const base::DictionaryValue* original_manifest,
60 const Extension* extension,
61 const SkBitmap& install_icon) OVERRIDE;
62 virtual void OnUnpackFailure(const base::string16& error) OVERRIDE;
63
54 // Allows prompting for plugins to be disabled; intended for testing only. 64 // Allows prompting for plugins to be disabled; intended for testing only.
55 bool prompt_for_plugins() { return prompt_for_plugins_; } 65 bool prompt_for_plugins() { return prompt_for_plugins_; }
56 void set_prompt_for_plugins(bool val) { prompt_for_plugins_ = val; } 66 void set_prompt_for_plugins(bool val) { prompt_for_plugins_ = val; }
57 67
58 // Allows overriding of whether modern manifest versions are required; 68 // Allows overriding of whether modern manifest versions are required;
59 // intended for testing. 69 // intended for testing.
60 bool require_modern_manifest_version() const { 70 bool require_modern_manifest_version() const {
61 return require_modern_manifest_version_; 71 return require_modern_manifest_version_;
62 } 72 }
63 void set_require_modern_manifest_version(bool val) { 73 void set_require_modern_manifest_version(bool val) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // Checks management policies and requirements before the extension can be 142 // Checks management policies and requirements before the extension can be
133 // installed. 143 // installed.
134 ExtensionInstallChecker install_checker_; 144 ExtensionInstallChecker install_checker_;
135 145
136 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); 146 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller);
137 }; 147 };
138 148
139 } // namespace extensions 149 } // namespace extensions
140 150
141 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ 151 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698