| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (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 scoped_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)); |
| 92 shown_ids_.insert(extension->id()); | 92 shown_ids_.insert(extension->id()); |
| 93 errors_.insert(std::make_pair(extension->id(), std::move(error))); | 93 errors_.insert(std::make_pair(extension->id(), std::move(error))); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void ExternalInstallManager::RemoveExternalInstallError( | 96 void ExternalInstallManager::RemoveExternalInstallError( |
| 97 const std::string& extension_id) { | 97 const std::string& extension_id) { |
| 98 std::map<std::string, scoped_ptr<ExternalInstallError>>::iterator iter = | 98 std::map<std::string, std::unique_ptr<ExternalInstallError>>::iterator iter = |
| 99 errors_.find(extension_id); | 99 errors_.find(extension_id); |
| 100 if (iter != errors_.end()) { | 100 if (iter != errors_.end()) { |
| 101 if (iter->second.get() == currently_visible_install_alert_) | 101 if (iter->second.get() == currently_visible_install_alert_) |
| 102 currently_visible_install_alert_ = nullptr; | 102 currently_visible_install_alert_ = nullptr; |
| 103 errors_.erase(iter); | 103 errors_.erase(iter); |
| 104 UpdateExternalExtensionAlert(); | 104 UpdateExternalExtensionAlert(); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 void ExternalInstallManager::UpdateExternalExtensionAlert() { | 108 void ExternalInstallManager::UpdateExternalExtensionAlert() { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (ContainsKey(errors_, extension_id)) |
| 236 RemoveExternalInstallError(extension_id); | 236 RemoveExternalInstallError(extension_id); |
| 237 } | 237 } |
| 238 | 238 |
| 239 } // namespace extensions | 239 } // namespace extensions |
| OLD | NEW |