Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Unified Diff: chrome/browser/extensions/external_provider_impl.cc

Issue 15899007: Add ability to keep external extension for existing user but don't install it for new users (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase + s/LOG(INFO)/VLOG(1)/ Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/external_provider_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/external_provider_impl.cc
diff --git a/chrome/browser/extensions/external_provider_impl.cc b/chrome/browser/extensions/external_provider_impl.cc
index 0a0b51973151afb1990511640ddf515df1522a66..fb29bd5ac0e1066750e5b5d5af5c15ce114d28c2 100644
--- a/chrome/browser/extensions/external_provider_impl.cc
+++ b/chrome/browser/extensions/external_provider_impl.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/app_mode/app_mode_utils.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/external_component_loader.h"
#include "chrome/browser/extensions/external_policy_loader.h"
#include "chrome/browser/extensions/external_pref_loader.h"
@@ -60,10 +61,12 @@ const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url";
const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales";
const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app";
const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore";
+const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present";
ExternalProviderImpl::ExternalProviderImpl(
VisitorInterface* service,
ExternalLoader* loader,
+ Profile* profile,
Manifest::Location crx_location,
Manifest::Location download_location,
int creation_flags)
@@ -73,6 +76,7 @@ ExternalProviderImpl::ExternalProviderImpl(
prefs_(NULL),
ready_(false),
loader_(loader),
+ profile_(profile),
creation_flags_(creation_flags),
auto_acknowledge_(false) {
loader_->Init(this);
@@ -184,9 +188,9 @@ void ExternalProviderImpl::SetPrefs(DictionaryValue* prefs) {
if (!locale_supported) {
unsupported_extensions.insert(extension_id);
- LOG(INFO) << "Skip installing (or uninstall) external extension: "
- << extension_id << " because the extension doesn't support "
- << "the browser locale.";
+ VLOG(1) << "Skip installing (or uninstall) external extension: "
+ << extension_id << " because the extension doesn't support "
+ << "the browser locale.";
continue;
}
}
@@ -202,6 +206,20 @@ void ExternalProviderImpl::SetPrefs(DictionaryValue* prefs) {
is_from_webstore) {
creation_flags |= Extension::FROM_WEBSTORE;
}
+ bool keep_if_present;
+ if (extension->GetBoolean(kKeepIfPresent, &keep_if_present) &&
+ keep_if_present && profile_) {
+ ExtensionServiceInterface* extension_service =
+ ExtensionSystem::Get(profile_)->extension_service();
+ const Extension* extension = extension_service ?
+ extension_service->GetExtensionById(extension_id, true) : NULL;
+ if (!extension) {
+ VLOG(1) << "Skip installing (or uninstall) external extension: "
+ << extension_id << " because the extension should be kept "
+ << "only if it is already installed.";
+ continue;
+ }
+ }
if (has_external_crx) {
if (crx_location_ == Manifest::INVALID_LOCATION) {
@@ -331,6 +349,7 @@ void ExternalProviderImpl::CreateExternalProviders(
new ExternalProviderImpl(
service,
new ExternalPolicyLoader(profile),
+ profile,
Manifest::INVALID_LOCATION,
Manifest::EXTERNAL_POLICY_DOWNLOAD,
Extension::NO_FLAGS)));
@@ -384,6 +403,7 @@ void ExternalProviderImpl::CreateExternalProviders(
service,
new ExternalPrefLoader(external_apps_path_id,
check_admin_permissions_on_mac),
+ profile,
Manifest::EXTERNAL_PREF,
Manifest::EXTERNAL_PREF_DOWNLOAD,
bundled_extension_creation_flags)));
@@ -399,6 +419,7 @@ void ExternalProviderImpl::CreateExternalProviders(
service,
new ExternalPrefLoader(chrome::DIR_USER_EXTERNAL_EXTENSIONS,
ExternalPrefLoader::NONE),
+ profile,
Manifest::EXTERNAL_PREF,
Manifest::EXTERNAL_PREF_DOWNLOAD,
Extension::NO_FLAGS)));
@@ -410,6 +431,7 @@ void ExternalProviderImpl::CreateExternalProviders(
new ExternalProviderImpl(
service,
new ExternalRegistryLoader,
+ profile,
Manifest::EXTERNAL_REGISTRY,
Manifest::INVALID_LOCATION,
Extension::NO_FLAGS)));
@@ -423,6 +445,7 @@ void ExternalProviderImpl::CreateExternalProviders(
new ExternalPrefLoader(
chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS,
ExternalPrefLoader::NONE),
+ profile,
Manifest::EXTERNAL_PREF,
Manifest::EXTERNAL_PREF_DOWNLOAD,
bundled_extension_creation_flags)));
@@ -454,6 +477,7 @@ void ExternalProviderImpl::CreateExternalProviders(
new ExternalProviderImpl(
service,
app_pack_updater->CreateExternalLoader(),
+ profile,
Manifest::EXTERNAL_PREF,
Manifest::INVALID_LOCATION,
Extension::NO_FLAGS)));
@@ -466,6 +490,7 @@ void ExternalProviderImpl::CreateExternalProviders(
new ExternalProviderImpl(
service,
new ExternalComponentLoader(),
+ profile,
Manifest::INVALID_LOCATION,
Manifest::EXTERNAL_POLICY_DOWNLOAD,
Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)));
« no previous file with comments | « chrome/browser/extensions/external_provider_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698