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
3// found in the LICENSE file.
4//
5// Download code which handles CRX files (extensions, themes, apps, ...).
6
7#ifndef CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CRX_UTIL_H_
8#define CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CRX_UTIL_H_
9
10
11#include "base/basictypes.h"
12#include "base/memory/ref_counted.h"
13#include "base/memory/scoped_ptr.h"
14
15class ExtensionInstallPrompt;
16class Profile;
17
18namespace content {
19class DownloadItem;
20}
21
22namespace extensions {
23class CrxInstaller;
24}
25
26namespace download_crx_util {
27
28// Allow tests to install a mock ExtensionInstallPrompt object, to fake
29// user clicks on the permissions dialog.
30void SetMockInstallPromptForTesting(
31    scoped_ptr<ExtensionInstallPrompt> mock_prompt);
32
33// Create and pre-configure a CrxInstaller for a given |download_item|.
34scoped_refptr<extensions::CrxInstaller> CreateCrxInstaller(
35    Profile* profile,
36    const content::DownloadItem& download_item);
37
38// Start installing a downloaded item item as a CRX (extension, theme, app,
39// ...).  The installer does work on the file thread, so the installation
40// is not complete when this function returns.  Returns the object managing
41// the installation.
42scoped_refptr<extensions::CrxInstaller> OpenChromeExtension(
43    Profile* profile,
44    const content::DownloadItem& download_item);
45
46// Returns true if this is an extension download. This also considers user
47// scripts to be extension downloads, since we convert those automatically.
48bool IsExtensionDownload(const content::DownloadItem& download_item);
49
50// Checks whether an extension download should be allowed to proceed because the
51// installation site is whitelisted in prefs.
52bool OffStoreInstallAllowedByPrefs(Profile* profile,
53                                   const content::DownloadItem& item);
54
55}  // namespace download_crx_util
56
57#endif  // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CRX_UTIL_H_
58