| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 int mask = default_mask_; | 94 int mask = default_mask_; |
| 95 // This call can fail if the preference isn't set, but we don't really care | 95 // This call can fail if the preference isn't set, but we don't really care |
| 96 // if it does, because we just use the default mask instead. | 96 // if it does, because we just use the default mask instead. |
| 97 prefs_->ReadPrefAsInteger(extension_id, kStoreExtensionErrorsPref, &mask); | 97 prefs_->ReadPrefAsInteger(extension_id, kStoreExtensionErrorsPref, &mask); |
| 98 | 98 |
| 99 if (enabled) | 99 if (enabled) |
| 100 mask |= 1 << type; | 100 mask |= 1 << type; |
| 101 else | 101 else |
| 102 mask &= ~(1 << type); | 102 mask &= ~(1 << type); |
| 103 | 103 |
| 104 prefs_->UpdateExtensionPref(extension_id, | 104 prefs_->UpdateExtensionPref(extension_id, kStoreExtensionErrorsPref, |
| 105 kStoreExtensionErrorsPref, | 105 new base::Value(mask)); |
| 106 new base::FundamentalValue(mask)); | |
| 107 } | 106 } |
| 108 | 107 |
| 109 void ErrorConsole::SetReportingAllForExtension( | 108 void ErrorConsole::SetReportingAllForExtension( |
| 110 const std::string& extension_id, bool enabled) { | 109 const std::string& extension_id, bool enabled) { |
| 111 DCHECK(thread_checker_.CalledOnValidThread()); | 110 DCHECK(thread_checker_.CalledOnValidThread()); |
| 112 if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id)) | 111 if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id)) |
| 113 return; | 112 return; |
| 114 | 113 |
| 115 int mask = enabled ? (1 << ExtensionError::NUM_ERROR_TYPES) - 1 : 0; | 114 int mask = enabled ? (1 << ExtensionError::NUM_ERROR_TYPES) - 1 : 0; |
| 116 | 115 |
| 117 prefs_->UpdateExtensionPref(extension_id, | 116 prefs_->UpdateExtensionPref(extension_id, kStoreExtensionErrorsPref, |
| 118 kStoreExtensionErrorsPref, | 117 new base::Value(mask)); |
| 119 new base::FundamentalValue(mask)); | |
| 120 } | 118 } |
| 121 | 119 |
| 122 bool ErrorConsole::IsReportingEnabledForExtension( | 120 bool ErrorConsole::IsReportingEnabledForExtension( |
| 123 const std::string& extension_id) const { | 121 const std::string& extension_id) const { |
| 124 DCHECK(thread_checker_.CalledOnValidThread()); | 122 DCHECK(thread_checker_.CalledOnValidThread()); |
| 125 if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id)) | 123 if (!enabled_ || !crx_file::id_util::IdIsValid(extension_id)) |
| 126 return false; | 124 return false; |
| 127 | 125 |
| 128 return GetMaskForExtension(extension_id) != 0; | 126 return GetMaskForExtension(extension_id) != 0; |
| 129 } | 127 } |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 ExtensionRegistry::Get(profile_)->GetExtensionById( | 292 ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 295 extension_id, ExtensionRegistry::EVERYTHING); | 293 extension_id, ExtensionRegistry::EVERYTHING); |
| 296 if (extension && extension->location() == Manifest::UNPACKED) | 294 if (extension && extension->location() == Manifest::UNPACKED) |
| 297 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1; | 295 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1; |
| 298 | 296 |
| 299 // Otherwise, use the default mask. | 297 // Otherwise, use the default mask. |
| 300 return default_mask_; | 298 return default_mask_; |
| 301 } | 299 } |
| 302 | 300 |
| 303 } // namespace extensions | 301 } // namespace extensions |
| OLD | NEW |