David Black | e8f81504 | 2018-03-28 18:59:37 | [diff] [blame^] | 1 | // Copyright (c) 2018 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "ash/assistant/ash_assistant_controller.h" |
| 6 | |
| 7 | #include "ash/shell.h" |
| 8 | #include "ash/shell_delegate.h" |
| 9 | |
| 10 | namespace ash { |
| 11 | |
| 12 | AshAssistantController::AshAssistantController() |
| 13 | : assistant_controller_binding_(this), |
| 14 | assistant_event_subscriber_binding_(this) {} |
| 15 | |
| 16 | AshAssistantController::~AshAssistantController() { |
| 17 | assistant_controller_binding_.Close(); |
| 18 | assistant_event_subscriber_binding_.Close(); |
| 19 | } |
| 20 | |
| 21 | void AshAssistantController::BindRequest( |
| 22 | mojom::AshAssistantControllerRequest request) { |
| 23 | assistant_controller_binding_.Bind(std::move(request)); |
| 24 | } |
| 25 | |
| 26 | void AshAssistantController::SetAssistant( |
| 27 | chromeos::assistant::mojom::AssistantPtr assistant) { |
| 28 | // Subscribe to Assistant events. |
| 29 | chromeos::assistant::mojom::AssistantEventSubscriberPtr ptr; |
| 30 | assistant_event_subscriber_binding_.Bind(mojo::MakeRequest(&ptr)); |
| 31 | assistant->AddAssistantEventSubscriber(std::move(ptr)); |
| 32 | } |
| 33 | |
| 34 | void AshAssistantController::OnHtmlResponse(const std::string& response) { |
| 35 | // TODO(dmblack): Handle. |
| 36 | NOTIMPLEMENTED(); |
| 37 | } |
| 38 | |
| 39 | void AshAssistantController::OnTextResponse(const std::string& response) { |
| 40 | // TODO(dmblack): Handle. |
| 41 | NOTIMPLEMENTED(); |
| 42 | } |
| 43 | |
| 44 | void AshAssistantController::OnOpenUrlResponse(const GURL& url) { |
| 45 | Shell::Get()->shell_delegate()->OpenUrlFromArc(url); |
| 46 | } |
| 47 | |
| 48 | } // namespace ash |