Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: extensions/browser/api/webcam_private/webcam_private_api.h

Issue 1144423004: Add support for PTZ via VISCA. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor cleanup. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
6 #define EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_ 6 #define EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/scoped_observer.h" 11 #include "base/scoped_observer.h"
12 #include "extensions/browser/api/webcam_private/webcam.h"
12 #include "extensions/browser/browser_context_keyed_api_factory.h" 13 #include "extensions/browser/browser_context_keyed_api_factory.h"
13 #include "extensions/browser/extension_function.h" 14 #include "extensions/browser/extension_function.h"
14 #include "extensions/browser/process_manager_observer.h" 15 #include "extensions/browser/process_manager_observer.h"
15 16
16 class Profile; 17 class Profile;
17 18
18 namespace extensions { 19 namespace extensions {
19 20
20 class ProcessManager; 21 class ProcessManager;
21 class Webcam;
22 22
23 class WebcamPrivateAPI : public BrowserContextKeyedAPI, 23 class WebcamPrivateAPI : public BrowserContextKeyedAPI,
24 public ProcessManagerObserver { 24 public ProcessManagerObserver,
25 public base::SupportsWeakPtr<WebcamPrivateAPI> {
25 public: 26 public:
26 static BrowserContextKeyedAPIFactory<WebcamPrivateAPI>* GetFactoryInstance(); 27 static BrowserContextKeyedAPIFactory<WebcamPrivateAPI>* GetFactoryInstance();
27 28
28 // Convenience method to get the WebcamPrivateAPI for a BrowserContext. 29 // Convenience method to get the WebcamPrivateAPI for a BrowserContext.
29 static WebcamPrivateAPI* Get(content::BrowserContext* context); 30 static WebcamPrivateAPI* Get(content::BrowserContext* context);
30 31
31 explicit WebcamPrivateAPI(content::BrowserContext* context); 32 explicit WebcamPrivateAPI(content::BrowserContext* context);
32 ~WebcamPrivateAPI() override; 33 ~WebcamPrivateAPI() override;
33 34
34 Webcam* GetWebcam(const std::string& extension_id, 35 Webcam* GetWebcam(const std::string& extension_id,
35 const std::string& webcam_id); 36 const std::string& webcam_id);
36 37
38 bool OpenSerialWebcam(
39 const std::string& extension_id,
40 const std::string& device_id,
41 const base::Callback<void(const std::string&, bool)>& callback);
42 bool CloseWebcam(const std::string& extension_id,
43 const std::string& webcam_id);
44
37 private: 45 private:
38 friend class BrowserContextKeyedAPIFactory<WebcamPrivateAPI>; 46 friend class BrowserContextKeyedAPIFactory<WebcamPrivateAPI>;
39 47
48 void OnOpenSerialWebcam(
49 const std::string& extension_id,
50 const std::string& device_id,
51 const base::Callback<void(const std::string&, bool)>& callback,
52 bool success);
40 bool GetDeviceId(const std::string& extension_id, 53 bool GetDeviceId(const std::string& extension_id,
41 const std::string& webcam_id, 54 const std::string& webcam_id,
42 std::string* device_id); 55 std::string* device_id);
56 std::string GetWebcamId(const std::string& extension_id,
57 const std::string& device_id);
43 58
44 // ProcessManagerObserver: 59 // ProcessManagerObserver:
45 void OnBackgroundHostClose(const std::string& extension_id) override; 60 void OnBackgroundHostClose(const std::string& extension_id) override;
46 61
47 // BrowserContextKeyedAPI: 62 // BrowserContextKeyedAPI:
48 static const char* service_name() { 63 static const char* service_name() {
49 return "WebcamPrivateAPI"; 64 return "WebcamPrivateAPI";
50 } 65 }
51 static const bool kServiceIsNULLWhileTesting = true; 66 static const bool kServiceIsNULLWhileTesting = true;
52 static const bool kServiceRedirectedInIncognito = true; 67 static const bool kServiceRedirectedInIncognito = true;
53 68
54 content::BrowserContext* const browser_context_; 69 content::BrowserContext* const browser_context_;
55 ScopedObserver<ProcessManager, ProcessManagerObserver> 70 ScopedObserver<ProcessManager, ProcessManagerObserver>
56 process_manager_observer_; 71 process_manager_observer_;
57 72
58 std::map<std::string, linked_ptr<Webcam>> webcams_; 73 std::map<std::string, linked_ptr<Webcam>> webcams_;
59
60 base::WeakPtrFactory<WebcamPrivateAPI> weak_ptr_factory_;
61 }; 74 };
62 75
63 template <> 76 template <>
64 void BrowserContextKeyedAPIFactory<WebcamPrivateAPI> 77 void BrowserContextKeyedAPIFactory<WebcamPrivateAPI>
65 ::DeclareFactoryDependencies(); 78 ::DeclareFactoryDependencies();
66 79
80 class WebcamPrivateOpenSerialWebcamFunction : public AsyncExtensionFunction {
81 public:
82 WebcamPrivateOpenSerialWebcamFunction();
83 DECLARE_EXTENSION_FUNCTION("webcamPrivate.openSerialWebcam",
84 WEBCAMPRIVATE_OPENSERIALWEBCAM);
85
86 protected:
87 ~WebcamPrivateOpenSerialWebcamFunction() override;
88
89 // AsyncExtensionFunction:
90 bool RunAsync() override;
91
92 private:
93 void OnOpenWebcam(const std::string& webcam_id, bool success);
94
95 DISALLOW_COPY_AND_ASSIGN(WebcamPrivateOpenSerialWebcamFunction);
96 };
97
98 class WebcamPrivateCloseWebcamFunction : public AsyncExtensionFunction {
99 public:
100 WebcamPrivateCloseWebcamFunction();
101 DECLARE_EXTENSION_FUNCTION("webcamPrivate.closeWebcam",
102 WEBCAMPRIVATE_CLOSEWEBCAM);
103
104 protected:
105 ~WebcamPrivateCloseWebcamFunction() override;
106
107 // AsyncApiFunction:
108 bool RunAsync() override;
109
110 private:
111 DISALLOW_COPY_AND_ASSIGN(WebcamPrivateCloseWebcamFunction);
112 };
113
67 class WebcamPrivateSetFunction : public SyncExtensionFunction { 114 class WebcamPrivateSetFunction : public SyncExtensionFunction {
68 public: 115 public:
69 WebcamPrivateSetFunction(); 116 WebcamPrivateSetFunction();
70 DECLARE_EXTENSION_FUNCTION("webcamPrivate.set", WEBCAMPRIVATE_SET); 117 DECLARE_EXTENSION_FUNCTION("webcamPrivate.set", WEBCAMPRIVATE_SET);
71 118
72 protected: 119 protected:
73 ~WebcamPrivateSetFunction() override; 120 ~WebcamPrivateSetFunction() override;
74 bool RunSync() override; 121 bool RunSync() override;
75 122
76 private: 123 private:
(...skipping 22 matching lines...) Expand all
99 ~WebcamPrivateResetFunction() override; 146 ~WebcamPrivateResetFunction() override;
100 bool RunSync() override; 147 bool RunSync() override;
101 148
102 private: 149 private:
103 DISALLOW_COPY_AND_ASSIGN(WebcamPrivateResetFunction); 150 DISALLOW_COPY_AND_ASSIGN(WebcamPrivateResetFunction);
104 }; 151 };
105 152
106 } // namespace extensions 153 } // namespace extensions
107 154
108 #endif // EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_ 155 #endif // EXTENSIONS_BROWSER_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698