Chromium Code Reviews| Index: chrome/browser/extensions/error_console/error_console.cc |
| diff --git a/chrome/browser/extensions/error_console/error_console.cc b/chrome/browser/extensions/error_console/error_console.cc |
| index 2429af614a413b7bf187029e5a40e71f3e11dceb..0a1109e6018f37bf15a1098a8a5ccd30b433a023 100644 |
| --- a/chrome/browser/extensions/error_console/error_console.cc |
| +++ b/chrome/browser/extensions/error_console/error_console.cc |
| @@ -37,9 +37,8 @@ namespace { |
| // settings. |
| const char kStoreExtensionErrorsPref[] = "store_extension_errors"; |
| -// The default mask (for the time being) is to report everything. |
| -const int32 kDefaultMask = (1 << ExtensionError::MANIFEST_ERROR) | |
| - (1 << ExtensionError::RUNTIME_ERROR); |
| +// The default mask (for the time being) is to report nothing. |
|
not at google - send to devlin
2014/04/15 21:57:41
"default" mask is pretty meaningless without conte
Devlin
2014/04/16 18:10:48
Done.
|
| +const int32 kDefaultMask = 0; |
| const char kAppsDeveloperToolsExtensionId[] = |
| "ohmmkhmmmpcnpikjeljgnaoabkaalbgc"; |
| @@ -101,6 +100,14 @@ void ErrorConsole::SetReportingForExtension(const std::string& extension_id, |
| base::Value::CreateIntegerValue(pref->second)); |
| } |
| +bool ErrorConsole::IsReportingEnabledForExtension( |
| + const std::string& extension_id) const { |
| + return ShouldReportErrorForExtension(extension_id, |
| + ExtensionError::MANIFEST_ERROR) || |
| + ShouldReportErrorForExtension(extension_id, |
| + ExtensionError::RUNTIME_ERROR); |
| +} |
| + |
| void ErrorConsole::UseDefaultReportingForExtension( |
| const std::string& extension_id) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| @@ -116,16 +123,9 @@ void ErrorConsole::UseDefaultReportingForExtension( |
| void ErrorConsole::ReportError(scoped_ptr<ExtensionError> error) { |
| DCHECK(thread_checker_.CalledOnValidThread()); |
| - if (!enabled_ || !Extension::IdIsValid(error->extension_id())) |
| - return; |
| - |
| - ErrorPreferenceMap::const_iterator pref = |
| - pref_map_.find(error->extension_id()); |
| - // Check the mask to see if we report the error. If we don't have a specific |
| - // entry, use the default mask. |
| - if ((pref == pref_map_.end() && |
| - ((default_mask_ & (1 << error->type())) == 0)) || |
| - (pref != pref_map_.end() && (pref->second & (1 << error->type())) == 0)) { |
| + if (!enabled_ || |
| + !Extension::IdIsValid(error->extension_id()) || |
| + !ShouldReportErrorForExtension(error->extension_id(), error->type())) { |
| return; |
| } |
| @@ -269,4 +269,26 @@ void ErrorConsole::Observe(int type, |
| } |
| } |
| +bool ErrorConsole::ShouldReportErrorForExtension( |
| + const std::string& extension_id, ExtensionError::Type type) const { |
| + ErrorPreferenceMap::const_iterator pref = pref_map_.find(extension_id); |
| + // Registered preferences take priority over everything else. |
|
not at google - send to devlin
2014/04/15 21:57:41
nit: put this comment above the declaration of |pr
Devlin
2014/04/16 18:10:48
Done.
|
| + if (pref != pref_map_.end()) |
| + return (pref->second & (1 << type)) != 0; |
| + |
| + // If the default mask says to report the error, do so. |
| + if ((default_mask_ & (1 << type)) != 0) |
| + return true; |
| + |
| + // One last check: If the extension is unpacked, we report all errors by |
| + // default. |
| + const Extension* extension = |
| + ExtensionRegistry::Get(profile_)->GetExtensionById( |
| + extension_id, ExtensionRegistry::EVERYTHING); |
| + if (extension && extension->location() == Manifest::UNPACKED) |
| + return true; |
| + |
| + return false; |
| +} |
| + |
| } // namespace extensions |