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

Side by Side Diff: chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.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
« no previous file with comments | « no previous file | chrome/browser/ui/ash/palette_delegate_chromeos.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/chromeos/arc/voice_interaction/arc_voice_interaction_fr amework_service.h" 5 #include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_fr amework_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/accelerators/accelerator_controller.h" 10 #include "ash/accelerators/accelerator_controller.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 void ArcVoiceInteractionFrameworkService::OnInstanceReady() { 59 void ArcVoiceInteractionFrameworkService::OnInstanceReady() {
60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
61 mojom::VoiceInteractionFrameworkInstance* framework_instance = 61 mojom::VoiceInteractionFrameworkInstance* framework_instance =
62 ARC_GET_INSTANCE_FOR_METHOD( 62 ARC_GET_INSTANCE_FOR_METHOD(
63 arc_bridge_service()->voice_interaction_framework(), Init); 63 arc_bridge_service()->voice_interaction_framework(), Init);
64 DCHECK(framework_instance); 64 DCHECK(framework_instance);
65 framework_instance->Init(binding_.CreateInterfacePtrAndBind()); 65 framework_instance->Init(binding_.CreateInterfacePtrAndBind());
66 66
67 ash::Shell::Get()->accelerator_controller()->Register( 67 ash::Shell::Get()->accelerator_controller()->Register(
68 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN)}, this); 68 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN)}, this);
69 // Temporary shortcut added to enable the metalayer experiment.
70 ash::Shell::Get()->accelerator_controller()->Register(
71 {ui::Accelerator(ui::VKEY_A, ui::EF_COMMAND_DOWN | ui::EF_SHIFT_DOWN)},
72 this);
69 } 73 }
70 74
71 void ArcVoiceInteractionFrameworkService::OnInstanceClosed() { 75 void ArcVoiceInteractionFrameworkService::OnInstanceClosed() {
72 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 76 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
73 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this); 77 ash::Shell::Get()->accelerator_controller()->UnregisterAll(this);
74 } 78 }
75 79
76 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed( 80 bool ArcVoiceInteractionFrameworkService::AcceleratorPressed(
77 const ui::Accelerator& accelerator) { 81 const ui::Accelerator& accelerator) {
78 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 82 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
79 mojom::VoiceInteractionFrameworkInstance* framework_instance = 83
80 ARC_GET_INSTANCE_FOR_METHOD( 84 if (accelerator.IsShiftDown()) {
81 arc_bridge_service()->voice_interaction_framework(), 85 mojom::VoiceInteractionFrameworkInstance* framework_instance =
82 StartVoiceInteractionSession); 86 ARC_GET_INSTANCE_FOR_METHOD(
83 DCHECK(framework_instance); 87 arc_bridge_service()->voice_interaction_framework(),
84 framework_instance->StartVoiceInteractionSession(); 88 ToggleMetalayer);
89 DCHECK(framework_instance);
90 framework_instance->ToggleMetalayer();
91 } else {
92 mojom::VoiceInteractionFrameworkInstance* framework_instance =
93 ARC_GET_INSTANCE_FOR_METHOD(
94 arc_bridge_service()->voice_interaction_framework(),
95 StartVoiceInteractionSession);
96 DCHECK(framework_instance);
97 framework_instance->StartVoiceInteractionSession();
98 }
99
85 return true; 100 return true;
86 } 101 }
87 102
88 bool ArcVoiceInteractionFrameworkService::CanHandleAccelerators() const { 103 bool ArcVoiceInteractionFrameworkService::CanHandleAccelerators() const {
89 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 104 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
90 return true; 105 return true;
91 } 106 }
92 107
93 void ArcVoiceInteractionFrameworkService::CaptureFocusedWindow( 108 void ArcVoiceInteractionFrameworkService::CaptureFocusedWindow(
94 const CaptureFocusedWindowCallback& callback) { 109 const CaptureFocusedWindowCallback& callback) {
95 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
96 aura::Window* window = 111 aura::Window* window =
97 ash::Shell::Get()->activation_client()->GetActiveWindow(); 112 ash::Shell::Get()->activation_client()->GetActiveWindow();
98 113
99 if (window == nullptr) { 114 if (window == nullptr) {
100 callback.Run(std::vector<uint8_t>{}); 115 callback.Run(std::vector<uint8_t>{});
101 return; 116 return;
102 } 117 }
103 ui::GrabWindowSnapshotAsyncPNG(window, gfx::Rect(window->bounds().size()), 118 ui::GrabWindowSnapshotAsyncPNG(window, gfx::Rect(window->bounds().size()),
104 base::CreateTaskRunnerWithTraits( 119 base::CreateTaskRunnerWithTraits(
105 base::TaskTraits().MayBlock().WithPriority( 120 base::TaskTraits().MayBlock().WithPriority(
106 base::TaskPriority::USER_BLOCKING)), 121 base::TaskPriority::USER_BLOCKING)),
107 base::Bind(&ScreenshotCallback, callback)); 122 base::Bind(&ScreenshotCallback, callback));
108 } 123 }
109 124
110 } // namespace arc 125 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/ash/palette_delegate_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698