1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick// Use of this source code is governed by a BSD-style license that can be
3731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick// found in the LICENSE file.
4731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
5731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSIONS_STARTUP_H_
6731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick#define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_STARTUP_H_
7731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick#pragma once
8731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
9ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/scoped_ptr.h"
1021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen#include "chrome/browser/extensions/pack_extension_job.h"
1121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
12731df977c0511bca2206b5f333555b1205ff1f43Iain Merrickclass CommandLine;
13731df977c0511bca2206b5f333555b1205ff1f43Iain Merrickclass Profile;
14731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
15731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick// Initialization helpers for various Extension startup actions.
1621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsenclass ExtensionsStartupUtil : public PackExtensionJob::Client {
1721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen public:
1821d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  ExtensionsStartupUtil();
1921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  virtual ~ExtensionsStartupUtil();
2021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
2121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  virtual void OnPackSuccess(const FilePath& crx_path,
2221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen                             const FilePath& output_private_key_path);
2321d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  virtual void OnPackFailure(const std::string& error_message);
2421d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
2521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // Handle --pack-extension flag from the |cmd_line| by packing the specified
2621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // extension. Returns false if the pack job failed.
2721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  bool PackExtension(const CommandLine& cmd_line);
2821d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
2921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // Handle --uninstall-extension flag from the |cmd_line| by uninstalling the
3021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // specified extension from |profile|. Returns false if the uninstall job
3121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  // could not be started.
3221d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  bool UninstallExtension(const CommandLine& cmd_line, Profile* profile);
3321d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
3421d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen private:
3521d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  void ShowPackExtensionMessage(const std::wstring& caption,
3621d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen                                const std::wstring& message);
3721d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  scoped_refptr<PackExtensionJob> pack_job_;
3821d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  bool pack_job_succeeded_;
3921d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen
4021d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen  DISALLOW_COPY_AND_ASSIGN(ExtensionsStartupUtil);
4121d179b334e59e9a3bfcaed4c4430bef1bc5759dKristian Monsen};
42731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick
43731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick#endif  // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_STARTUP_H_
44