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_PENDING_EXTENSION_INFO_H_ 6 #define CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ 7 #pragma once 8 9 #include "chrome/common/extensions/extension.h" 10 11 class GURL; 12 13 // A pending extension is an extension that hasn't been installed yet 14 // and is intended to be installed in the next auto-update cycle. The 15 // update URL of a pending extension may be blank, in which case a 16 // default one is assumed. 17 // TODO(skerner): Make this class an implementation detail of 18 // PendingExtensionManager, and remove all other users. 19 class PendingExtensionInfo { 20 public: 21 typedef bool (*ShouldAllowInstallPredicate)(const Extension&); 22 23 PendingExtensionInfo( 24 const GURL& update_url, 25 ShouldAllowInstallPredicate should_allow_install, 26 bool is_from_sync, 27 bool install_silently, 28 bool enable_on_install, 29 bool enable_incognito_on_install, 30 Extension::Location install_source); 31 32 // Required for STL container membership. Should not be used directly. 33 PendingExtensionInfo(); 34 35 const GURL& update_url() const { return update_url_; } 36 37 // ShouldAllowInstall() returns the result of running constructor argument 38 // |should_allow_install| on an extension. After an extension is unpacked, 39 // this function is run. If it returns true, the extension is installed. 40 // If not, the extension is discarded. This allows creators of 41 // PendingExtensionInfo objects to ensure that extensions meet some criteria 42 // that can only be tested once the extension is unpacked. 43 bool ShouldAllowInstall(const Extension& extension) const { 44 return should_allow_install_(extension); 45 } 46 bool is_from_sync() const { return is_from_sync_; } 47 bool install_silently() const { return install_silently_; } 48 bool enable_on_install() const { return enable_on_install_; } 49 bool enable_incognito_on_install() const { 50 return enable_incognito_on_install_; 51 } 52 Extension::Location install_source() const { return install_source_; } 53 54 private: 55 GURL update_url_; 56 57 // When the extension is about to be installed, this function is 58 // called. If this function returns true, the install proceeds. If 59 // this function returns false, the install is aborted. 60 ShouldAllowInstallPredicate should_allow_install_; 61 62 bool is_from_sync_; // This update check was initiated from sync. 63 bool install_silently_; 64 bool enable_on_install_; 65 bool enable_incognito_on_install_; 66 Extension::Location install_source_; 67 68 FRIEND_TEST_ALL_PREFIXES(ExtensionServiceTest, AddPendingExtensionFromSync); 69 }; 70 71 #endif // CHROME_BROWSER_EXTENSIONS_PENDING_EXTENSION_INFO_H_ 72