Commit d8341be3 authored by Muyuan Li's avatar Muyuan Li Committed by Commit Bot

assistant: fix metalayer scale and hook up selection region

Bug: None
Test: Manual
Change-Id: I7a9968bb3b421ef26cc90dd68b063e514e3f4094
Reviewed-on: https://chromium-review.googlesource.com/1147502
Commit-Queue: Muyuan Li <muyuanli@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#577692}
parent b893d71f
...@@ -175,9 +175,8 @@ void AssistantScreenContextController::RequestScreenContext( ...@@ -175,9 +175,8 @@ void AssistantScreenContextController::RequestScreenContext(
assistant_screen_context_model_.SetRequestState( assistant_screen_context_model_.SetRequestState(
ScreenContextRequestState::kInProgress); ScreenContextRequestState::kInProgress);
// Request screen context for the entire screen.
assistant_->RequestScreenContext( assistant_->RequestScreenContext(
gfx::Rect(), rect,
base::BindOnce( base::BindOnce(
&AssistantScreenContextController::OnScreenContextRequestFinished, &AssistantScreenContextController::OnScreenContextRequestFinished,
screen_context_request_factory_.GetWeakPtr())); screen_context_request_factory_.GetWeakPtr()));
......
...@@ -50,9 +50,9 @@ class ASH_EXPORT AssistantScreenContextController ...@@ -50,9 +50,9 @@ class ASH_EXPORT AssistantScreenContextController
void AddModelObserver(AssistantScreenContextModelObserver* observer); void AddModelObserver(AssistantScreenContextModelObserver* observer);
void RemoveModelObserver(AssistantScreenContextModelObserver* observer); void RemoveModelObserver(AssistantScreenContextModelObserver* observer);
// Requests a screenshot for the region defined by |rect|. If an empty rect is // Requests a screenshot for the region defined by |rect| (given in DP). If
// supplied, the entire screen is captured. Upon screenshot completion, the // an empty rect is supplied, the entire screen is captured. Upon screenshot
// specified |callback| is run. // completion, the specified |callback| is run.
void RequestScreenshot( void RequestScreenshot(
const gfx::Rect& rect, const gfx::Rect& rect,
mojom::AssistantController::RequestScreenshotCallback callback); mojom::AssistantController::RequestScreenshotCallback callback);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/system/palette/palette_utils.h" #include "ash/system/palette/palette_utils.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "chromeos/chromeos_switches.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
#include "ui/events/base_event_utils.h" #include "ui/events/base_event_utils.h"
...@@ -222,8 +223,17 @@ void HighlighterController::RecognizeGesture() { ...@@ -222,8 +223,17 @@ void HighlighterController::RecognizeGesture() {
if (!box.IsEmpty() && if (!box.IsEmpty() &&
gesture_type != HighlighterGestureType::kNotRecognized) { gesture_type != HighlighterGestureType::kNotRecognized) {
const gfx::Rect selection_rect = gfx::ToEnclosingRect( // TODO(muyuanli): Delete the check when native assistant is default on.
gfx::ScaleRect(box, GetScreenshotScale(current_window))); // This is a temporary workaround to support both ARC-based assistant
// and native assistant. In ARC-based assistant, we send the rect in pixels
// to ARC side, where the app will crop the screenshot. In native assistant,
// we pass the rect directly to UI snapshot API, which assumes coordinates
// in DP.
const gfx::Rect selection_rect =
chromeos::switches::IsAssistantEnabled()
? gfx::ToEnclosingRect(box)
: gfx::ToEnclosingRect(
gfx::ScaleRect(box, GetScreenshotScale(current_window)));
if (client_) if (client_)
client_->HandleSelection(selection_rect); client_->HandleSelection(selection_rect);
......
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