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

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

Issue 2803403002: Support region selection for voice interaction session (Closed)
Patch Set: 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 5d8c7713467206867bfdf4343035205a2d1db9bd..1e069ff25a417c8448809adb691686c45515f971 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/screenshot_delegate.h"
#include "ash/shell.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_;
+
+ void HandleTakeScreenshotForAllRootWindows() override { NOTIMPLEMENTED(); }
+
+ void HandleTakePartialScreenshot(aura::Window* window,
+ const gfx::Rect& rect) override {
+ auto framework =
xc 2017/04/10 17:53:45 I was asked to use concrete type instead of auto i
+ ARC_GET_INSTANCE_FOR_METHOD(arc::ArcServiceManager::Get()
+ ->arc_bridge_service()
+ ->voice_interaction_framework(),
+ StartVoiceInteractionSessionForRegion);
+ if (!framework) {
+ LOG(ERROR) << "Cannot connect to ARC";
+ 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) &&
+ 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(
« no previous file with comments | « chrome/browser/ui/ash/palette_delegate_chromeos.h ('k') | components/arc/common/voice_interaction_framework.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698