Chromium Code Reviews| 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_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 for (const auto& extension : | 77 for (const auto& extension : |
| 78 ExtensionRegistry::Get(browser_context)->disabled_extensions()) { | 78 ExtensionRegistry::Get(browser_context)->disabled_extensions()) { |
| 79 if (IsUnacknowledgedExternalExtension(*extension)) | 79 if (IsUnacknowledgedExternalExtension(*extension)) |
| 80 unacknowledged_ids_.insert(extension->id()); | 80 unacknowledged_ids_.insert(extension->id()); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 ExternalInstallManager::~ExternalInstallManager() { | 84 ExternalInstallManager::~ExternalInstallManager() { |
| 85 } | 85 } |
| 86 | 86 |
| 87 | |
| 88 bool ExternalInstallManager::IsPromptingEnabled() { | |
| 89 // Enable this feature on canary on mac. | |
| 90 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) | |
| 91 return GetCurrentChannel() < version_info::Channel::CANARY; | |
|
lazyboy
2017/01/11 01:46:40
Did you mean <= ?
Devlin
2017/01/11 15:53:33
I did, good catch! Done.
| |
| 92 #else | |
| 93 return FeatureSwitch::prompt_for_external_extensions()->IsEnabled(); | |
| 94 #endif | |
| 95 } | |
| 96 | |
| 87 void ExternalInstallManager::AddExternalInstallError(const Extension* extension, | 97 void ExternalInstallManager::AddExternalInstallError(const Extension* extension, |
| 88 bool is_new_profile) { | 98 bool is_new_profile) { |
| 89 // Error already exists or has been previously shown. | 99 // Error already exists or has been previously shown. |
| 90 if (base::ContainsKey(errors_, extension->id()) || | 100 if (base::ContainsKey(errors_, extension->id()) || |
| 91 shown_ids_.count(extension->id()) > 0) | 101 shown_ids_.count(extension->id()) > 0) |
| 92 return; | 102 return; |
| 93 | 103 |
| 94 ExternalInstallError::AlertType alert_type = | 104 ExternalInstallError::AlertType alert_type = |
| 95 (ManifestURL::UpdatesFromGallery(extension) && !is_new_profile) | 105 (ManifestURL::UpdatesFromGallery(extension) && !is_new_profile) |
| 96 ? ExternalInstallError::BUBBLE_ALERT | 106 ? ExternalInstallError::BUBBLE_ALERT |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 109 if (iter->second.get() == currently_visible_install_alert_) | 119 if (iter->second.get() == currently_visible_install_alert_) |
| 110 currently_visible_install_alert_ = nullptr; | 120 currently_visible_install_alert_ = nullptr; |
| 111 errors_.erase(iter); | 121 errors_.erase(iter); |
| 112 unacknowledged_ids_.erase(extension_id); | 122 unacknowledged_ids_.erase(extension_id); |
| 113 UpdateExternalExtensionAlert(); | 123 UpdateExternalExtensionAlert(); |
| 114 } | 124 } |
| 115 } | 125 } |
| 116 | 126 |
| 117 void ExternalInstallManager::UpdateExternalExtensionAlert() { | 127 void ExternalInstallManager::UpdateExternalExtensionAlert() { |
| 118 // If the feature is not enabled do nothing. | 128 // If the feature is not enabled do nothing. |
| 119 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) | 129 if (!IsPromptingEnabled()) |
| 120 return; | 130 return; |
| 121 | 131 |
| 122 // Look for any extensions that were disabled because of being unacknowledged | 132 // Look for any extensions that were disabled because of being unacknowledged |
| 123 // external extensions. | 133 // external extensions. |
| 124 const ExtensionSet& disabled_extensions = | 134 const ExtensionSet& disabled_extensions = |
| 125 ExtensionRegistry::Get(browser_context_)->disabled_extensions(); | 135 ExtensionRegistry::Get(browser_context_)->disabled_extensions(); |
| 126 for (const auto& id : unacknowledged_ids_) { | 136 for (const auto& id : unacknowledged_ids_) { |
| 127 if (base::ContainsKey(errors_, id) || shown_ids_.count(id) > 0) | 137 if (base::ContainsKey(errors_, id) || shown_ids_.count(id) > 0) |
| 128 continue; | 138 continue; |
| 129 | 139 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 void ExternalInstallManager::OnExtensionUninstalled( | 222 void ExternalInstallManager::OnExtensionUninstalled( |
| 213 content::BrowserContext* browser_context, | 223 content::BrowserContext* browser_context, |
| 214 const Extension* extension, | 224 const Extension* extension, |
| 215 extensions::UninstallReason reason) { | 225 extensions::UninstallReason reason) { |
| 216 if (unacknowledged_ids_.erase(extension->id())) | 226 if (unacknowledged_ids_.erase(extension->id())) |
| 217 LogExternalExtensionEvent(extension, EXTERNAL_EXTENSION_UNINSTALLED); | 227 LogExternalExtensionEvent(extension, EXTERNAL_EXTENSION_UNINSTALLED); |
| 218 } | 228 } |
| 219 | 229 |
| 220 bool ExternalInstallManager::IsUnacknowledgedExternalExtension( | 230 bool ExternalInstallManager::IsUnacknowledgedExternalExtension( |
| 221 const Extension& extension) const { | 231 const Extension& extension) const { |
| 222 if (!FeatureSwitch::prompt_for_external_extensions()->IsEnabled()) | 232 if (!IsPromptingEnabled()) |
| 223 return false; | 233 return false; |
| 224 | 234 |
| 225 int disable_reasons = extension_prefs_->GetDisableReasons(extension.id()); | 235 int disable_reasons = extension_prefs_->GetDisableReasons(extension.id()); |
| 226 bool is_from_sideload_wipeout = | 236 bool is_from_sideload_wipeout = |
| 227 (disable_reasons & Extension::DISABLE_SIDELOAD_WIPEOUT) != 0; | 237 (disable_reasons & Extension::DISABLE_SIDELOAD_WIPEOUT) != 0; |
| 228 // We don't consider extensions that weren't disabled for being external so | 238 // We don't consider extensions that weren't disabled for being external so |
| 229 // that we grandfather in extensions. External extensions are only disabled on | 239 // that we grandfather in extensions. External extensions are only disabled on |
| 230 // install with the "prompt for external extensions" feature enabled. | 240 // install with the "prompt for external extensions" feature enabled. |
| 231 bool is_disabled_external = | 241 bool is_disabled_external = |
| 232 (disable_reasons & Extension::DISABLE_EXTERNAL_EXTENSION) != 0; | 242 (disable_reasons & Extension::DISABLE_EXTERNAL_EXTENSION) != 0; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 244 // It's a shame we have to use the notification system (instead of the | 254 // It's a shame we have to use the notification system (instead of the |
| 245 // registry observer) for this, but the ExtensionUnloaded notification is | 255 // registry observer) for this, but the ExtensionUnloaded notification is |
| 246 // not sent out if the extension is disabled (which it is here). | 256 // not sent out if the extension is disabled (which it is here). |
| 247 const std::string& extension_id = | 257 const std::string& extension_id = |
| 248 content::Details<const Extension>(details).ptr()->id(); | 258 content::Details<const Extension>(details).ptr()->id(); |
| 249 if (base::ContainsKey(errors_, extension_id)) | 259 if (base::ContainsKey(errors_, extension_id)) |
| 250 RemoveExternalInstallError(extension_id); | 260 RemoveExternalInstallError(extension_id); |
| 251 } | 261 } |
| 252 | 262 |
| 253 } // namespace extensions | 263 } // namespace extensions |
| OLD | NEW |