| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_warning_service.h" | 5 #include "chrome/browser/extensions/extension_warning_service.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
| 15 #include "extensions/browser/extension_system.h" | 15 #include "extensions/browser/extension_system.h" |
| 16 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 17 | 17 |
| 18 using content::BrowserThread; | 18 using content::BrowserThread; |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 | 21 |
| 22 ExtensionWarningService::ExtensionWarningService(Profile* profile) | 22 ExtensionWarningService::ExtensionWarningService(Profile* profile) |
| 23 : profile_(profile) { | 23 : profile_(profile) { |
| 24 DCHECK(CalledOnValidThread()); | 24 DCHECK(CalledOnValidThread()); |
| 25 if (profile_) { | 25 if (profile_) { |
| 26 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 26 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 27 content::Source<Profile>(profile_->GetOriginalProfile())); | 27 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 28 } | 28 } |
| 29 } | 29 } |
| 30 | 30 |
| 31 ExtensionWarningService::~ExtensionWarningService() {} | 31 ExtensionWarningService::~ExtensionWarningService() {} |
| 32 | 32 |
| 33 void ExtensionWarningService::ClearWarnings( | 33 void ExtensionWarningService::ClearWarnings( |
| 34 const std::set<ExtensionWarning::WarningType>& types) { | 34 const std::set<ExtensionWarning::WarningType>& types) { |
| 35 DCHECK(CalledOnValidThread()); | 35 DCHECK(CalledOnValidThread()); |
| 36 bool deleted_anything = false; | 36 bool deleted_anything = false; |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 117 |
| 118 void ExtensionWarningService::NotifyWarningsChanged() { | 118 void ExtensionWarningService::NotifyWarningsChanged() { |
| 119 FOR_EACH_OBSERVER(Observer, observer_list_, ExtensionWarningsChanged()); | 119 FOR_EACH_OBSERVER(Observer, observer_list_, ExtensionWarningsChanged()); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void ExtensionWarningService::Observe( | 122 void ExtensionWarningService::Observe( |
| 123 int type, | 123 int type, |
| 124 const content::NotificationSource& source, | 124 const content::NotificationSource& source, |
| 125 const content::NotificationDetails& details) { | 125 const content::NotificationDetails& details) { |
| 126 switch (type) { | 126 switch (type) { |
| 127 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 127 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
| 128 const Extension* extension = | 128 const Extension* extension = |
| 129 content::Details<extensions::UnloadedExtensionInfo>(details)-> | 129 content::Details<extensions::UnloadedExtensionInfo>(details)-> |
| 130 extension; | 130 extension; |
| 131 // Unloading one extension might have solved the problems of others. | 131 // Unloading one extension might have solved the problems of others. |
| 132 // Therefore, we clear warnings of this type for all extensions. | 132 // Therefore, we clear warnings of this type for all extensions. |
| 133 std::set<ExtensionWarning::WarningType> warning_types = | 133 std::set<ExtensionWarning::WarningType> warning_types = |
| 134 GetWarningTypesAffectingExtension(extension->id()); | 134 GetWarningTypesAffectingExtension(extension->id()); |
| 135 ClearWarnings(warning_types); | 135 ClearWarnings(warning_types); |
| 136 break; | 136 break; |
| 137 } | 137 } |
| 138 default: | 138 default: |
| 139 NOTREACHED(); | 139 NOTREACHED(); |
| 140 break; | 140 break; |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 | 143 |
| 144 } // namespace extensions | 144 } // namespace extensions |
| OLD | NEW |