Oksana Zhuravlova | 4dd171e8 | 2019-08-16 20:54:00 | [diff] [blame] | 1 | // Copyright 2019 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 "chrome/browser/chrome_browser_interface_binders.h" |
| 6 | #include "content/public/browser/browser_context.h" |
| 7 | #include "content/public/browser/render_frame_host.h" |
| 8 | #include "content/public/browser/render_process_host.h" |
| 9 | #include "services/image_annotation/public/mojom/constants.mojom-forward.h" |
| 10 | #include "services/image_annotation/public/mojom/image_annotation.mojom.h" |
| 11 | #include "services/service_manager/public/cpp/connector.h" |
| 12 | |
| 13 | namespace chrome { |
| 14 | namespace internal { |
| 15 | |
| 16 | // Forward image Annotator requests to the image_annotation service. |
| 17 | void BindImageAnnotator( |
| 18 | content::RenderFrameHost* const frame_host, |
| 19 | mojo::PendingReceiver<image_annotation::mojom::Annotator> receiver) { |
| 20 | content::BrowserContext::GetConnectorFor( |
| 21 | frame_host->GetProcess()->GetBrowserContext()) |
| 22 | ->BindInterface( |
| 23 | image_annotation::mojom::kServiceName, |
| 24 | image_annotation::mojom::AnnotatorRequest(std::move(receiver))); |
| 25 | } |
| 26 | |
| 27 | void PopulateChromeFrameBinders( |
| 28 | service_manager::BinderMapWithContext<content::RenderFrameHost*>* map) { |
| 29 | map->Add<image_annotation::mojom::Annotator>( |
| 30 | base::BindRepeating(&BindImageAnnotator)); |
| 31 | } |
| 32 | |
| 33 | } // namespace internal |
| 34 | } // namespace chrome |