Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / browser / gpu / gl_string_manager.cc
blobf678ecba2c43110d6e97b9dcee2f0cacb570689d
1 // Copyright (c) 2012 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.
5 #include "chrome/browser/gpu/gl_string_manager.h"
7 #include "base/prefs/pref_registry_simple.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/common/pref_names.h"
11 #include "content/public/browser/gpu_data_manager.h"
13 // static
14 void GLStringManager::RegisterPrefs(PrefRegistrySimple* registry) {
15 registry->RegisterStringPref(prefs::kGLVendorString, std::string());
16 registry->RegisterStringPref(prefs::kGLRendererString, std::string());
17 registry->RegisterStringPref(prefs::kGLVersionString, std::string());
20 GLStringManager::GLStringManager() {
23 GLStringManager::~GLStringManager() {
26 void GLStringManager::Initialize() {
27 // On MacOSX or Windows, preliminary GPUInfo is enough.
28 #if defined(OS_LINUX)
29 // We never remove this observer from GpuDataManager.
30 content::GpuDataManager::GetInstance()->AddObserver(this);
32 PrefService* local_state = g_browser_process->local_state();
33 if (!local_state)
34 return;
36 gl_vendor_ = local_state->GetString(prefs::kGLVendorString);
37 gl_renderer_ = local_state->GetString(prefs::kGLRendererString);
38 gl_version_ = local_state->GetString(prefs::kGLVersionString);
40 if (!gl_vendor_.empty() || !gl_renderer_.empty() || !gl_version_.empty()) {
41 content::GpuDataManager::GetInstance()->SetGLStrings(
42 gl_vendor_, gl_renderer_, gl_version_);
44 #endif
47 void GLStringManager::OnGpuInfoUpdate() {
48 std::string gl_vendor, gl_renderer, gl_version;
49 content::GpuDataManager::GetInstance()->GetGLStrings(
50 &gl_vendor, &gl_renderer, &gl_version);
52 PrefService* local_state = g_browser_process->local_state();
53 if (!local_state)
54 return;
56 if (!gl_vendor.empty() && gl_vendor != gl_vendor_) {
57 gl_vendor_ = gl_vendor;
58 local_state->SetString(prefs::kGLVendorString, gl_vendor_);
60 if (!gl_renderer.empty() && gl_renderer != gl_renderer_) {
61 gl_renderer_ = gl_renderer;
62 local_state->SetString(prefs::kGLRendererString, gl_renderer_);
64 if (!gl_version.empty() && gl_version != gl_version_) {
65 gl_version_ = gl_version;
66 local_state->SetString(prefs::kGLVersionString, gl_version_);