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

Unified Diff: chrome/browser/ui/ash/palette_delegate_chromeos.cc

Issue 2803403002: Support region selection for voice interaction session (Closed)
Patch Set: Removed 'auto' Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/palette_delegate_chromeos.cc
diff --git a/chrome/browser/ui/ash/palette_delegate_chromeos.cc b/chrome/browser/ui/ash/palette_delegate_chromeos.cc
index cbecd0cfcf55db1adef5abd6c1ee9f267c79adb6..501e4ac32f65f320c03f8f432eb3d9a168cb2ab5 100644
--- a/chrome/browser/ui/ash/palette_delegate_chromeos.cc
+++ b/chrome/browser/ui/ash/palette_delegate_chromeos.cc
@@ -10,13 +10,19 @@
#include "ash/shell.h"
#include "ash/system/palette/palette_utils.h"
#include "ash/utility/screenshot_controller.h"
+#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/note_taking_helper.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/pref_names.h"
+#include "chromeos/chromeos_switches.h"
+#include "components/arc/arc_bridge_service.h"
+#include "components/arc/arc_service_manager.h"
+#include "components/arc/common/voice_interaction_framework.mojom.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_service.h"
#include "components/user_manager/user_manager.h"
@@ -25,6 +31,39 @@
namespace chromeos {
+class VoiceInteractionScreenshotDelegate : public ash::ScreenshotDelegate {
+ public:
+ explicit VoiceInteractionScreenshotDelegate(Profile* profile)
+ : profile_(profile) {}
+
+ private:
+ Profile* profile_;
Luis Héctor Chávez 2017/04/11 16:11:16 nit: Profile* const profile_;
Vladislav Kaznacheev 2017/04/11 18:59:33 Removed as unused.
+
+ void HandleTakeScreenshotForAllRootWindows() override { NOTIMPLEMENTED(); }
+
+ void HandleTakePartialScreenshot(aura::Window* window,
+ const gfx::Rect& rect) override {
+ arc::mojom::VoiceInteractionFrameworkInstance* framework =
+ ARC_GET_INSTANCE_FOR_METHOD(arc::ArcServiceManager::Get()
+ ->arc_bridge_service()
+ ->voice_interaction_framework(),
+ StartVoiceInteractionSessionForRegion);
+ if (!framework) {
+ LOG(ERROR) << "Cannot connect to ARC";
dcheng 2017/04/11 07:39:47 Nit: please use DLOG
Luis Héctor Chávez 2017/04/11 16:11:16 You can also remove this logging completely: ARC_G
Vladislav Kaznacheev 2017/04/11 18:59:33 Acknowledged.
Vladislav Kaznacheev 2017/04/11 18:59:33 Done.
+ return;
+ }
+ double device_scale_factor = window->layer()->device_scale_factor();
+ framework->StartVoiceInteractionSessionForRegion(
+ gfx::ScaleToEnclosingRect(rect, device_scale_factor));
+ }
+
+ void HandleTakeWindowScreenshot(aura::Window* window) override {
+ NOTIMPLEMENTED();
+ }
+
+ bool CanTakeScreenshot() override { return true; }
+};
+
PaletteDelegateChromeOS::PaletteDelegateChromeOS() : weak_factory_(this) {
registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED,
content::NotificationService::AllSources());
@@ -141,9 +180,21 @@ void PaletteDelegateChromeOS::TakeScreenshot() {
void PaletteDelegateChromeOS::TakePartialScreenshot(const base::Closure& done) {
auto* screenshot_controller = ash::Shell::Get()->screenshot_controller();
- auto* screenshot_delegate = ash::WmShellAura::Get()
- ->accelerator_controller_delegate()
- ->screenshot_delegate();
+
+ ash::ScreenshotDelegate* screenshot_delegate;
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ chromeos::switches::kEnableVoiceInteraction) &&
Luis Héctor Chávez 2017/04/11 16:11:16 nit: ArcVoiceInteractionFrameworkService::IsVoiceI
Vladislav Kaznacheev 2017/04/11 18:59:33 Done.
+ arc::IsArcAllowedForProfile(profile_)) {
+ if (!voice_interaction_screenshot_delegate_) {
+ voice_interaction_screenshot_delegate_ =
+ base::MakeUnique<VoiceInteractionScreenshotDelegate>(profile_);
+ }
+ screenshot_delegate = voice_interaction_screenshot_delegate_.get();
+ } else {
+ screenshot_delegate = ash::WmShellAura::Get()
+ ->accelerator_controller_delegate()
+ ->screenshot_delegate();
+ }
screenshot_controller->set_pen_events_only(true);
screenshot_controller->StartPartialScreenshotSession(

Powered by Google App Engine
This is Rietveld 408576698