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

Side by Side Diff: content/browser/android/nfc_host.cc

Issue 2865653002: [Device Service] Decouple NFC implementation from //content (Closed)
Patch Set: Rebase Created 3 years, 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/android/nfc_host.h"
6
7 #include <utility>
8
9 #include "base/atomic_sequence_num.h"
10 #include "content/public/browser/android/content_view_core.h"
11 #include "content/public/common/service_manager_connection.h"
12 #include "device/nfc/nfc.mojom.h"
13 #include "jni/NfcHost_jni.h"
14 #include "services/device/public/interfaces/constants.mojom.h"
15 #include "services/service_manager/public/cpp/connector.h"
16
17 namespace content {
18
19 namespace {
20
21 base::StaticAtomicSequenceNumber g_unique_id;
22
23 } // namespace
24
25 NFCHost::NFCHost(WebContents* web_contents)
26 : id_(g_unique_id.GetNext()), web_contents_(web_contents) {
27 DCHECK(web_contents_);
28
29 JNIEnv* env = base::android::AttachCurrentThread();
30
31 java_nfc_host_.Reset(
32 Java_NfcHost_create(env, web_contents_->GetJavaWebContents().obj(), id_));
33
34 if (ServiceManagerConnection::GetForProcess()) {
35 service_manager::Connector* connector =
36 ServiceManagerConnection::GetForProcess()->GetConnector();
37 connector->BindInterface(device::mojom::kServiceName,
38 mojo::MakeRequest(&nfc_provider_));
39 }
40 }
41
42 void NFCHost::GetNFC(device::nfc::mojom::NFCRequest request) {
43 // Connect to an NFC object, associating it with |id_|.
44 nfc_provider_->GetNFCForHost(id_, std::move(request));
45 }
46
47 NFCHost::~NFCHost() {}
48
49 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/nfc_host.h ('k') | content/browser/frame_host/render_frame_host_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698