| 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 <list> | 7 #include <list> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "content/public/browser/notification_details.h" | 20 #include "content/public/browser/notification_details.h" |
| 21 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 22 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
| 23 #include "extensions/browser/extension_system.h" | 23 #include "extensions/browser/extension_system.h" |
| 24 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
| 25 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
| 26 #include "extensions/common/extension_set.h" | 26 #include "extensions/common/extension_set.h" |
| 27 #include "extensions/common/feature_switch.h" | |
| 28 | 27 |
| 29 namespace extensions { | 28 namespace extensions { |
| 30 | 29 |
| 31 namespace { | 30 namespace { |
| 32 // The key into the Extension prefs for an Extension's specific reporting | 31 // The key into the Extension prefs for an Extension's specific reporting |
| 33 // settings. | 32 // settings. |
| 34 const char kStoreExtensionErrorsPref[] = "store_extension_errors"; | 33 const char kStoreExtensionErrorsPref[] = "store_extension_errors"; |
| 35 | 34 |
| 36 // The default mask (for the time being) is to report everything. | 35 // The default mask (for the time being) is to report everything. |
| 37 const int32 kDefaultMask = (1 << ExtensionError::MANIFEST_ERROR) | | 36 const int32 kDefaultMask = (1 << ExtensionError::MANIFEST_ERROR) | |
| 38 (1 << ExtensionError::RUNTIME_ERROR); | 37 (1 << ExtensionError::RUNTIME_ERROR); |
| 39 } | 38 } |
| 40 | 39 |
| 41 void ErrorConsole::Observer::OnErrorConsoleDestroyed() { | 40 void ErrorConsole::Observer::OnErrorConsoleDestroyed() { |
| 42 } | 41 } |
| 43 | 42 |
| 44 ErrorConsole::ErrorConsole(Profile* profile, | 43 ErrorConsole::ErrorConsole(Profile* profile, |
| 45 ExtensionService* extension_service) | 44 ExtensionService* extension_service) |
| 46 : enabled_(false), default_mask_(kDefaultMask), profile_(profile) { | 45 : enabled_(false), default_mask_(kDefaultMask), profile_(profile) { |
| 47 // TODO(rdevlin.cronin): Remove once crbug.com/159265 is fixed. | 46 // TODO(rdevlin.cronin): Remove once crbug.com/159265 is fixed. |
| 48 #if !defined(ENABLE_EXTENSIONS) | 47 #if !defined(ENABLE_EXTENSIONS) |
| 49 return; | 48 return; |
| 50 #endif | 49 #endif |
| 51 | 50 |
| 52 // If we don't have the necessary FeatureSwitch enabled, then return | |
| 53 // immediately. Since we never register for any notifications, this ensures | |
| 54 // the ErrorConsole will never be enabled. | |
| 55 if (!FeatureSwitch::error_console()->IsEnabled()) | |
| 56 return; | |
| 57 | |
| 58 pref_registrar_.Init(profile_->GetPrefs()); | 51 pref_registrar_.Init(profile_->GetPrefs()); |
| 59 pref_registrar_.Add(prefs::kExtensionsUIDeveloperMode, | 52 pref_registrar_.Add(prefs::kExtensionsUIDeveloperMode, |
| 60 base::Bind(&ErrorConsole::OnPrefChanged, | 53 base::Bind(&ErrorConsole::OnPrefChanged, |
| 61 base::Unretained(this))); | 54 base::Unretained(this))); |
| 62 | 55 |
| 63 if (profile_->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode)) | 56 if (profile_->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode)) |
| 64 Enable(extension_service); | 57 Enable(extension_service); |
| 65 } | 58 } |
| 66 | 59 |
| 67 ErrorConsole::~ErrorConsole() { | 60 ErrorConsole::~ErrorConsole() { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 227 |
| 235 AddManifestErrorsForExtension(info->extension); | 228 AddManifestErrorsForExtension(info->extension); |
| 236 break; | 229 break; |
| 237 } | 230 } |
| 238 default: | 231 default: |
| 239 NOTREACHED(); | 232 NOTREACHED(); |
| 240 } | 233 } |
| 241 } | 234 } |
| 242 | 235 |
| 243 } // namespace extensions | 236 } // namespace extensions |
| OLD | NEW |