Add chrome.webcamPrivate idl

This also adds the stubs for all the functions.

BUG=346492

Review URL: https://codereview.chromium.org/205243005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263287 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/api/webcam_private/webcam_private_api.cc b/chrome/browser/extensions/api/webcam_private/webcam_private_api.cc
new file mode 100644
index 0000000..f956ba4
--- /dev/null
+++ b/chrome/browser/extensions/api/webcam_private/webcam_private_api.cc
@@ -0,0 +1,62 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/webcam_private/webcam_private_api.h"
+
+#include "chrome/common/extensions/api/webcam_private.h"
+
+namespace extensions {
+
+WebcamPrivateSetFunction::WebcamPrivateSetFunction() {
+}
+
+WebcamPrivateSetFunction::~WebcamPrivateSetFunction() {
+}
+
+bool WebcamPrivateSetFunction::RunImpl() {
+  // Get parameters
+  scoped_ptr<api::webcam_private::Set::Params> params(
+      api::webcam_private::Set::Params::Create(*args_));
+  EXTENSION_FUNCTION_VALIDATE(params.get());
+
+  // TODO(zork): Send the value to the webcam.
+
+  return true;
+}
+
+WebcamPrivateGetFunction::WebcamPrivateGetFunction() {
+}
+
+WebcamPrivateGetFunction::~WebcamPrivateGetFunction() {
+}
+
+bool WebcamPrivateGetFunction::RunImpl() {
+  // Get parameters
+  scoped_ptr<api::webcam_private::Get::Params> params(
+      api::webcam_private::Get::Params::Create(*args_));
+  EXTENSION_FUNCTION_VALIDATE(params.get());
+
+  // TODO(zork): Get the value from the webcam.
+
+  return false;
+}
+
+WebcamPrivateResetFunction::WebcamPrivateResetFunction() {
+}
+
+WebcamPrivateResetFunction::~WebcamPrivateResetFunction() {
+}
+
+bool WebcamPrivateResetFunction::RunImpl() {
+  // Get parameters
+  scoped_ptr<api::webcam_private::Reset::Params> params(
+      api::webcam_private::Reset::Params::Create(*args_));
+  EXTENSION_FUNCTION_VALIDATE(params.get());
+
+  // TODO(zork): Reset the webcam state.
+
+  return true;
+}
+
+}  // namespace extensions
diff --git a/chrome/browser/extensions/api/webcam_private/webcam_private_api.h b/chrome/browser/extensions/api/webcam_private/webcam_private_api.h
new file mode 100644
index 0000000..132a211d
--- /dev/null
+++ b/chrome/browser/extensions/api/webcam_private/webcam_private_api.h
@@ -0,0 +1,55 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
+#define CHROME_BROWSER_EXTENSIONS_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
+
+#include "extensions/browser/extension_function.h"
+
+class Profile;
+
+namespace extensions {
+
+class WebcamPrivateSetFunction : public SyncExtensionFunction {
+ public:
+  WebcamPrivateSetFunction();
+  DECLARE_EXTENSION_FUNCTION("webcamPrivate.set", WEBCAMPRIVATE_SET);
+
+ protected:
+  virtual ~WebcamPrivateSetFunction();
+  virtual bool RunImpl() OVERRIDE;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(WebcamPrivateSetFunction);
+};
+
+class WebcamPrivateGetFunction : public SyncExtensionFunction {
+ public:
+  WebcamPrivateGetFunction();
+  DECLARE_EXTENSION_FUNCTION("webcamPrivate.get", WEBCAMPRIVATE_GET);
+
+ protected:
+  virtual ~WebcamPrivateGetFunction();
+  virtual bool RunImpl() OVERRIDE;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(WebcamPrivateGetFunction);
+};
+
+class WebcamPrivateResetFunction : public SyncExtensionFunction {
+ public:
+  WebcamPrivateResetFunction();
+  DECLARE_EXTENSION_FUNCTION("webcamPrivate.reset", WEBCAMPRIVATE_RESET);
+
+ protected:
+  virtual ~WebcamPrivateResetFunction();
+  virtual bool RunImpl() OVERRIDE;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(WebcamPrivateResetFunction);
+};
+
+}  // namespace extensions
+
+#endif  // CHROME_BROWSER_EXTENSIONS_API_WEBCAM_PRIVATE_WEBCAM_PRIVATE_API_H_
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index b03411f..d86fb7e4 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -946,6 +946,8 @@
             'browser/extensions/api/terminal/terminal_extension_helper.h',
             'browser/extensions/api/terminal/terminal_private_api.cc',
             'browser/extensions/api/terminal/terminal_private_api.h',
+            'browser/extensions/api/webcam_private/webcam_private_api.h',
+            'browser/extensions/api/webcam_private/webcam_private_api.cc',
             'browser/extensions/updater/extension_cache_impl.cc',
             'browser/extensions/updater/extension_cache_impl.h',
             'browser/extensions/updater/local_extension_cache.cc',
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
index 4a9b6eb..7e8481a 100644
--- a/chrome/common/extensions/api/_api_features.json
+++ b/chrome/common/extensions/api/_api_features.json
@@ -459,6 +459,10 @@
     "extension_types": ["extension", "legacy_packaged_app"],
     "contexts": ["blessed_extension"]
   },
