OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/common/extensions/api/system_display.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/linked_ptr.h" |
12 | 13 |
13 namespace gfx { | 14 namespace gfx { |
14 class Display; | 15 class Display; |
15 } | 16 } |
16 | 17 |
17 namespace extensions { | 18 namespace extensions { |
18 | 19 |
19 typedef std::vector<linked_ptr< | 20 namespace api { |
20 api::system_display::DisplayUnitInfo> > DisplayInfo; | 21 namespace system_display { |
| 22 struct DisplayProperties; |
| 23 struct DisplayUnitInfo; |
| 24 } |
| 25 } |
| 26 |
| 27 typedef std::vector<linked_ptr<api::system_display::DisplayUnitInfo> > |
| 28 DisplayInfo; |
21 | 29 |
22 class DisplayInfoProvider { | 30 class DisplayInfoProvider { |
23 public : | 31 public: |
| 32 virtual ~DisplayInfoProvider(); |
| 33 |
| 34 // Returns a pointer to DisplayInfoProvider or NULL if Create() |
| 35 // or InitializeForTesting() or not called yet. |
24 static DisplayInfoProvider* Get(); | 36 static DisplayInfoProvider* Get(); |
25 | 37 |
26 DisplayInfoProvider(); | |
27 virtual ~DisplayInfoProvider(); | |
28 | |
29 // This is for tests that run in its own process (e.g. browser_tests). | 38 // This is for tests that run in its own process (e.g. browser_tests). |
30 // Using this in other tests (e.g. unit_tests) will result in DCHECK failure. | 39 // Using this in other tests (e.g. unit_tests) will result in DCHECK failure. |
31 static void InitializeForTesting(DisplayInfoProvider* display_info_provider); | 40 static void InitializeForTesting(DisplayInfoProvider* display_info_provider); |
32 | 41 |
| 42 // Updates the display with |display_id| according to |info|. Returns whether |
| 43 // the display was successfully updated. On failure, no display parameters |
| 44 // should be changed, and |error| should be set to the error string. |
| 45 virtual bool SetInfo(const std::string& display_id, |
| 46 const api::system_display::DisplayProperties& info, |
| 47 std::string* error) = 0; |
| 48 |
33 DisplayInfo GetAllDisplaysInfo(); | 49 DisplayInfo GetAllDisplaysInfo(); |
34 | 50 |
35 virtual bool SetInfo(const std::string& display_id, | 51 protected: |
36 const api::system_display::DisplayProperties& info, | 52 DisplayInfoProvider(); |
37 std::string* error); | |
38 | 53 |
39 private: | 54 private: |
| 55 static DisplayInfoProvider* Create(); |
| 56 |
40 // Update the content of the |unit| obtained for |display| using | 57 // Update the content of the |unit| obtained for |display| using |
41 // platform specific method. | 58 // platform specific method. |
42 virtual void UpdateDisplayUnitInfoForPlatform( | 59 virtual void UpdateDisplayUnitInfoForPlatform( |
43 const gfx::Display& display, | 60 const gfx::Display& display, |
44 extensions::api::system_display::DisplayUnitInfo* unit); | 61 api::system_display::DisplayUnitInfo* unit) = 0; |
45 | 62 |
46 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider); | 63 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider); |
47 }; | 64 }; |
48 | 65 |
49 } // namespace extensions | 66 } // namespace extensions |
50 | 67 |
51 #endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ | 68 #endif // CHROME_BROWSER_EXTENSIONS_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_ |
OLD | NEW |