OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "ui/gfx/screen.h" | 6 #include "ui/gfx/screen.h" |
7 #include "ui/gfx/screen_type_delegate.h" | 7 #include "ui/gfx/screen_type_delegate.h" |
8 | 8 |
9 namespace gfx { | 9 namespace gfx { |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 type = g_screen_type_delegate_->GetScreenTypeForNativeView(view); | 28 type = g_screen_type_delegate_->GetScreenTypeForNativeView(view); |
29 if (type == SCREEN_TYPE_NATIVE) | 29 if (type == SCREEN_TYPE_NATIVE) |
30 return GetNativeScreen(); | 30 return GetNativeScreen(); |
31 DCHECK(g_screen_[type]); | 31 DCHECK(g_screen_[type]); |
32 return g_screen_[type]; | 32 return g_screen_[type]; |
33 } | 33 } |
34 | 34 |
35 // static | 35 // static |
36 void Screen::SetScreenInstance(ScreenType type, Screen* instance) { | 36 void Screen::SetScreenInstance(ScreenType type, Screen* instance) { |
37 DCHECK_LE(type, SCREEN_TYPE_LAST); | 37 DCHECK_LE(type, SCREEN_TYPE_LAST); |
| 38 DCHECK(!g_screen_[type]); |
38 g_screen_[type] = instance; | 39 g_screen_[type] = instance; |
39 } | 40 } |
40 | 41 |
41 // static | 42 // static |
| 43 Screen* Screen::GetScreenByType(ScreenType type) { |
| 44 DCHECK(g_screen_[type]); |
| 45 return g_screen_[type]; |
| 46 } |
| 47 |
| 48 // static |
42 void Screen::SetScreenTypeDelegate(ScreenTypeDelegate* delegate) { | 49 void Screen::SetScreenTypeDelegate(ScreenTypeDelegate* delegate) { |
43 g_screen_type_delegate_ = delegate; | 50 g_screen_type_delegate_ = delegate; |
44 } | 51 } |
45 | 52 |
46 // static | 53 // static |
47 Screen* Screen::GetNativeScreen() { | 54 Screen* Screen::GetNativeScreen() { |
48 if (!g_screen_[SCREEN_TYPE_NATIVE]) | 55 if (!g_screen_[SCREEN_TYPE_NATIVE]) |
49 g_screen_[SCREEN_TYPE_NATIVE] = CreateNativeScreen(); | 56 g_screen_[SCREEN_TYPE_NATIVE] = CreateNativeScreen(); |
50 return g_screen_[SCREEN_TYPE_NATIVE]; | 57 return g_screen_[SCREEN_TYPE_NATIVE]; |
51 } | 58 } |
52 | 59 |
53 } // namespace gfx | 60 } // namespace gfx |
OLD | NEW |