| 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 <vector> | 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 12 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 13 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/extensions/error_console/error_console_factory.h" | 17 #include "chrome/browser/extensions/error_console/error_console_factory.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 138 |
| 138 void ErrorConsole::ReportError(scoped_ptr<ExtensionError> error) { | 139 void ErrorConsole::ReportError(scoped_ptr<ExtensionError> error) { |
| 139 DCHECK(thread_checker_.CalledOnValidThread()); | 140 DCHECK(thread_checker_.CalledOnValidThread()); |
| 140 if (!enabled_ || !crx_file::id_util::IdIsValid(error->extension_id())) | 141 if (!enabled_ || !crx_file::id_util::IdIsValid(error->extension_id())) |
| 141 return; | 142 return; |
| 142 | 143 |
| 143 int mask = GetMaskForExtension(error->extension_id()); | 144 int mask = GetMaskForExtension(error->extension_id()); |
| 144 if (!(mask & (1 << error->type()))) | 145 if (!(mask & (1 << error->type()))) |
| 145 return; | 146 return; |
| 146 | 147 |
| 147 const ExtensionError* weak_error = errors_.AddError(error.Pass()); | 148 const ExtensionError* weak_error = errors_.AddError(std::move(error)); |
| 148 FOR_EACH_OBSERVER(Observer, observers_, OnErrorAdded(weak_error)); | 149 FOR_EACH_OBSERVER(Observer, observers_, OnErrorAdded(weak_error)); |
| 149 } | 150 } |
| 150 | 151 |
| 151 void ErrorConsole::RemoveErrors(const ErrorMap::Filter& filter) { | 152 void ErrorConsole::RemoveErrors(const ErrorMap::Filter& filter) { |
| 152 std::set<std::string> affected_ids; | 153 std::set<std::string> affected_ids; |
| 153 errors_.RemoveErrors(filter, &affected_ids); | 154 errors_.RemoveErrors(filter, &affected_ids); |
| 154 FOR_EACH_OBSERVER(Observer, observers_, OnErrorsRemoved(affected_ids)); | 155 FOR_EACH_OBSERVER(Observer, observers_, OnErrorsRemoved(affected_ids)); |
| 155 } | 156 } |
| 156 | 157 |
| 157 const ErrorList& ErrorConsole::GetErrorsForExtension( | 158 const ErrorList& ErrorConsole::GetErrorsForExtension( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 ExtensionRegistry::Get(profile_)->GetExtensionById( | 293 ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 293 extension_id, ExtensionRegistry::EVERYTHING); | 294 extension_id, ExtensionRegistry::EVERYTHING); |
| 294 if (extension && extension->location() == Manifest::UNPACKED) | 295 if (extension && extension->location() == Manifest::UNPACKED) |
| 295 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1; | 296 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1; |
| 296 | 297 |
| 297 // Otherwise, use the default mask. | 298 // Otherwise, use the default mask. |
| 298 return default_mask_; | 299 return default_mask_; |
| 299 } | 300 } |
| 300 | 301 |
| 301 } // namespace extensions | 302 } // namespace extensions |
| OLD | NEW |