OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/logging.h" | |
6 #include "ui/gfx/screen.h" | |
7 #include "ui/gfx/screen_type_delegate.h" | |
8 | |
9 namespace { | |
10 | |
11 gfx::Screen* g_screen_[gfx::SCREEN_TYPE_LAST + 1]; | |
12 gfx::ScreenTypeDelegate* g_screen_type_delegate_ = NULL; | |
13 | |
14 } // namespace | |
oshima
2012/10/10 20:08:39
We usually put anonymous namespace nested. That wa
scottmg
2012/10/10 20:52:01
Done.
| |
15 | |
16 namespace gfx { | |
17 | |
18 Screen::Screen() { | |
19 } | |
20 | |
21 Screen::~Screen() { | |
22 } | |
23 | |
24 // static | |
25 Screen* Screen::GetScreenFor(NativeView view) { | |
26 ScreenType type = SCREEN_TYPE_NATIVE; | |
27 if (g_screen_type_delegate_) | |
28 type = g_screen_type_delegate_->GetScreenTypeForNativeView(view); | |
29 if (type == SCREEN_TYPE_NATIVE) | |
30 return GetNativeScreen(); | |
31 DCHECK(g_screen_[type]); | |
32 return g_screen_[type]; | |
33 } | |
34 | |
35 // static | |
36 void Screen::SetScreenInstance(ScreenType type, Screen* instance) { | |
37 DCHECK_LE(type, SCREEN_TYPE_LAST); | |
38 g_screen_[type] = instance; | |
39 } | |
40 | |
41 // static | |
42 void Screen::SetScreenTypeDelegate(ScreenTypeDelegate* delegate) { | |
43 g_screen_type_delegate_ = delegate; | |
44 } | |
45 | |
46 // static | |
47 Screen* Screen::GetNativeScreen() { | |
48 if (!g_screen_[SCREEN_TYPE_NATIVE]) | |
49 g_screen_[SCREEN_TYPE_NATIVE] = CreateNativeScreen(); | |
50 return g_screen_[SCREEN_TYPE_NATIVE]; | |
51 } | |
52 | |
53 } | |
oshima
2012/10/10 20:08:39
// namespace gfx
scottmg
2012/10/10 20:52:01
Done.
| |
OLD | NEW |