| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 content::BrowserContext* browser_context, | 61 content::BrowserContext* browser_context, |
| 62 bool is_first_run) | 62 bool is_first_run) |
| 63 : browser_context_(browser_context), | 63 : browser_context_(browser_context), |
| 64 is_first_run_(is_first_run), | 64 is_first_run_(is_first_run), |
| 65 extension_prefs_(ExtensionPrefs::Get(browser_context_)), | 65 extension_prefs_(ExtensionPrefs::Get(browser_context_)), |
| 66 extension_registry_observer_(this) { | 66 extension_registry_observer_(this) { |
| 67 DCHECK(browser_context_); | 67 DCHECK(browser_context_); |
| 68 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_)); | 68 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_)); |
| 69 registrar_.Add( | 69 registrar_.Add( |
| 70 this, | 70 this, |
| 71 chrome::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 if (HasExternalInstallError()) | 80 if (HasExternalInstallError()) |
| 81 return; // Only have one external install error at a time. | 81 return; // Only have one external install error at a time. |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 return (Manifest::IsExternalLocation(extension->location()) && | 209 return (Manifest::IsExternalLocation(extension->location()) && |
| 210 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id()) && | 210 !extension_prefs_->IsExternalExtensionAcknowledged(extension->id()) && |
| 211 !(extension_prefs_->GetDisableReasons(extension->id()) & | 211 !(extension_prefs_->GetDisableReasons(extension->id()) & |
| 212 Extension::DISABLE_SIDELOAD_WIPEOUT)); | 212 Extension::DISABLE_SIDELOAD_WIPEOUT)); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void ExternalInstallManager::Observe( | 215 void ExternalInstallManager::Observe( |
| 216 int type, | 216 int type, |
| 217 const content::NotificationSource& source, | 217 const content::NotificationSource& source, |
| 218 const content::NotificationDetails& details) { | 218 const content::NotificationDetails& details) { |
| 219 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_REMOVED, type); | 219 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_REMOVED, type); |
| 220 // The error is invalidated if the extension has been loaded or removed. | 220 // The error is invalidated if the extension has been loaded or removed. |
| 221 // It's a shame we have to use the notification system (instead of the | 221 // It's a shame we have to use the notification system (instead of the |
| 222 // registry observer) for this, but the ExtensionUnloaded notification is | 222 // registry observer) for this, but the ExtensionUnloaded notification is |
| 223 // not sent out if the extension is disabled (which it is here). | 223 // not sent out if the extension is disabled (which it is here). |
| 224 if (error_.get() && | 224 if (error_.get() && |
| 225 content::Details<const Extension>(details).ptr()->id() == | 225 content::Details<const Extension>(details).ptr()->id() == |
| 226 error_->extension_id()) { | 226 error_->extension_id()) { |
| 227 RemoveExternalInstallError(); | 227 RemoveExternalInstallError(); |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace extensions | 231 } // namespace extensions |
| OLD | NEW |