Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / renderer_host / pepper / monitor_finder_mac.h
blobea25a5345aefdc8b945ca71da222bd422e4d86c4
1 // Copyright 2014 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 CHROME_BROWSER_RENDERER_HOST_PEPPER_MONITOR_FINDER_MAC_H_
6 #define CHROME_BROWSER_RENDERER_HOST_PEPPER_MONITOR_FINDER_MAC_H_
8 #include <ApplicationServices/ApplicationServices.h>
10 #include "base/memory/ref_counted.h"
11 #include "base/synchronization/lock.h"
13 namespace chrome {
15 // MonitorFinder maps a RenderFrameHost to the display ID on which the widget
16 // is painting. This class operates on the IO thread while the RenderFrameHost
17 // is on the UI thread, so the value returned by GetMonitor() may be 0 until
18 // the information can be retrieved asynchronously.
19 class MonitorFinder : public base::RefCountedThreadSafe<MonitorFinder> {
20 public:
21 MonitorFinder(int process_id, int render_frame_id);
23 // Gets the native display ID for the <process_id, render_frame_id> tuple.
24 int64_t GetMonitor();
26 // Checks if the given |monitor_id| represents a built-in display.
27 static bool IsMonitorBuiltIn(int64_t monitor_id);
29 private:
30 friend class base::RefCountedThreadSafe<MonitorFinder>;
31 ~MonitorFinder();
33 // Method run on the UI thread to get the display information.
34 void FetchMonitorFromWidget();
36 const int process_id_;
37 const int render_frame_id_;
39 base::Lock mutex_; // Protects the two members below.
40 // Whether one request to FetchMonitorFromWidget() has been made already.
41 bool request_sent_;
42 // The native display ID for the RenderFrameHost.
43 CGDirectDisplayID display_id_;
45 DISALLOW_COPY_AND_ASSIGN(MonitorFinder);
48 } // namespace chrome
50 #endif // CHROME_BROWSER_RENDERER_HOST_PEPPER_MONITOR_FINDER_H_