Commit 8176c135 authored by Wei Lee's avatar Wei Lee Committed by Commit Bot

Adds IsTabletMode() in CCA mojo API

This CL adds IsTabletMode() so that CCA could handle different behaviors
under clamshell/tablet mode accordingly. In addition, this CL also moves
CameraAppHelperImpl into components/chromeos_camera since it has nothing
to do with video capture logic.

Bug: b:140273786
Test: Manually tested and CCA works expectedly
Change-Id: Ief04ea06ec93584d9140e9fa4e385f300e3f4419
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787485Reviewed-by: default avatarShik Chen <shik@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarColin Blundell <blundell@chromium.org>
Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Wei Lee <wtlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697910}
parent 9e59abcb
......@@ -51,6 +51,7 @@ include_rules = [
"+components/certificate_transparency",
"+components/chrome_cleaner/public",
"+components/chrome_cleaner/test",
"+components/chromeos_camera",
"+components/cloud_devices/common",
"+components/component_updater",
"+components/consent_auditor",
......
......@@ -993,6 +993,7 @@ jumbo_static_library("extensions") {
"//chromeos/system",
"//chromeos/tpm",
"//components/arc",
"//components/chromeos_camera:camera_app_helper",
"//components/constrained_window",
"//components/drive",
"//components/user_manager",
......
......@@ -30,13 +30,13 @@
#include "chromeos/services/ime/public/mojom/input_engine.mojom.h"
#include "chromeos/services/media_perception/public/mojom/media_perception.mojom.h"
#include "components/arc/intent_helper/arc_intent_helper_bridge.h"
#include "components/chromeos_camera/camera_app_helper_impl.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/media_device_id.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/media_perception_private/media_perception_api_delegate.h"
#include "media/capture/video/chromeos/camera_app_device_provider_impl.h"
#include "media/capture/video/chromeos/camera_app_helper_impl.h"
#include "media/capture/video/chromeos/mojom/camera_app.mojom.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
......@@ -120,7 +120,8 @@ void ConnectToCameraAppHelper(cros::mojom::CameraAppHelperRequest request,
auto intent_callback = base::BindRepeating(
&TriggerCameraIntent, source->GetProcess()->GetBrowserContext());
auto camera_app_helper =
std::make_unique<media::CameraAppHelperImpl>(std::move(intent_callback));
std::make_unique<chromeos_camera::CameraAppHelperImpl>(
std::move(intent_callback));
mojo::MakeStrongBinding(std::move(camera_app_helper), std::move(request));
}
#endif
......
......@@ -169,6 +169,7 @@ copy("chrome_camera_app_js_models") {
copy("chrome_camera_app_js_mojo") {
sources = [
"src/js/mojo/chrome_helper.js",
"src/js/mojo/device_operator.js",
"src/js/mojo/image_capture.js",
]
......
......@@ -130,6 +130,7 @@ RESOURCES = \
src/js/models/gallery.js \
src/js/models/result_saver.js \
src/js/models/video_saver.js \
src/js/mojo/chrome_helper.js \
src/js/mojo/device_operator.js \
src/js/mojo/image_capture.js \
src/js/nav.js \
......
......@@ -18,6 +18,7 @@
<structure name="IDR_CAMERA_CAMERA3_DEVICE_INFO_JS" file="src/js/device/camera3_device_info.js" type="chrome_html" />
<structure name="IDR_CAMERA_CAMERA_JS" file="src/js/views/camera.js" type="chrome_html" />
<structure name="IDR_CAMERA_CONSTRAINTS_PREFERRER_JS" file="src/js/device/constraints_preferrer.js" type="chrome_html" />
<structure name="IDR_CAMERA_CHROME_HELPER_JS" file="src/js/mojo/chrome_helper.js" type="chrome_html" />
<structure name="IDR_CAMERA_DEVICE_OPERATOR_JS" file="src/js/mojo/device_operator.js" type="chrome_html" />
<structure name="IDR_CAMERA_DEVICE_INFO_UPDATER_JS" file="src/js/device/device_info_updater.js" type="chrome_html" />
<structure name="IDR_CAMERA_DIALOG_JS" file="src/js/views/dialog.js" type="chrome_html" />
......
......@@ -6,11 +6,19 @@ import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") {
deps = [
":chrome_helper",
":device_operator",
":image_capture",
]
}
js_library("chrome_helper") {
deps = [
"//media/capture/video/chromeos/mojom:cros_camera_js_library_for_compile",
]
externs_list = [ "$externs_path/pending.js" ]
}
js_library("device_operator") {
deps = [
"//media/capture/video/chromeos/mojom:cros_camera_js_library_for_compile",
......
// Copyright 2019 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.
'use strict';
/**
* Namespace for the Camera app.
*/
var cca = cca || {};
/**
* Namespace for mojo.
*/
cca.mojo = cca.mojo || {};
/**
* Communicates with Chrome.
*/
cca.mojo.ChromeHelper = class {
/**
* @public
*/
constructor() {
/**
* An interface remote that is used to communicate with Chrome.
* @type {cros.mojom.CameraAppHelperRemote}
*/
this.remote_ = cros.mojom.CameraAppHelper.getRemote();
}
/**
* Checks if the device is under tablet mode currently.
* @return {!Promise<boolean>}
*/
async isTabletMode() {
return await this.remote_.isTabletMode().then(({isTabletMode}) => {
return isTabletMode;
});
}
/**
* Creates a new instance of ChromeHelper if it is not set. Returns the
* exist instance.
* @return {!cca.mojo.ChromeHelper} The singleton instance.
*/
static getInstance() {
if (this.instance === null) {
this.instance = new cca.mojo.ChromeHelper();
}
return this.instance;
}
};
/**
* The singleton instance of ChromeHelper. Initialized by the first
* invocation of getInstance().
* @type {?cca.mojo.ChromeHelper}
*/
cca.mojo.ChromeHelper.instance = null;
......@@ -36,6 +36,7 @@
<script src="../js/mojo/geometry.mojom-lite.js"></script>
<script src="../js/mojo/range.mojom-lite.js"></script>
<script src="../js/mojo/camera_app.mojom-lite.js"></script>
<script src="../js/mojo/chrome_helper.js"></script>
<script src="../js/mojo/device_operator.js"></script>
<script src="../js/mojo/image_capture.js"></script>
<script src="../js/views/view.js"></script>
......
......@@ -195,6 +195,18 @@ if (use_v4l2_codec || use_vaapi) {
}
}
source_set("camera_app_helper") {
sources = [
"camera_app_helper_impl.cc",
"camera_app_helper_impl.h",
]
deps = [
"//ash/public/cpp",
"//media/capture/video/chromeos/mojom:cros_camera",
]
}
test("jpeg_decode_accelerator_unittest") {
deps = [
":mjpeg_decode_accelerator",
......
include_rules = [
"+ash/public/cpp",
"+media",
"+mojo",
"+third_party/libyuv",
......
......@@ -2,9 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/capture/video/chromeos/camera_app_helper_impl.h"
#include "components/chromeos_camera/camera_app_helper_impl.h"
namespace media {
#include "ash/public/cpp/tablet_mode.h"
namespace chromeos_camera {
CameraAppHelperImpl::CameraAppHelperImpl(IntentCallback intent_callback)
: intent_callback_(std::move(intent_callback)) {}
......@@ -18,4 +20,8 @@ void CameraAppHelperImpl::OnIntentHandled(
intent_callback_.Run(intent_id, is_success, captured_data);
}
} // namespace media
\ No newline at end of file
void CameraAppHelperImpl::IsTabletMode(IsTabletModeCallback callback) {
std::move(callback).Run(ash::TabletMode::Get()->InTabletMode());
}
} // namespace chromeos_camera
......@@ -2,19 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_APP_HELPER_IMPL_H_
#define MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_APP_HELPER_IMPL_H_
#ifndef COMPONENTS_CHROMEOS_CAMERA_CAMERA_APP_HELPER_IMPL_H_
#define COMPONENTS_CHROMEOS_CAMERA_CAMERA_APP_HELPER_IMPL_H_
#include <string>
#include <vector>
#include "media/capture/capture_export.h"
#include "media/capture/video/chromeos/mojom/camera_app.mojom.h"
#include "mojo/public/cpp/bindings/binding_set.h"
namespace media {
namespace chromeos_camera {
class CAPTURE_EXPORT CameraAppHelperImpl : public cros::mojom::CameraAppHelper {
class CameraAppHelperImpl : public cros::mojom::CameraAppHelper {
public:
using IntentCallback = base::RepeatingCallback<
void(uint32_t, bool, const std::vector<uint8_t>&)>;
......@@ -26,6 +23,7 @@ class CAPTURE_EXPORT CameraAppHelperImpl : public cros::mojom::CameraAppHelper {
void OnIntentHandled(uint32_t intent_id,
bool is_success,
const std::vector<uint8_t>& captured_data) override;
void IsTabletMode(IsTabletModeCallback callback) override;
private:
IntentCallback intent_callback_;
......@@ -33,6 +31,6 @@ class CAPTURE_EXPORT CameraAppHelperImpl : public cros::mojom::CameraAppHelper {
DISALLOW_COPY_AND_ASSIGN(CameraAppHelperImpl);
};
} // namespace media
} // namespace chromeos_camera
#endif // MEDIA_CAPTURE_VIDEO_CHROMEOS_CAMERA_APP_HELPER_IMPL_H_
\ No newline at end of file
#endif // COMPONENTS_CHROMEOS_CAMERA_CAMERA_APP_HELPER_IMPL_H_
\ No newline at end of file
......@@ -247,8 +247,6 @@ jumbo_component("capture_lib") {
"video/chromeos/camera_app_device_impl.h",
"video/chromeos/camera_app_device_provider_impl.cc",
"video/chromeos/camera_app_device_provider_impl.h",
"video/chromeos/camera_app_helper_impl.cc",
"video/chromeos/camera_app_helper_impl.h",
"video/chromeos/camera_buffer_factory.cc",
"video/chromeos/camera_buffer_factory.h",
"video/chromeos/camera_device_context.cc",
......
......@@ -69,6 +69,9 @@ interface CameraAppHelper {
// as a byte array.
OnIntentHandled(uint32 intent_id, bool is_success,
array<uint8> captured_data);
// Checks if device is under tablet mode currently.
IsTabletMode() => (bool is_tablet_mode);
};
// Inner interface that used to communicate between browser process (Remote) and
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment