Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 DCHECK(thread_checker_.CalledOnValidThread()); | 162 DCHECK(thread_checker_.CalledOnValidThread()); |
| 163 observers_.AddObserver(observer); | 163 observers_.AddObserver(observer); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void ErrorConsole::RemoveObserver(Observer* observer) { | 166 void ErrorConsole::RemoveObserver(Observer* observer) { |
| 167 DCHECK(thread_checker_.CalledOnValidThread()); | 167 DCHECK(thread_checker_.CalledOnValidThread()); |
| 168 observers_.RemoveObserver(observer); | 168 observers_.RemoveObserver(observer); |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool ErrorConsole::IsEnabledForChromeExtensionsPage() const { | 171 bool ErrorConsole::IsEnabledForChromeExtensionsPage() const { |
| 172 return profile_->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode) && | 172 FeatureSwitch* error_console = FeatureSwitch::error_console(); |
|
Dan Beam
2015/05/12 01:34:13
put |error_console| as close as possible to its us
hcarmona
2015/05/12 17:20:13
Done.
| |
| 173 (FeatureSwitch::error_console()->IsEnabled() || | 173 |
| 174 GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV); | 174 if (!profile_->GetPrefs()->GetBoolean(prefs::kExtensionsUIDeveloperMode)) |
| 175 return false; // Only enabled in developer mode. | |
| 176 if (GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV && | |
| 177 !error_console->IsEnabled()) | |
| 178 return false; // Restricted to dev channel or opt-in. | |
| 179 | |
| 180 return true; | |
| 175 } | 181 } |
| 176 | 182 |
| 177 bool ErrorConsole::IsEnabledForAppsDeveloperTools() const { | 183 bool ErrorConsole::IsEnabledForAppsDeveloperTools() const { |
| 178 return ExtensionRegistry::Get(profile_)->enabled_extensions() | 184 return ExtensionRegistry::Get(profile_)->enabled_extensions() |
| 179 .Contains(kAppsDeveloperToolsExtensionId); | 185 .Contains(kAppsDeveloperToolsExtensionId); |
| 180 } | 186 } |
| 181 | 187 |
| 182 void ErrorConsole::CheckEnabled() { | 188 void ErrorConsole::CheckEnabled() { |
| 183 bool should_be_enabled = IsEnabledForChromeExtensionsPage() || | 189 bool should_be_enabled = IsEnabledForChromeExtensionsPage() || |
| 184 IsEnabledForAppsDeveloperTools(); | 190 IsEnabledForAppsDeveloperTools(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 ExtensionRegistry::Get(profile_)->GetExtensionById( | 293 ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 288 extension_id, ExtensionRegistry::EVERYTHING); | 294 extension_id, ExtensionRegistry::EVERYTHING); |
| 289 if (extension && extension->location() == Manifest::UNPACKED) | 295 if (extension && extension->location() == Manifest::UNPACKED) |
| 290 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1; | 296 return (1 << ExtensionError::NUM_ERROR_TYPES) - 1; |
| 291 | 297 |
| 292 // Otherwise, use the default mask. | 298 // Otherwise, use the default mask. |
| 293 return default_mask_; | 299 return default_mask_; |
| 294 } | 300 } |
| 295 | 301 |
| 296 } // namespace extensions | 302 } // namespace extensions |
| OLD | NEW |