#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/stl_util.h"
+#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/install_signer.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/manifest_url_handler.h"
-#include "chrome/common/pref_names.h"
+#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_context.h"
#include "content/public/common/content_switches.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/manifest.h"
+#include "extensions/common/manifest_url_handlers.h"
#include "extensions/common/one_shot_event.h"
-#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
namespace extensions {
result, INIT_RESULT_MAX);
}
-bool FromStore(const Extension& extension) {
- if (extension.from_webstore() || ManifestURL::UpdatesFromGallery(&extension))
- return true;
-
- // If an extension has no update url, our autoupdate code will ask the
- // webstore about it (to aid in migrating to the webstore from self-hosting
- // or sideloading based installs). So we want to do verification checks on
- // such extensions too so that we don't accidentally disable old installs of
- // extensions that did migrate to the webstore.
- return (ManifestURL::GetUpdateURL(&extension).is_empty() &&
- Manifest::IsAutoUpdateableLocation(extension.location()));
-}
-
bool CanUseExtensionApis(const Extension& extension) {
return extension.is_extension() || extension.is_legacy_packaged_app();
}
// static
bool InstallVerifier::NeedsVerification(const Extension& extension) {
- return FromStore(extension) && CanUseExtensionApis(extension);
+ return IsFromStore(extension) && CanUseExtensionApis(extension);
+}
+
+
+
+// static
+bool InstallVerifier::IsFromStore(const Extension& extension) {
+ if (extension.from_webstore() || ManifestURL::UpdatesFromGallery(&extension))
+ return true;
+
+ // If an extension has no update url, our autoupdate code will ask the
+ // webstore about it (to aid in migrating to the webstore from self-hosting
+ // or sideloading based installs). So we want to do verification checks on
+ // such extensions too so that we don't accidentally disable old installs of
+ // extensions that did migrate to the webstore.
+ return (ManifestURL::GetUpdateURL(&extension).is_empty() &&
+ Manifest::IsAutoUpdateableLocation(extension.location()));
}
void InstallVerifier::Init() {
return base::Time();
}
-bool InstallVerifier::IsKnownId(const std::string& id) {
+bool InstallVerifier::IsKnownId(const std::string& id) const {
return signature_.get() && (ContainsKey(signature_->ids, id) ||
ContainsKey(signature_->invalid_ids, id));
}
+bool InstallVerifier::IsInvalid(const std::string& id) const {
+ return ((signature_.get() && ContainsKey(signature_->invalid_ids, id)));
+}
+
void InstallVerifier::VerifyExtension(const std::string& extension_id) {
ExtensionIdSet ids;
ids.insert(extension_id);
BeginFetch();
}
+bool InstallVerifier::AllowedByEnterprisePolicy(const std::string& id) const {
+ return ExtensionManagementFactory::GetForBrowserContext(context_)
+ ->IsInstallationExplicitlyAllowed(id);
+}
+
std::string InstallVerifier::GetDebugPolicyProviderName() const {
return std::string("InstallVerifier");
}
if (ContainsKey(InstallSigner::GetForcedNotFromWebstore(), extension->id())) {
verified = false;
outcome = FORCED_NOT_VERIFIED;
- } else if (!FromStore(*extension)) {
+ } else if (!IsFromStore(*extension)) {
verified = false;
outcome = NOT_FROM_STORE;
} else if (signature_.get() == NULL &&
for (ExtensionSet::const_iterator iter = extensions->begin();
iter != extensions->end();
++iter) {
- if (NeedsVerification(**iter))
+ if (NeedsVerification(*iter->get()))
result.insert((*iter)->id());
}
return result;
++iter) {
int disable_reasons = prefs_->GetDisableReasons((*iter)->id());
if (disable_reasons & Extension::DISABLE_NOT_VERIFIED &&
- !MustRemainDisabled(*iter, NULL, NULL)) {
+ !MustRemainDisabled(iter->get(), NULL, NULL)) {
prefs_->RemoveDisableReason((*iter)->id(),
Extension::DISABLE_NOT_VERIFIED);
}
}
}
-bool InstallVerifier::AllowedByEnterprisePolicy(const std::string& id) const {
- PrefService* pref_service = prefs_->pref_service();
- if (pref_service->IsManagedPreference(pref_names::kInstallAllowList)) {
- const base::ListValue* whitelist =
- pref_service->GetList(pref_names::kInstallAllowList);
- base::StringValue id_value(id);
- if (whitelist && whitelist->Find(id_value) != whitelist->end())
- return true;
- }
- if (pref_service->IsManagedPreference(pref_names::kInstallForceList)) {
- const base::DictionaryValue* forcelist =
- pref_service->GetDictionary(pref_names::kInstallForceList);
- if (forcelist && forcelist->HasKey(id))
- return true;
- }
- return false;
-}
-
bool InstallVerifier::IsVerified(const std::string& id) const {
return ((signature_.get() && ContainsKey(signature_->ids, id)) ||
ContainsKey(provisional_, id));