Commit 49800220 authored by Meilin Wang's avatar Meilin Wang Committed by Commit Bot

Fix Google Assistant settings link navigation.

Fix the navigation of the "Google Assistant settings" link in Chrome OS settings.

Test: local compile and manually test.
Bug: b:112606371
Change-Id: I9bedaa639a0a0e7a3ceb33c999d0528af5c0bd47
Reviewed-on: https://chromium-review.googlesource.com/1183886Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Meilin Wang <meilinw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#585134}
parent 731377a9
......@@ -4,6 +4,9 @@
#include "ash/assistant/assistant_controller.h"
#include <algorithm>
#include <utility>
#include "ash/assistant/assistant_cache_controller.h"
#include "ash/assistant/assistant_controller_observer.h"
#include "ash/assistant/assistant_interaction_controller.h"
......@@ -110,6 +113,11 @@ void AssistantController::RequestScreenshot(
std::move(callback));
}
void AssistantController::OpenAssistantSettings() {
// Launch Assistant settings via deeplink.
OpenUrl(assistant::util::CreateAssistantSettingsDeepLink());
}
void AssistantController::ManageWebContents(
const base::UnguessableToken& id_token,
mojom::ManagedWebContentsParamsPtr params,
......@@ -175,7 +183,7 @@ void AssistantController::DownloadImage(
void AssistantController::OnDeepLinkReceived(
assistant::util::DeepLinkType type,
const std::map<std::string, std::string>& params) {
using namespace assistant::util;
using assistant::util::DeepLinkType;
switch (type) {
case DeepLinkType::kFeedback:
......@@ -263,12 +271,12 @@ void AssistantController::NotifyDestroying() {
}
void AssistantController::NotifyDeepLinkReceived(const GURL& deep_link) {
using namespace assistant::util;
using assistant::util::DeepLinkType;
// Retrieve deep link type and parsed parameters.
DeepLinkType type = GetDeepLinkType(deep_link);
DeepLinkType type = assistant::util::GetDeepLinkType(deep_link);
const std::map<std::string, std::string> params =
GetDeepLinkParams(deep_link);
assistant::util::GetDeepLinkParams(deep_link);
for (AssistantControllerObserver& observer : observers_)
observer.OnDeepLinkReceived(type, params);
......
......@@ -5,6 +5,7 @@
#ifndef ASH_ASSISTANT_ASSISTANT_CONTROLLER_H_
#define ASH_ASSISTANT_ASSISTANT_CONTROLLER_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
......@@ -101,6 +102,7 @@ class ASH_EXPORT AssistantController
mojom::WebContentsManagerPtr web_contents_manager) override;
void RequestScreenshot(const gfx::Rect& rect,
RequestScreenshotCallback callback) override;
void OpenAssistantSettings() override;
// AssistantControllerObserver:
void OnDeepLinkReceived(
......
......@@ -34,4 +34,7 @@ interface AssistantController {
// encoded in JPEG format. If |rect| is empty, it returns fullscreen
// screenshot.
RequestScreenshot(gfx.mojom.Rect rect) => (array<uint8> screenshot);
// Opens Google Assistant settings.
OpenAssistantSettings();
};
......@@ -6,11 +6,16 @@
#include <utility>
#include "ash/public/interfaces/assistant_controller.mojom.h"
#include "ash/public/interfaces/constants.mojom.h"
#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/chromeos/arc/voice_interaction/arc_voice_interaction_framework_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chromeos/chromeos_switches.h"
#include "components/arc/arc_service_manager.h"
#include "content/public/browser/browser_context.h"
#include "services/service_manager/public/cpp/connector.h"
#include "ui/gfx/geometry/rect.h"
namespace chromeos {
......@@ -72,6 +77,16 @@ void GoogleAssistantHandler::HandleSetGoogleAssistantContextEnabled(
void GoogleAssistantHandler::HandleShowGoogleAssistantSettings(
const base::ListValue* args) {
if (chromeos::switches::IsAssistantEnabled()) {
// Opens Google Assistant settings.
service_manager::Connector* connector =
content::BrowserContext::GetConnectorFor(profile_);
ash::mojom::AssistantControllerPtr assistant_controller;
connector->BindInterface(ash::mojom::kServiceName, &assistant_controller);
assistant_controller->OpenAssistantSettings();
return;
}
auto* service =
arc::ArcVoiceInteractionFrameworkService::GetForBrowserContext(profile_);
if (service)
......
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