Roll src/third_party/WebKit a3b4a2e:7441784 (svn 202551:202552)
[chromium-blink-merge.git] / extensions / browser / api / system_display / display_info_provider.h
blob86894c93185e6ccc37f795c8af1bcbed9227d682
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
3 // found in the LICENSE file.
5 #ifndef EXTENSIONS_BROWSER_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_
6 #define EXTENSIONS_BROWSER_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_
8 #include <string>
9 #include <vector>
11 #include "base/macros.h"
12 #include "base/memory/linked_ptr.h"
14 namespace gfx {
15 class Display;
16 class Screen;
19 namespace extensions {
21 namespace api {
22 namespace system_display {
23 struct DisplayProperties;
24 struct DisplayUnitInfo;
28 typedef std::vector<linked_ptr<api::system_display::DisplayUnitInfo>>
29 DisplayInfo;
31 class DisplayInfoProvider {
32 public:
33 virtual ~DisplayInfoProvider();
35 // Returns a pointer to DisplayInfoProvider or NULL if Create()
36 // or InitializeForTesting() or not called yet.
37 static DisplayInfoProvider* Get();
39 // This is for tests that run in its own process (e.g. browser_tests).
40 // Using this in other tests (e.g. unit_tests) will result in DCHECK failure.
41 static void InitializeForTesting(DisplayInfoProvider* display_info_provider);
43 // Updates the display with |display_id| according to |info|. Returns whether
44 // the display was successfully updated. On failure, no display parameters
45 // should be changed, and |error| should be set to the error string.
46 virtual bool SetInfo(const std::string& display_id,
47 const api::system_display::DisplayProperties& info,
48 std::string* error) = 0;
50 // Get the screen that is always active, which will be used for monitoring
51 // display changes events.
52 virtual gfx::Screen* GetActiveScreen() = 0;
54 // Enable the unified desktop feature.
55 virtual void EnableUnifiedDesktop(bool enable);
57 DisplayInfo GetAllDisplaysInfo();
59 protected:
60 DisplayInfoProvider();
62 private:
63 static DisplayInfoProvider* Create();
65 // Update the content of the |unit| obtained for |display| using
66 // platform specific method.
67 virtual void UpdateDisplayUnitInfoForPlatform(
68 const gfx::Display& display,
69 api::system_display::DisplayUnitInfo* unit) = 0;
71 DISALLOW_COPY_AND_ASSIGN(DisplayInfoProvider);
74 } // namespace extensions
76 #endif // EXTENSIONS_BROWSER_API_SYSTEM_DISPLAY_DISPLAY_INFO_PROVIDER_H_