|
OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/gpu/gpu_mode_manager.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/prefs/pref_registry_simple.h" | |
9 #include "base/prefs/pref_service.h" | |
10 #include "chrome/browser/browser_process.h" | |
11 #include "chrome/common/pref_names.h" | |
12 #include "content/public/browser/gpu_data_manager.h" | |
13 | |
14 // static | |
15 void GpuModeManager::RegisterPrefs(PrefRegistrySimple* registry) { | |
16 registry->RegisterBooleanPref( | |
17 prefs::kHardwareAccelerationModeEnabled, true); | |
18 } | |
19 | |
20 GpuModeManager::GpuModeManager() { | |
21 CHECK(g_browser_process != NULL); | |
Lei Zhang
2013/03/08 23:29:10
Probably don't need this. If |g_browser_process| i
Zhenyao Mo
2013/03/09 00:15:45
Done.
| |
22 if (g_browser_process->local_state()) { // Skip for unit tests | |
23 pref_registrar_.Init(g_browser_process->local_state()); | |
24 pref_registrar_.Add( | |
Lei Zhang
2013/03/08 23:29:10
Do you need this when OnGpuModeEnabledPrefChanged
Zhenyao Mo
2013/03/09 00:15:45
I do need this, otherwise Settings page won't load
| |
25 prefs::kHardwareAccelerationModeEnabled, | |
26 base::Bind(&GpuModeManager::OnGpuModeEnabledPrefChanged, | |
27 base::Unretained(this))); | |
28 | |
29 if (!IsGpuModePrefEnabled()) { | |
30 content::GpuDataManager* gpu_data_manager = | |
31 content::GpuDataManager::GetInstance(); | |
32 DCHECK(gpu_data_manager); | |
33 gpu_data_manager->DisableHardwareAcceleration(); | |
34 } | |
35 } | |
36 } | |
37 | |
38 GpuModeManager::~GpuModeManager() { | |
39 } | |
40 | |
41 void GpuModeManager::OnGpuModeEnabledPrefChanged() { | |
42 // Do nothing. The pref change takes effect after chrome restarts. | |
43 } | |
44 | |
45 bool GpuModeManager::IsGpuModePrefEnabled() const { | |
46 PrefService* service = g_browser_process->local_state(); | |
47 DCHECK(service); | |
48 return service->GetBoolean( | |
49 prefs::kHardwareAccelerationModeEnabled); | |
50 } | |
51 | |
OLD | NEW |