Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / extensions / browser / api / webcam_private / webcam.h
blob6aba62d1c3edaf90ee07c7b6bc43a7a0b164d6b4
1 // Copyright 2015 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_WEBCAM_PRIVATE_WEBCAM_H_
6 #define EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_H_
8 #include <set>
9 #include <string>
11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "extensions/browser/api/api_resource.h"
16 namespace extensions {
18 class Webcam : public base::RefCounted<Webcam> {
19 public:
20 enum PanDirection {
21 PAN_LEFT,
22 PAN_RIGHT,
23 PAN_STOP,
26 enum TiltDirection {
27 TILT_UP,
28 TILT_DOWN,
29 TILT_STOP,
32 Webcam();
34 using GetPTZCompleteCallback = base::Callback<void(bool, int)>;
35 using SetPTZCompleteCallback = base::Callback<void(bool)>;
37 virtual void GetPan(const GetPTZCompleteCallback& callback) = 0;
38 virtual void GetTilt(const GetPTZCompleteCallback& callback) = 0;
39 virtual void GetZoom(const GetPTZCompleteCallback& callback) = 0;
40 virtual void SetPan(int value,
41 int pan_speed,
42 const SetPTZCompleteCallback& callback) = 0;
43 virtual void SetTilt(int value,
44 int tilt_speed,
45 const SetPTZCompleteCallback& callback) = 0;
46 virtual void SetZoom(int value, const SetPTZCompleteCallback& callback) = 0;
47 virtual void SetPanDirection(PanDirection direction,
48 int pan_speed,
49 const SetPTZCompleteCallback& callback) = 0;
50 virtual void SetTiltDirection(TiltDirection direction,
51 int tilt_speed,
52 const SetPTZCompleteCallback& callback) = 0;
53 virtual void Reset(bool pan,
54 bool tilt,
55 bool zoom,
56 const SetPTZCompleteCallback& callback) = 0;
58 protected:
59 friend class base::RefCounted<Webcam>;
60 virtual ~Webcam();
62 private:
63 DISALLOW_COPY_AND_ASSIGN(Webcam);
66 class WebcamResource : public ApiResource {
67 public:
68 WebcamResource(const std::string& owner_extension_id,
69 Webcam* webcam,
70 const std::string& webcam_id);
71 ~WebcamResource() override;
73 static const content::BrowserThread::ID kThreadId =
74 content::BrowserThread::UI;
76 Webcam* GetWebcam() const;
77 const std::string GetWebcamId() const;
79 // ApiResource overrides.
80 bool IsPersistent() const override;
82 private:
83 scoped_refptr<Webcam> webcam_;
84 std::string webcam_id_;
86 DISALLOW_COPY_AND_ASSIGN(WebcamResource);
89 } // namespace extensions
91 #endif // EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_H_