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

Side by Side Diff: chrome/browser/ui/ash/palette_delegate_chromeos.cc

Issue 2803403002: Support region selection for voice interaction session (Closed)
Patch Set: Addressed comments 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/palette_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/palette_delegate_chromeos.h"
6 6
7 #include "ash/accelerators/accelerator_controller_delegate_aura.h" 7 #include "ash/accelerators/accelerator_controller_delegate_aura.h"
8 #include "ash/aura/shell_port_classic.h" 8 #include "ash/aura/shell_port_classic.h"
9 #include "ash/screenshot_delegate.h" 9 #include "ash/screenshot_delegate.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/system/palette/palette_utils.h" 11 #include "ash/system/palette/palette_utils.h"
12 #include "ash/utility/screenshot_controller.h" 12 #include "ash/utility/screenshot_controller.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/chromeos/arc/arc_util.h"
16 #include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_fr amework_service.h"
15 #include "chrome/browser/chromeos/note_taking_helper.h" 17 #include "chrome/browser/chromeos/note_taking_helper.h"
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" 18 #include "chrome/browser/chromeos/profiles/profile_helper.h"
17 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_manager.h" 20 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "components/arc/arc_bridge_service.h"
23 #include "components/arc/arc_service_manager.h"
24 #include "components/arc/common/voice_interaction_framework.mojom.h"
20 #include "components/prefs/pref_change_registrar.h" 25 #include "components/prefs/pref_change_registrar.h"
21 #include "components/prefs/pref_service.h" 26 #include "components/prefs/pref_service.h"
22 #include "components/user_manager/user_manager.h" 27 #include "components/user_manager/user_manager.h"
23 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/notification_source.h" 29 #include "content/public/browser/notification_source.h"
25 30
26 namespace chromeos { 31 namespace chromeos {
27 32
33 class VoiceInteractionScreenshotDelegate : public ash::ScreenshotDelegate {
34 public:
35 VoiceInteractionScreenshotDelegate() {}
36 ~VoiceInteractionScreenshotDelegate() override {}
37
38 private:
39 void HandleTakeScreenshotForAllRootWindows() override { NOTIMPLEMENTED(); }
40
41 void HandleTakePartialScreenshot(aura::Window* window,
42 const gfx::Rect& rect) override {
43 arc::mojom::VoiceInteractionFrameworkInstance* framework =
44 ARC_GET_INSTANCE_FOR_METHOD(arc::ArcServiceManager::Get()
45 ->arc_bridge_service()
46 ->voice_interaction_framework(),
47 StartVoiceInteractionSessionForRegion);
48 if (!framework)
49 return;
50 double device_scale_factor = window->layer()->device_scale_factor();
51 framework->StartVoiceInteractionSessionForRegion(
52 gfx::ScaleToEnclosingRect(rect, device_scale_factor));
53 }
54
55 void HandleTakeWindowScreenshot(aura::Window* window) override {
56 NOTIMPLEMENTED();
57 }
58
59 bool CanTakeScreenshot() override { return true; }
60
61 DISALLOW_COPY_AND_ASSIGN(VoiceInteractionScreenshotDelegate);
62 };
63
28 PaletteDelegateChromeOS::PaletteDelegateChromeOS() : weak_factory_(this) { 64 PaletteDelegateChromeOS::PaletteDelegateChromeOS() : weak_factory_(this) {
29 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, 65 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED,
30 content::NotificationService::AllSources()); 66 content::NotificationService::AllSources());
31 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, 67 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
32 content::NotificationService::AllSources()); 68 content::NotificationService::AllSources());
33 } 69 }
34 70
35 PaletteDelegateChromeOS::~PaletteDelegateChromeOS() {} 71 PaletteDelegateChromeOS::~PaletteDelegateChromeOS() {}
36 72
37 std::unique_ptr<PaletteDelegateChromeOS::EnableListenerSubscription> 73 std::unique_ptr<PaletteDelegateChromeOS::EnableListenerSubscription>
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 170
135 void PaletteDelegateChromeOS::TakeScreenshot() { 171 void PaletteDelegateChromeOS::TakeScreenshot() {
136 auto* screenshot_delegate = ash::ShellPortClassic::Get() 172 auto* screenshot_delegate = ash::ShellPortClassic::Get()
137 ->accelerator_controller_delegate() 173 ->accelerator_controller_delegate()
138 ->screenshot_delegate(); 174 ->screenshot_delegate();
139 screenshot_delegate->HandleTakeScreenshotForAllRootWindows(); 175 screenshot_delegate->HandleTakeScreenshotForAllRootWindows();
140 } 176 }
141 177
142 void PaletteDelegateChromeOS::TakePartialScreenshot(const base::Closure& done) { 178 void PaletteDelegateChromeOS::TakePartialScreenshot(const base::Closure& done) {
143 auto* screenshot_controller = ash::Shell::Get()->screenshot_controller(); 179 auto* screenshot_controller = ash::Shell::Get()->screenshot_controller();
144 auto* screenshot_delegate = ash::ShellPortClassic::Get() 180
145 ->accelerator_controller_delegate() 181 ash::ScreenshotDelegate* screenshot_delegate;
146 ->screenshot_delegate(); 182 if (arc::ArcVoiceInteractionFrameworkService::IsVoiceInteractionEnabled() &&
183 arc::IsArcAllowedForProfile(profile_)) {
184 // This is an experimental mode. It will be either taken out or grow
185 // into a separate tool next to "Capture region".
186 if (!voice_interaction_screenshot_delegate_) {
187 voice_interaction_screenshot_delegate_ =
188 base::MakeUnique<VoiceInteractionScreenshotDelegate>();
189 }
190 screenshot_delegate = voice_interaction_screenshot_delegate_.get();
191 } else {
192 screenshot_delegate = ash::ShellPortClassic::Get()
193 ->accelerator_controller_delegate()
194 ->screenshot_delegate();
195 }
147 196
148 screenshot_controller->set_pen_events_only(true); 197 screenshot_controller->set_pen_events_only(true);
149 screenshot_controller->StartPartialScreenshotSession( 198 screenshot_controller->StartPartialScreenshotSession(
150 screenshot_delegate, false /* draw_overlay_immediately */); 199 screenshot_delegate, false /* draw_overlay_immediately */);
151 screenshot_controller->set_on_screenshot_session_done( 200 screenshot_controller->set_on_screenshot_session_done(
152 base::Bind(&PaletteDelegateChromeOS::OnPartialScreenshotDone, 201 base::Bind(&PaletteDelegateChromeOS::OnPartialScreenshotDone,
153 weak_factory_.GetWeakPtr(), done)); 202 weak_factory_.GetWeakPtr(), done));
154 } 203 }
155 204
156 void PaletteDelegateChromeOS::CancelPartialScreenshot() { 205 void PaletteDelegateChromeOS::CancelPartialScreenshot() {
157 ash::Shell::Get()->screenshot_controller()->CancelScreenshotSession(); 206 ash::Shell::Get()->screenshot_controller()->CancelScreenshotSession();
158 } 207 }
159 208
160 } // namespace chromeos 209 } // namespace chromeos
OLDNEW
« 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