Home | History | Annotate | Download | only in download
      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 
     15 class ExtensionInstallPrompt;
     16 class Profile;
     17 
     18 namespace content {
     19 class DownloadItem;
     20 }
     21 
     22 namespace extensions {
     23 class CrxInstaller;
     24 }
     25 
     26 namespace download_crx_util {
     27 
     28 // Allow tests to install a mock ExtensionInstallPrompt object, to fake
     29 // user clicks on the permissions dialog.
     30 void SetMockInstallPromptForTesting(
     31     scoped_ptr<ExtensionInstallPrompt> mock_prompt);
     32 
     33 // Start installing a downloaded item item as a CRX (extension, theme, app,
     34 // ...).  The installer does work on the file thread, so the installation
     35 // is not complete when this function returns.  Returns the object managing
     36 // the installation.
     37 scoped_refptr<extensions::CrxInstaller> OpenChromeExtension(
     38     Profile* profile,
     39     const content::DownloadItem& download_item);
     40 
     41 // Returns true if this is an extension download. This also considers user
     42 // scripts to be extension downloads, since we convert those automatically.
     43 bool IsExtensionDownload(const content::DownloadItem& download_item);
     44 
     45 // Checks whether an extension download should be allowed to proceed because the
     46 // installation site is whitelisted in prefs.
     47 bool OffStoreInstallAllowedByPrefs(Profile* profile,
     48                                    const content::DownloadItem& item);
     49 
     50 }  // namespace download_crx_util
     51 
     52 #endif  // CHROME_BROWSER_DOWNLOAD_DOWNLOAD_CRX_UTIL_H_
     53