| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/external_install_manager.h" | 5 #include "chrome/browser/extensions/external_install_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 extensions::NOTIFICATION_EXTENSION_REMOVED, | 71 extensions::NOTIFICATION_EXTENSION_REMOVED, |
| 72 content::Source<Profile>(Profile::FromBrowserContext(browser_context_))); | 72 content::Source<Profile>(Profile::FromBrowserContext(browser_context_))); |
| 73 } | 73 } |
| 74 | 74 |
| 75 ExternalInstallManager::~ExternalInstallManager() { | 75 ExternalInstallManager::~ExternalInstallManager() { |
| 76 } | 76 } |
| 77 | 77 |
| 78 void ExternalInstallManager::AddExternalInstallError(const Extension* extension, | 78 void ExternalInstallManager::AddExternalInstallError(const Extension* extension, |
| 79 bool is_new_profile) { | 79 bool is_new_profile) { |
| 80 // Error already exists or has been previously shown. | 80 // Error already exists or has been previously shown. |
| 81 if (ContainsKey(errors_, extension->id()) || | 81 if (base::ContainsKey(errors_, extension->id()) || |
| 82 shown_ids_.count(extension->id()) > 0) | 82 shown_ids_.count(extension->id()) > 0) |
| 83 return; | 83 return; |
| 84 | 84 |
| 85 ExternalInstallError::AlertType alert_type = | 85 ExternalInstallError::AlertType alert_type = |
| 86 (ManifestURL::UpdatesFromGallery(extension) && !is_new_profile) | 86 (ManifestURL::UpdatesFromGallery(extension) && !is_new_profile) |
| 87 ? ExternalInstallError::BUBBLE_ALERT | 87 ? ExternalInstallError::BUBBLE_ALERT |
| 88 : ExternalInstallError::MENU_ALERT; | 88 : ExternalInstallError::MENU_ALERT; |
| 89 | 89 |
| 90 std::unique_ptr<ExternalInstallError> error(new ExternalInstallError( | 90 std::unique_ptr<ExternalInstallError> error(new ExternalInstallError( |
| 91 browser_context_, extension->id(), alert_type, this)); | 91 browser_context_, extension->id(), alert_type, this)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 108 void ExternalInstallManager::UpdateExternalExtensionAlert() { | 108 void ExternalInstallManager::UpdateExternalExtensionAlert() { |
| 109 // If the feature is not enabled do nothing. | 109 // If the feature is not enabled do nothing. |
| 110 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) | 110 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) |
| 111 return; | 111 return; |
| 112 | 112 |
| 113 // Look for any extensions that were disabled because of being unacknowledged | 113 // Look for any extensions that were disabled because of being unacknowledged |
| 114 // external extensions. | 114 // external extensions. |
| 115 const ExtensionSet& disabled_extensions = | 115 const ExtensionSet& disabled_extensions = |
| 116 ExtensionRegistry::Get(browser_context_)->disabled_extensions(); | 116 ExtensionRegistry::Get(browser_context_)->disabled_extensions(); |
| 117 for (const scoped_refptr<const Extension>& extension : disabled_extensions) { | 117 for (const scoped_refptr<const Extension>& extension : disabled_extensions) { |
| 118 if (ContainsKey(errors_, extension->id()) || | 118 if (base::ContainsKey(errors_, extension->id()) || |
| 119 shown_ids_.count(extension->id()) > 0) | 119 shown_ids_.count(extension->id()) > 0) |
| 120 continue; | 120 continue; |
| 121 | 121 |
| 122 if (!IsUnacknowledgedExternalExtension(extension.get())) | 122 if (!IsUnacknowledgedExternalExtension(extension.get())) |
| 123 continue; | 123 continue; |
| 124 | 124 |
| 125 // Warn the user about the suspicious extension. | 125 // Warn the user about the suspicious extension. |
| 126 if (extension_prefs_->IncrementAcknowledgePromptCount(extension->id()) > | 126 if (extension_prefs_->IncrementAcknowledgePromptCount(extension->id()) > |
| 127 kMaxExtensionAcknowledgePromptCount) { | 127 kMaxExtensionAcknowledgePromptCount) { |
| 128 // Stop prompting for this extension and record metrics. | 128 // Stop prompting for this extension and record metrics. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 int type, | 225 int type, |
| 226 const content::NotificationSource& source, | 226 const content::NotificationSource& source, |
| 227 const content::NotificationDetails& details) { | 227 const content::NotificationDetails& details) { |
| 228 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_REMOVED, type); | 228 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_REMOVED, type); |
| 229 // The error is invalidated if the extension has been loaded or removed. | 229 // The error is invalidated if the extension has been loaded or removed. |
| 230 // It's a shame we have to use the notification system (instead of the | 230 // It's a shame we have to use the notification system (instead of the |
| 231 // registry observer) for this, but the ExtensionUnloaded notification is | 231 // registry observer) for this, but the ExtensionUnloaded notification is |
| 232 // not sent out if the extension is disabled (which it is here). | 232 // not sent out if the extension is disabled (which it is here). |
| 233 const std::string& extension_id = | 233 const std::string& extension_id = |
| 234 content::Details<const Extension>(details).ptr()->id(); | 234 content::Details<const Extension>(details).ptr()->id(); |
| 235 if (ContainsKey(errors_, extension_id)) | 235 if (base::ContainsKey(errors_, extension_id)) |
| 236 RemoveExternalInstallError(extension_id); | 236 RemoveExternalInstallError(extension_id); |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace extensions | 239 } // namespace extensions |
| OLD | NEW |