Index: extensions/browser/api/webcam_private/webcam_private_api.h |
diff --git a/extensions/browser/api/webcam_private/webcam_private_api.h b/extensions/browser/api/webcam_private/webcam_private_api.h |
index 3c64e6c89edb24d3d06d2e55de279278bad41d17..bd8a3aa65399a0eaeb08c373f3746949f1357568 100644 |
--- a/extensions/browser/api/webcam_private/webcam_private_api.h |
+++ b/extensions/browser/api/webcam_private/webcam_private_api.h |
@@ -9,6 +9,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/scoped_observer.h" |
+#include "extensions/browser/api/webcam_private/webcam.h" |
#include "extensions/browser/browser_context_keyed_api_factory.h" |
#include "extensions/browser/extension_function.h" |
#include "extensions/browser/process_manager_observer.h" |
@@ -18,10 +19,10 @@ class Profile; |
namespace extensions { |
class ProcessManager; |
-class Webcam; |
class WebcamPrivateAPI : public BrowserContextKeyedAPI, |
- public ProcessManagerObserver { |
+ public ProcessManagerObserver, |
+ public base::SupportsWeakPtr<WebcamPrivateAPI> { |
public: |
static BrowserContextKeyedAPIFactory<WebcamPrivateAPI>* GetFactoryInstance(); |
@@ -34,12 +35,26 @@ class WebcamPrivateAPI : public BrowserContextKeyedAPI, |
Webcam* GetWebcam(const std::string& extension_id, |
const std::string& webcam_id); |
+ bool OpenSerialWebcam( |
+ const std::string& extension_id, |
+ const std::string& device_id, |
+ const base::Callback<void(const std::string&, bool)>& callback); |
+ bool CloseWebcam(const std::string& extension_id, |
+ const std::string& webcam_id); |
+ |
private: |
friend class BrowserContextKeyedAPIFactory<WebcamPrivateAPI>; |
+ void OnOpenSerialWebcam( |
+ const std::string& extension_id, |
+ const std::string& device_id, |
+ const base::Callback<void(const std::string&, bool)>& callback, |
+ bool success); |
bool GetDeviceId(const std::string& extension_id, |
const std::string& webcam_id, |
std::string* device_id); |
+ std::string GetWebcamId(const std::string& extension_id, |
+ const std::string& device_id); |
// ProcessManagerObserver: |
void OnBackgroundHostClose(const std::string& extension_id) override; |
@@ -56,14 +71,46 @@ class WebcamPrivateAPI : public BrowserContextKeyedAPI, |
process_manager_observer_; |
std::map<std::string, linked_ptr<Webcam>> webcams_; |
- |
- base::WeakPtrFactory<WebcamPrivateAPI> weak_ptr_factory_; |
}; |
template <> |
void BrowserContextKeyedAPIFactory<WebcamPrivateAPI> |
::DeclareFactoryDependencies(); |
+class WebcamPrivateOpenSerialWebcamFunction : public AsyncExtensionFunction { |
+ public: |
+ WebcamPrivateOpenSerialWebcamFunction(); |
+ DECLARE_EXTENSION_FUNCTION("webcamPrivate.openSerialWebcam", |
+ WEBCAMPRIVATE_OPENSERIALWEBCAM); |
+ |
+ protected: |
+ ~WebcamPrivateOpenSerialWebcamFunction() override; |
+ |
+ // AsyncExtensionFunction: |
+ bool RunAsync() override; |
+ |
+ private: |
+ void OnOpenWebcam(const std::string& webcam_id, bool success); |
+ |
+ DISALLOW_COPY_AND_ASSIGN(WebcamPrivateOpenSerialWebcamFunction); |
+}; |
+ |
+class WebcamPrivateCloseWebcamFunction : public AsyncExtensionFunction { |
+ public: |
+ WebcamPrivateCloseWebcamFunction(); |
+ DECLARE_EXTENSION_FUNCTION("webcamPrivate.closeWebcam", |
+ WEBCAMPRIVATE_CLOSEWEBCAM); |
+ |
+ protected: |
+ ~WebcamPrivateCloseWebcamFunction() override; |
+ |
+ // AsyncApiFunction: |
+ bool RunAsync() override; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(WebcamPrivateCloseWebcamFunction); |
+}; |
+ |
class WebcamPrivateSetFunction : public SyncExtensionFunction { |
public: |
WebcamPrivateSetFunction(); |