1 // Copyright 2019 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 "ui/base/cursor/cursor_theme_manager.h" 6 7 #include "base/check.h" 8 #include "base/check_op.h" 9 10 namespace ui { 11 12 namespace { 13 14 CursorThemeManager* g_instance = nullptr; 15 16 } 17 ~CursorThemeManager()18CursorThemeManager::~CursorThemeManager() { 19 DCHECK_EQ(g_instance, this); 20 g_instance = nullptr; 21 } 22 23 // static GetInstance()24CursorThemeManager* CursorThemeManager::GetInstance() { 25 return g_instance; 26 } 27 AddObserver(CursorThemeManagerObserver * observer)28void CursorThemeManager::AddObserver(CursorThemeManagerObserver* observer) { 29 cursor_theme_observers_.AddObserver(observer); 30 std::string name = GetCursorThemeName(); 31 if (!name.empty()) 32 observer->OnCursorThemeNameChanged(name); 33 int size = GetCursorThemeSize(); 34 if (size) 35 observer->OnCursorThemeSizeChanged(size); 36 } 37 RemoveObserver(CursorThemeManagerObserver * observer)38void CursorThemeManager::RemoveObserver(CursorThemeManagerObserver* observer) { 39 cursor_theme_observers_.RemoveObserver(observer); 40 } 41 CursorThemeManager()42CursorThemeManager::CursorThemeManager() { 43 DCHECK(!g_instance); 44 g_instance = this; 45 } 46 47 } // namespace ui 48