+  "webcamPrivate": {
+    "dependencies": ["permission:webcamPrivate"],
+    "contexts": ["blessed_extension"]
+  },
   "management": {
     "dependencies": ["permission:management"],
     "contexts": ["blessed_extension"]
diff --git a/chrome/common/extensions/api/_permission_features.json b/chrome/common/extensions/api/_permission_features.json
index 1c20b10..cc9a5fa 100644
--- a/chrome/common/extensions/api/_permission_features.json
+++ b/chrome/common/extensions/api/_permission_features.json
@@ -530,6 +530,10 @@
     "extension_types": ["extension", "legacy_packaged_app"],
     "location": "component"
   },
+  "webcamPrivate": {
+    "channel": "dev",
+    "extension_types": ["extension", "platform_app"]
+  },
   "management": [
     {
       "channel": "stable",
diff --git a/chrome/common/extensions/api/api.gyp b/chrome/common/extensions/api/api.gyp
index 5b9e368..13a1bb5 100644
--- a/chrome/common/extensions/api/api.gyp
+++ b/chrome/common/extensions/api/api.gyp
@@ -164,6 +164,7 @@
               'screenlock_private.idl',
               'wallpaper.json',
               'wallpaper_private.json',
+              'webcam_private.idl',
             ],
           }],
           ['enable_webrtc==1', {
diff --git a/chrome/common/extensions/api/webcam_private.idl b/chrome/common/extensions/api/webcam_private.idl
new file mode 100644
index 0000000..60811c03
--- /dev/null
+++ b/chrome/common/extensions/api/webcam_private.idl
@@ -0,0 +1,23 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Webcam Private API.
+namespace webcamPrivate {
+  dictionary WebcamConfiguration {
+    double? pan;
+    double? zoom;
+    double? tilt;
+  };
+
+  callback WebcamConfigurationCallback =
+      void(WebcamConfiguration configuration);
+
+  interface Functions {
+    static void get(DOMString webcamId, WebcamConfigurationCallback callback);
+    static void set(DOMString webcamId, WebcamConfiguration config);
+    static void reset(DOMString webcamId, WebcamConfiguration config);
+
+  };
+};
+
diff --git a/chrome/common/extensions/permissions/chrome_api_permissions.cc b/chrome/common/extensions/permissions/chrome_api_permissions.cc
index 7473029..9711087 100644
--- a/chrome/common/extensions/permissions/chrome_api_permissions.cc
+++ b/chrome/common/extensions/permissions/chrome_api_permissions.cc
@@ -208,6 +208,7 @@
         {APIPermission::kIdentityPrivate, "identityPrivate",
          APIPermissionInfo::kFlagCannotBeOptional},
         {APIPermission::kLogPrivate, "logPrivate"},
+        {APIPermission::kWebcamPrivate, "webcamPrivate"},
         {APIPermission::kNetworkingPrivate, "networkingPrivate",
          APIPermissionInfo::kFlagCannotBeOptional,
          IDS_EXTENSION_PROMPT_WARNING_NETWORKING_PRIVATE,
diff --git a/chrome/common/extensions/permissions/permission_set_unittest.cc b/chrome/common/extensions/permissions/permission_set_unittest.cc
index 4bf2c043..460ef03 100644
--- a/chrome/common/extensions/permissions/permission_set_unittest.cc
+++ b/chrome/common/extensions/permissions/permission_set_unittest.cc
@@ -670,6 +670,7 @@
   skip.insert(APIPermission::kSystemStorage);
   skip.insert(APIPermission::kTts);
   skip.insert(APIPermission::kUnlimitedStorage);
+  skip.insert(APIPermission::kWebcamPrivate);
   skip.insert(APIPermission::kWebView);
   skip.insert(APIPermission::kWindowShape);
 
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h
index 8a4f621e5..7397ef1 100644
--- a/extensions/browser/extension_function_histogram_value.h
+++ b/extensions/browser/extension_function_histogram_value.h
@@ -778,6 +778,9 @@
   FILESYSTEMPROVIDERINTERNAL_UNMOUNTREQUESTEDSUCCESS,
   FILESYSTEMPROVIDERINTERNAL_UNMOUNTREQUESTEDERROR,
   MEDIAGALLERIES_DROPPERMISSIONFORMEDIAFILESYSTEM,
+  WEBCAMPRIVATE_SET,
+  WEBCAMPRIVATE_RESET,
+  WEBCAMPRIVATE_GET,
   // Last entry: Add new entries above and ensure to update
   // tools/metrics/histograms/histograms/histograms.xml.
   ENUM_BOUNDARY
diff --git a/extensions/common/permissions/api_permission.h b/extensions/common/permissions/api_permission.h
index a8eb0db..64bdf3c 100644
--- a/extensions/common/permissions/api_permission.h
+++ b/extensions/common/permissions/api_permission.h
@@ -158,6 +158,7 @@
     kVirtualKeyboardPrivate,
     kWallpaper,
     kWallpaperPrivate,
+    kWebcamPrivate,
     kWebConnectable,  // for externally_connectable manifest key
     kWebNavigation,
     kWebRequest,
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 88f5b659..b4cd4796 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -33281,6 +33281,9 @@
   <int value="717" label="FILESYSTEMPROVIDERINTERNAL_UNMOUNTREQUESTEDSUCCESS"/>
   <int value="718" label="FILESYSTEMPROVIDERINTERNAL_UNMOUNTREQUESTEDERROR"/>
   <int value="719" label="MEDIAGALLERIES_DROPPERMISSIONFORMEDIAFILESYSTEM"/>
+  <int value="720" label="WEBCAMPRIVATE_SET"/>
+  <int value="721" label="WEBCAMPRIVATE_RESET"/>
+  <int value="722" label="WEBCAMPRIVATE_GET"/>
 </enum>
 
 <enum name="ExtensionInstallCause" type="int">