Chromium Code Reviews| Index: chrome/browser/extensions/unpacked_installer.h |
| diff --git a/chrome/browser/extensions/unpacked_installer.h b/chrome/browser/extensions/unpacked_installer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..61a738f1d5fc1da2d2900cf5fa7a67f40ec02eef |
| --- /dev/null |
| +++ b/chrome/browser/extensions/unpacked_installer.h |
| @@ -0,0 +1,73 @@ |
| +// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
| +#pragma once |
| + |
| +#include <string> |
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/scoped_ptr.h" |
|
Aaron Boodman
2011/10/28 22:21:58
Is this include needed?
Yoyo Zhou
2011/10/31 21:58:15
No.
|
| +#include "base/memory/weak_ptr.h" |
| + |
| +class Extension; |
| +class ExtensionService; |
| +class FilePath; |
| + |
| +// Installs and loads an unpacked extension. |
| +// TODO(erikkay): It might be useful to be able to load a packed extension |
| +// (presumably into memory) without installing it. |
| +class UnpackedInstaller |
|
Aaron Boodman
2011/10/28 22:21:58
I think it would make this a little cleaner if the
Aaron Boodman
2011/10/28 22:21:58
Throughout this change: consider putting all these
Yoyo Zhou
2011/10/31 21:58:15
It's meant to be used as one per installation, lik
Yoyo Zhou
2011/10/31 21:58:15
Done.
Aaron Boodman
2011/10/31 22:33:25
Ok, I was reacting to the file paths getting passe
Yoyo Zhou
2011/11/01 21:50:57
Oh, I suppose I could stop passing them around. It
|
| + : public base::RefCountedThreadSafe<UnpackedInstaller> { |
| + public: |
| + explicit UnpackedInstaller(base::WeakPtr<ExtensionService> extension_service); |
| + |
| + // Loads the extension from the directory |extension_path|. |
| + void Load(const FilePath& extension_path); |
| + |
| + // Loads the extension from the directory |extension_path|; |
| + // for use with command line switch --load-extension=path. |
| + void LoadFromCommandLine(const FilePath& extension_path); |
| + |
| + // Allows prompting for plugins to be disabled; intended for testing only. |
| + bool prompt_for_plugins() { return prompt_for_plugins_; } |
|
Aaron Boodman
2011/10/28 22:21:58
I think that this may no longer be needed. For awh
Yoyo Zhou
2011/10/31 21:58:15
This is used in tests. I'm not sure about removing
|
| + void set_prompt_for_plugins(bool val) { prompt_for_plugins_ = val; } |
| + |
| + private: |
| + friend class base::RefCountedThreadSafe<UnpackedInstaller>; |
| + |
| + virtual ~UnpackedInstaller(); |
| + |
| + // Loads a single extension from |path| where |path| is the top directory of |
| + // a specific extension where its manifest file lives. |
| + // Errors are reported through ExtensionErrorReporter. On success, |
| + // ExtensionService::AddExtension() is called. |
| + void LoadSingleExtension(const FilePath &extension_path); |
| + |
| + // LoadSingleExtension needs to check the file access preference, which needs |
| + // to happen back on the UI thread, so it posts CheckExtensionFileAccess on |
| + // the UI thread. In turn, once that gets the pref, it goes back to the |
| + // file thread with LoadSingleExtensionWithFileAccess. |
| + void CheckExtensionFileAccess(const FilePath& extension_path); |
| + void LoadSingleExtensionWithFileAccess( |
| + const FilePath &path, bool allow_file_access); |
| + |
| + // Notify the frontend that there was an error loading an extension. |
| + void ReportExtensionLoadError(const FilePath& extension_path, |
| + const std::string& error); |
| + |
| + // Called when an unpacked extension has been loaded and installed. |
| + void OnLoadSingleExtension(const scoped_refptr<const Extension>& extension); |
| + |
| + base::WeakPtr<ExtensionService> service_weak_; |
| + |
| + // If true and the extension contains plugins, we prompt the user before |
| + // loading. |
| + bool prompt_for_plugins_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |