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

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

Issue 8417012: Refactor loading out of ExtensionService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: finally Created 9 years, 1 month 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
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/file_path.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h"
14
15 class Extension;
16 class ExtensionService;
17
18 namespace extensions {
19
20 // Installs and loads an unpacked extension.
21 // TODO(erikkay): It might be useful to be able to load a packed extension
22 // (presumably into memory) without installing it.
23 class UnpackedInstaller
24 : public base::RefCountedThreadSafe<UnpackedInstaller> {
25 public:
26 static scoped_refptr<UnpackedInstaller> Create(
27 ExtensionService* extension_service);
28
29 // Loads the extension from the directory |extension_path|, which is
30 // the top directory of a specific extension where its manifest file lives.
31 // Errors are reported through ExtensionErrorReporter. On success,
32 // ExtensionService::AddExtension() is called.
33 void Load(const FilePath& extension_path);
34
35 // Loads the extension from the directory |extension_path|;
36 // for use with command line switch --load-extension=path.
37 // This is equivalent to Load, except that it runs synchronously.
38 void LoadFromCommandLine(const FilePath& extension_path);
39
40 // Allows prompting for plugins to be disabled; intended for testing only.
41 bool prompt_for_plugins() { return prompt_for_plugins_; }
42 void set_prompt_for_plugins(bool val) { prompt_for_plugins_ = val; }
43
44 private:
45 friend class base::RefCountedThreadSafe<UnpackedInstaller>;
46
47 explicit UnpackedInstaller(ExtensionService* extension_service);
48 virtual ~UnpackedInstaller();
49
50 // We change the input extension path to an absolute path, on the file thread.
51 // Then we need to check the file access preference, which needs
52 // to happen back on the UI thread, so it posts CheckExtensionFileAccess on
53 // the UI thread. In turn, once that gets the pref, it goes back to the
54 // file thread with LoadWithFileAccess.
55 // TODO(yoz): It would be nice to remove this ping-pong, but we need to know
56 // what file access flags to pass to extension_file_util::LoadExtension.
57 void GetAbsolutePath();
58 void CheckExtensionFileAccess();
59 void LoadWithFileAccess(bool allow_file_access);
60
61 // Notify the frontend that there was an error loading an extension.
62 void ReportExtensionLoadError(const std::string& error);
63
64 // Called when an unpacked extension has been loaded and installed.
65 void OnLoaded(const scoped_refptr<const Extension>& extension);
66
67 base::WeakPtr<ExtensionService> service_weak_;
68
69 // The pathname of the directory to load from, which is an absolute path
70 // after GetAbsolutePath has been called.
71 FilePath extension_path_;
72
73 // If true and the extension contains plugins, we prompt the user before
74 // loading.
75 bool prompt_for_plugins_;
76
77 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller);
78 };
79
80 } // namespace extensions
81
82 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/network_delay_listener_unittest.cc ('k') | chrome/browser/extensions/unpacked_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698