| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/error_console/error_console.h" | 5 #include "chrome/browser/extensions/error_console/error_console.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 void ErrorConsole::UseDefaultReportingForExtension( | 130 void ErrorConsole::UseDefaultReportingForExtension( |
| 131 const std::string& extension_id) { | 131 const std::string& extension_id) { |
| 132 DCHECK(thread_checker_.CalledOnValidThread()); | 132 DCHECK(thread_checker_.CalledOnValidThread()); |
| 133 if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id)) | 133 if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id)) |
| 134 return; | 134 return; |
| 135 | 135 |
| 136 prefs_->UpdateExtensionPref(extension_id, kStoreExtensionErrorsPref, NULL); | 136 prefs_->UpdateExtensionPref(extension_id, kStoreExtensionErrorsPref, NULL); |
| 137 } | 137 } |
| 138 | 138 |
| 139 void ErrorConsole::ReportError(scoped_ptr<ExtensionError> error) { | 139 void ErrorConsole::ReportError(std::unique_ptr<ExtensionError> error) { |
| 140 DCHECK(thread_checker_.CalledOnValidThread()); | 140 DCHECK(thread_checker_.CalledOnValidThread()); |
| 141 if (!enabled_ || !crx_file::id_util::IdIsValid(error->extension_id())) | 141 if (!enabled_ || !crx_file::id_util::IdIsValid(error->extension_id())) |
| 142 return; | 142 return; |
| 143 | 143 |
| 144 int mask = GetMaskForExtension(error->extension_id()); | 144 int mask = GetMaskForExtension(error->extension_id()); |
| 145 if (!(mask & (1 << error->type()))) | 145 if (!(mask & (1 << error->type()))) |
| 146 return; | 146 return; |
| 147 | 147 |
| 148 const ExtensionError* weak_error = errors_.AddError(std::move(error)); | 148 const ExtensionError* weak_error = errors_.AddError(std::move(error)); |
| 149 FOR_EACH_OBSERVER(Observer, observers_, OnErrorAdded(weak_error)); | 149 FOR_EACH_OBSERVER(Observer, observers_, OnErrorAdded(weak_error)); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 extensions::UninstallReason reason) { | 256 extensions::UninstallReason reason) { |
| 257 errors_.RemoveErrors(ErrorMap::Filter::ErrorsForExtension(extension->id()), | 257 errors_.RemoveErrors(ErrorMap::Filter::ErrorsForExtension(extension->id()), |
| 258 nullptr); | 258 nullptr); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void ErrorConsole::AddManifestErrorsForExtension(const Extension* extension) { | 261 void ErrorConsole::AddManifestErrorsForExtension(const Extension* extension) { |
| 262 const std::vector<InstallWarning>& warnings = | 262 const std::vector<InstallWarning>& warnings = |
| 263 extension->install_warnings(); | 263 extension->install_warnings(); |
| 264 for (std::vector<InstallWarning>::const_iterator iter = warnings.begin(); | 264 for (std::vector<InstallWarning>::const_iterator iter = warnings.begin(); |
| 265 iter != warnings.end(); ++iter) { | 265 iter != warnings.end(); ++iter) { |
| 266 ReportError(scoped_ptr<ExtensionError>(new ManifestError( | 266 ReportError(std::unique_ptr<ExtensionError>(new ManifestError( |
| 267 extension->id(), | 267 extension->id(), base::UTF8ToUTF16(iter->message), |
| 268 base::UTF8ToUTF16(iter->message), | 268 base::UTF8ToUTF16(iter->key), base::UTF8ToUTF16(iter->specific)))); |
| 269 base::UTF8ToUTF16(iter->key), | |
| 270 base::UTF8ToUTF16(iter->specific)))); | |
| 271 } | 269 } |
| 272 } | 270 } |
| 273 | 271 |
| 274 void ErrorConsole::Observe(int type, | 272 void ErrorConsole::Observe(int type, |
| 275 const content::NotificationSource& source, | 273 const content::NotificationSource& source, |
| 276 const content::NotificationDetails& details) { | 274 const content::NotificationDetails& details) { |
| 277 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 275 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
| 278 Profile* profile = content::Source<Profile>(source).ptr(); | 276 Profile* profile = content::Source<Profile>(source).ptr(); |
| 279 // If incognito profile which we are associated with is destroyed, also | 277 // If incognito profile which we are associated with is destroyed, also |
| 280 // destroy all incognito errors. | 278 // destroy all incognito errors. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 293 ExtensionRegistry::Get(profile_)->GetExtensionById( | 291 ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 294 extension_id, ExtensionRegistry::EVERYTHING); | 292 extension_id, ExtensionRegistry::EVERYTHING); |
| 295 if (extension && extension->location() == Manifest::UNPACKED) | 293 if (extension && extension->location() == Manifest::UNPACKED) |
| 296 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1; | 294 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1; |
| 297 | 295 |
| 298 // Otherwise, use the default mask. | 296 // Otherwise, use the default mask. |
| 299 return default_mask_; | 297 return default_mask_; |
| 300 } | 298 } |
| 301 | 299 |
| 302 } // namespace extensions | 300 } // namespace extensions |
| OLD | NEW |