[WebLayer] Move Android NFC code to //components/permissions/nfc/android.
NfcSystemLevelSetting is used by the site settings page, which is being
componentized so it can be used by WebLayer. This CL moves the Android
portion of //chrome/browser/nfc to the permissions component to to
unblock site settings work, but the remaineder of the NFC code will
likely need to be componentized at a later date as well.
Bug: 1058597
Change-Id: Idd315fe4d82201c7009b6bbb3202a8d3d2241571
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090831
Reviewed-by: Andy Paicu <[email protected]>
Reviewed-by: John Abd-El-Malek <[email protected]>
Reviewed-by: Clark DuVall <[email protected]>
Reviewed-by: Colin Blundell <[email protected]>
Reviewed-by: Theresa <[email protected]>
Commit-Queue: Robbie McElrath <[email protected]>
Cr-Commit-Position: refs/heads/master@{#749284}
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 5037f67..f3ab075 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -2981,7 +2981,6 @@
"//chrome/browser/android/thin_webview/internal",
"//chrome/browser/android/webapk:proto",
"//chrome/browser/flags:flags_android",
- "//chrome/browser/nfc/android:native",
"//chrome/browser/notifications/chime/android",
"//chrome/browser/notifications/scheduler/public",
"//chrome/browser/offline_pages/prefetch/notifications",
@@ -3010,6 +3009,7 @@
"//components/paint_preview/browser/android:jni_headers",
"//components/password_manager/content/browser",
"//components/payments/content/android",
+ "//components/permissions/android:native",
"//components/resources:components_resources",
"//components/security_state/content/android",
"//components/send_tab_to_self",
diff --git a/chrome/browser/nfc/android/BUILD.gn b/chrome/browser/nfc/android/BUILD.gn
deleted file mode 100644
index e5b9dc4..0000000
--- a/chrome/browser/nfc/android/BUILD.gn
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright 2020 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/config/android/rules.gni")
-
-android_library("java") {
- sources = [
- "java/src/org/chromium/chrome/browser/nfc/NfcSystemLevelPrompt.java",
- "java/src/org/chromium/chrome/browser/nfc/NfcSystemLevelSetting.java",
- ]
-
- annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
-
- deps = [
- ":java_resources",
- "//base:base_java",
- "//base:jni_java",
- "//content/public/android:content_java",
- "//third_party/android_deps:android_support_v7_appcompat_java",
- "//ui/android:ui_full_java",
-
- # TODO(crbug.com/1017190): Remove the following 2 deps once we stop linting individual targets.
- "//components/browser_ui/modaldialog/android:java",
- "//third_party/android_deps:com_google_android_material_material_java",
- ]
-}
-
-generate_jni("jni_headers") {
- sources =
- [ "java/src/org/chromium/chrome/browser/nfc/NfcSystemLevelSetting.java" ]
-}
-
-android_resources("java_resources") {
- deps = [
- "//chrome/browser/ui/android/strings:ui_strings_grd",
- "//components/browser_ui/modaldialog/android:java_resources",
- "//components/browser_ui/strings/android:browser_ui_strings_grd",
- ]
- resource_dirs = [ "java/res" ]
- custom_package = "org.chromium.chrome.browser.nfc"
-}
-
-source_set("native") {
- sources = [
- "nfc_system_level_setting.h",
- "nfc_system_level_setting_impl.cc",
- "nfc_system_level_setting_impl.h",
- ]
- deps = [
- ":jni_headers",
- "//base",
- "//content/public/browser",
- ]
-}
-
-source_set("test_support") {
- testonly = true
- sources = [
- "mock_nfc_system_level_setting.cc",
- "mock_nfc_system_level_setting.h",
- ]
- deps = [
- ":native",
- "//base",
- ]
-}
diff --git a/chrome/browser/nfc/android/DEPS b/chrome/browser/nfc/android/DEPS
deleted file mode 100644
index be9251e..0000000
--- a/chrome/browser/nfc/android/DEPS
+++ /dev/null
@@ -1,8 +0,0 @@
-noparent = True
-
-include_rules = [
- "+base",
- "+content/public/android/java/src/org/chromium/content_public",
- "+content/public/browser",
- "+ui/android",
-]
diff --git a/chrome/browser/nfc/android/java/res/drawable-hdpi/settings_nfc.png b/chrome/browser/nfc/android/java/res/drawable-hdpi/settings_nfc.png
deleted file mode 100644
index 35f9253..0000000
--- a/chrome/browser/nfc/android/java/res/drawable-hdpi/settings_nfc.png
+++ /dev/null
Binary files differ
diff --git a/chrome/browser/nfc/android/java/res/drawable-mdpi/settings_nfc.png b/chrome/browser/nfc/android/java/res/drawable-mdpi/settings_nfc.png
deleted file mode 100644
index b012c1c..0000000
--- a/chrome/browser/nfc/android/java/res/drawable-mdpi/settings_nfc.png
+++ /dev/null
Binary files differ
diff --git a/chrome/browser/nfc/android/java/res/drawable-xhdpi/settings_nfc.png b/chrome/browser/nfc/android/java/res/drawable-xhdpi/settings_nfc.png
deleted file mode 100644
index be707f3e..0000000
--- a/chrome/browser/nfc/android/java/res/drawable-xhdpi/settings_nfc.png
+++ /dev/null
Binary files differ
diff --git a/chrome/browser/nfc/android/java/res/drawable-xxhdpi/settings_nfc.png b/chrome/browser/nfc/android/java/res/drawable-xxhdpi/settings_nfc.png
deleted file mode 100644
index 267496a..0000000
--- a/chrome/browser/nfc/android/java/res/drawable-xxhdpi/settings_nfc.png
+++ /dev/null
Binary files differ
diff --git a/chrome/browser/nfc/android/java/res/drawable-xxxhdpi/settings_nfc.png b/chrome/browser/nfc/android/java/res/drawable-xxxhdpi/settings_nfc.png
deleted file mode 100644
index 5ef2eae..0000000
--- a/chrome/browser/nfc/android/java/res/drawable-xxxhdpi/settings_nfc.png
+++ /dev/null
Binary files differ
diff --git a/chrome/browser/nfc/android/java/src/org/chromium/chrome/browser/nfc/NfcSystemLevelPrompt.java b/chrome/browser/nfc/android/java/src/org/chromium/chrome/browser/nfc/NfcSystemLevelPrompt.java
deleted file mode 100644
index 18abe87..0000000
--- a/chrome/browser/nfc/android/java/src/org/chromium/chrome/browser/nfc/NfcSystemLevelPrompt.java
+++ /dev/null
@@ -1,114 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.nfc;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.os.Build;
-import android.provider.Settings;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.TextView;
-
-import androidx.annotation.VisibleForTesting;
-import androidx.core.widget.TextViewCompat;
-
-import org.chromium.base.task.PostTask;
-import org.chromium.content_public.browser.UiThreadTaskTraits;
-import org.chromium.ui.base.WindowAndroid;
-import org.chromium.ui.modaldialog.DialogDismissalCause;
-import org.chromium.ui.modaldialog.ModalDialogManager;
-import org.chromium.ui.modaldialog.ModalDialogProperties;
-import org.chromium.ui.modelutil.PropertyModel;
-
-/**
- * Implements a modal dialog that prompts the user about turning on the NFC adapter on the system
- * level.
- */
-public class NfcSystemLevelPrompt implements ModalDialogProperties.Controller {
- private ModalDialogManager mModalDialogManager;
- private WindowAndroid mWindowAndroid;
- private Runnable mCallback;
-
- /**
- * Triggers a prompt to ask the user to turn on the system NFC setting on their device.
- *
- * <p>The prompt will be triggered within the specified window.
- *
- * @param window The current window to display the prompt into.
- * @param callback The callback to be called when dialog is closed.
- */
- public void show(WindowAndroid window, Runnable callback) {
- ModalDialogManager modalDialogManager = window.getModalDialogManager();
- if (modalDialogManager == null) {
- PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> callback.run());
- return;
- }
- show(window, modalDialogManager, callback);
- }
-
- @VisibleForTesting
- protected void show(
- WindowAndroid window, ModalDialogManager modalDialogManager, Runnable callback) {
- Activity activity = window.getActivity().get();
- LayoutInflater inflater = LayoutInflater.from(activity);
- View customView = inflater.inflate(R.layout.permission_dialog, null);
-
- TextView messageTextView = customView.findViewById(R.id.text);
- messageTextView.setText(R.string.nfc_disabled_on_device_message);
- TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
- messageTextView, R.drawable.settings_nfc, 0, 0, 0);
-
- Resources resources = activity.getResources();
- PropertyModel model = new PropertyModel.Builder(ModalDialogProperties.ALL_KEYS)
- .with(ModalDialogProperties.CONTROLLER, this)
- .with(ModalDialogProperties.CUSTOM_VIEW, customView)
- .with(ModalDialogProperties.POSITIVE_BUTTON_TEXT, resources,
- R.string.nfc_prompt_turn_on)
- .with(ModalDialogProperties.NEGATIVE_BUTTON_TEXT, resources,
- R.string.cancel)
- .with(ModalDialogProperties.CONTENT_DESCRIPTION, resources,
- R.string.nfc_disabled_on_device_message)
- .with(ModalDialogProperties.FILTER_TOUCH_FOR_SECURITY, true)
- .build();
-
- mWindowAndroid = window;
- mCallback = callback;
- mModalDialogManager = modalDialogManager;
- mModalDialogManager.showDialog(model, ModalDialogManager.ModalDialogType.TAB);
- }
-
- @Override
- public void onClick(PropertyModel model, int buttonType) {
- if (buttonType == ModalDialogProperties.ButtonType.NEGATIVE) {
- mModalDialogManager.dismissDialog(model, DialogDismissalCause.NEGATIVE_BUTTON_CLICKED);
- } else {
- String nfcAction = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
- ? Settings.Panel.ACTION_NFC
- : Settings.ACTION_NFC_SETTINGS;
- Intent intent = new Intent(nfcAction);
- try {
- mWindowAndroid.showIntent(intent, new WindowAndroid.IntentCallback() {
- @Override
- public void onIntentCompleted(
- WindowAndroid window, int resultCode, Intent data) {
- mModalDialogManager.dismissDialog(
- model, DialogDismissalCause.POSITIVE_BUTTON_CLICKED);
- }
- }, null);
- } catch (android.content.ActivityNotFoundException ex) {
- mModalDialogManager.dismissDialog(
- model, DialogDismissalCause.POSITIVE_BUTTON_CLICKED);
- }
- }
- }
-
- @Override
- public void onDismiss(PropertyModel model, int dismissalCause) {
- if (mCallback != null) mCallback.run();
- mCallback = null;
- }
-}
diff --git a/chrome/browser/nfc/android/java/src/org/chromium/chrome/browser/nfc/NfcSystemLevelSetting.java b/chrome/browser/nfc/android/java/src/org/chromium/chrome/browser/nfc/NfcSystemLevelSetting.java
deleted file mode 100644
index 2f283313..0000000
--- a/chrome/browser/nfc/android/java/src/org/chromium/chrome/browser/nfc/NfcSystemLevelSetting.java
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.nfc;
-
-import android.Manifest;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.nfc.NfcAdapter;
-import android.os.Process;
-import android.provider.Settings;
-
-import androidx.annotation.VisibleForTesting;
-
-import org.chromium.base.ContextUtils;
-import org.chromium.base.annotations.CalledByNative;
-import org.chromium.base.annotations.NativeMethods;
-import org.chromium.base.task.PostTask;
-import org.chromium.content_public.browser.UiThreadTaskTraits;
-import org.chromium.content_public.browser.WebContents;
-import org.chromium.ui.base.WindowAndroid;
-
-/**
- * Provides methods for querying NFC sytem-level setting on Android.
- *
- * This class should be used only on the UI thread.
- */
-public class NfcSystemLevelSetting {
- private static Boolean sNfcSupportForTesting;
- private static Boolean sSystemNfcSettingForTesting;
-
- @CalledByNative
- public static boolean isNfcAccessPossible() {
- if (sNfcSupportForTesting != null) {
- return sNfcSupportForTesting;
- }
-
- Context context = ContextUtils.getApplicationContext();
- int permission =
- context.checkPermission(Manifest.permission.NFC, Process.myPid(), Process.myUid());
- if (permission != PackageManager.PERMISSION_GRANTED) {
- return false;
- }
-
- NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(context);
- return nfcAdapter != null;
- }
-
- @CalledByNative
- public static boolean isNfcSystemLevelSettingEnabled() {
- if (sSystemNfcSettingForTesting != null) {
- return sSystemNfcSettingForTesting;
- }
-
- if (!isNfcAccessPossible()) return false;
-
- NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(ContextUtils.getApplicationContext());
- return nfcAdapter.isEnabled();
- }
-
- @CalledByNative
- private static void promptToEnableNfcSystemLevelSetting(
- WebContents webContents, final long nativeCallback) {
- WindowAndroid window = webContents.getTopLevelNativeWindow();
- if (window == null) {
- // Consuming code may not expect a sync callback to happen.
- PostTask.postTask(UiThreadTaskTraits.DEFAULT,
- ()
- -> NfcSystemLevelSettingJni.get().onNfcSystemLevelPromptCompleted(
- nativeCallback));
- return;
- }
-
- NfcSystemLevelPrompt prompt = new NfcSystemLevelPrompt();
- prompt.show(window,
- ()
- -> NfcSystemLevelSettingJni.get().onNfcSystemLevelPromptCompleted(
- nativeCallback));
- }
-
- public static Intent getNfcSystemLevelSettingIntent() {
- Intent intent = new Intent(Settings.ACTION_NFC_SETTINGS);
- Context context = ContextUtils.getApplicationContext();
- if (intent.resolveActivity(context.getPackageManager()) == null) {
- return null;
- }
- return intent;
- }
-
- /** Disable/enable Android NFC setting for testing use only. */
- @VisibleForTesting
- public static void setNfcSettingForTesting(Boolean enabled) {
- sSystemNfcSettingForTesting = enabled;
- }
-
- /** Disable/enable Android NFC support for testing use only. */
- @VisibleForTesting
- public static void setNfcSupportForTesting(Boolean enabled) {
- sNfcSupportForTesting = enabled;
- }
-
- @NativeMethods
- interface Natives {
- void onNfcSystemLevelPromptCompleted(long callback);
- }
-}
diff --git a/chrome/browser/nfc/android/mock_nfc_system_level_setting.cc b/chrome/browser/nfc/android/mock_nfc_system_level_setting.cc
deleted file mode 100644
index fbce0dd5..0000000
--- a/chrome/browser/nfc/android/mock_nfc_system_level_setting.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/nfc/android/mock_nfc_system_level_setting.h"
-
-namespace {
-
-static bool nfc_access_is_possible_ = false;
-static bool is_nfc_setting_enabled_ = false;
-static bool has_shown_nfc_setting_prompt_ = false;
-
-} // namespace
-
-MockNfcSystemLevelSetting::MockNfcSystemLevelSetting()
- : NfcSystemLevelSetting() {}
-
-MockNfcSystemLevelSetting::~MockNfcSystemLevelSetting() {}
-
-void MockNfcSystemLevelSetting::SetNfcAccessIsPossible(bool is_possible) {
- nfc_access_is_possible_ = is_possible;
-}
-
-void MockNfcSystemLevelSetting::SetNfcSystemLevelSettingEnabled(
- bool is_enabled) {
- is_nfc_setting_enabled_ = is_enabled;
-}
-
-bool MockNfcSystemLevelSetting::HasShownNfcSettingPrompt() {
- return has_shown_nfc_setting_prompt_;
-}
-
-void MockNfcSystemLevelSetting::ClearHasShownNfcSettingPrompt() {
- has_shown_nfc_setting_prompt_ = false;
-}
-
-bool MockNfcSystemLevelSetting::IsNfcAccessPossible() {
- return nfc_access_is_possible_;
-}
-
-bool MockNfcSystemLevelSetting::IsNfcSystemLevelSettingEnabled() {
- return is_nfc_setting_enabled_;
-}
-
-void MockNfcSystemLevelSetting::PromptToEnableNfcSystemLevelSetting(
- content::WebContents* web_contents,
- base::OnceClosure prompt_completed_callback) {
- has_shown_nfc_setting_prompt_ = true;
- std::move(prompt_completed_callback).Run();
-}
diff --git a/chrome/browser/nfc/android/mock_nfc_system_level_setting.h b/chrome/browser/nfc/android/mock_nfc_system_level_setting.h
deleted file mode 100644
index c4e85a8..0000000
--- a/chrome/browser/nfc/android/mock_nfc_system_level_setting.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_NFC_ANDROID_MOCK_NFC_SYSTEM_LEVEL_SETTING_H_
-#define CHROME_BROWSER_NFC_ANDROID_MOCK_NFC_SYSTEM_LEVEL_SETTING_H_
-
-#include "base/macros.h"
-#include "chrome/browser/nfc/android/nfc_system_level_setting.h"
-
-// Mock implementation of NfcSystemLevelSetting for unit tests.
-class MockNfcSystemLevelSetting : public NfcSystemLevelSetting {
- public:
- MockNfcSystemLevelSetting();
- ~MockNfcSystemLevelSetting() override;
-
- static void SetNfcAccessIsPossible(bool is_possible);
- static void SetNfcSystemLevelSettingEnabled(bool is_enabled);
- static bool HasShownNfcSettingPrompt();
- static void ClearHasShownNfcSettingPrompt();
-
- // NfcSystemLevelSetting implementation:
- bool IsNfcAccessPossible() override;
- bool IsNfcSystemLevelSettingEnabled() override;
- void PromptToEnableNfcSystemLevelSetting(
- content::WebContents* web_contents,
- base::OnceClosure prompt_completed_callback) override;
-
- DISALLOW_COPY_AND_ASSIGN(MockNfcSystemLevelSetting);
-};
-
-#endif // CHROME_BROWSER_NFC_ANDROID_MOCK_NFC_SYSTEM_LEVEL_SETTING_H_
diff --git a/chrome/browser/nfc/android/nfc_system_level_setting.h b/chrome/browser/nfc/android/nfc_system_level_setting.h
deleted file mode 100644
index 71f4133..0000000
--- a/chrome/browser/nfc/android/nfc_system_level_setting.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_NFC_ANDROID_NFC_SYSTEM_LEVEL_SETTING_H_
-#define CHROME_BROWSER_NFC_ANDROID_NFC_SYSTEM_LEVEL_SETTING_H_
-
-#include "base/callback.h"
-#include "base/macros.h"
-
-namespace content {
-class WebContents;
-}
-
-// This class determines whether NFC is enabled system-wide on the device.
-class NfcSystemLevelSetting {
- public:
- virtual ~NfcSystemLevelSetting() {}
-
- // Returns true if the NFC system level setting can be enabled.
- virtual bool IsNfcAccessPossible() = 0;
-
- // Returns true if the NFC system level setting is enabled.
- virtual bool IsNfcSystemLevelSettingEnabled() = 0;
-
- // Triggers a prompt to ask the user to turn on the system NFC setting on
- // their device, and invokes callback when prompt is completed.
- //
- // The prompt will be triggered in the activity of the web contents.
- //
- // The callback is guaranteed to be called unless the user never replies to
- // the prompt dialog, which in practice happens very infrequently since the
- // dialog is modal.
- //
- // The callback may be invoked a long time after this method has returned.
- // If you need to access in the callback an object that is not owned by the
- // callback, you should ensure that the object has not been destroyed before
- // accessing it to prevent crashes, e.g. by using weak pointer semantics.
- virtual void PromptToEnableNfcSystemLevelSetting(
- content::WebContents* web_contents,
- base::OnceClosure prompt_completed_callback) = 0;
-};
-
-#endif // CHROME_BROWSER_NFC_ANDROID_NFC_SYSTEM_LEVEL_SETTING_H_
diff --git a/chrome/browser/nfc/android/nfc_system_level_setting_impl.cc b/chrome/browser/nfc/android/nfc_system_level_setting_impl.cc
deleted file mode 100644
index b9290276..0000000
--- a/chrome/browser/nfc/android/nfc_system_level_setting_impl.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/nfc/android/nfc_system_level_setting_impl.h"
-
-#include "base/android/jni_android.h"
-#include "chrome/browser/nfc/android/jni_headers/NfcSystemLevelSetting_jni.h"
-#include "content/public/browser/web_contents.h"
-
-NfcSystemLevelSettingImpl::NfcSystemLevelSettingImpl() {}
-
-NfcSystemLevelSettingImpl::~NfcSystemLevelSettingImpl() {}
-
-bool NfcSystemLevelSettingImpl::IsNfcAccessPossible() {
- JNIEnv* env = base::android::AttachCurrentThread();
- return Java_NfcSystemLevelSetting_isNfcAccessPossible(env);
-}
-
-bool NfcSystemLevelSettingImpl::IsNfcSystemLevelSettingEnabled() {
- JNIEnv* env = base::android::AttachCurrentThread();
- return Java_NfcSystemLevelSetting_isNfcSystemLevelSettingEnabled(env);
-}
-
-void NfcSystemLevelSettingImpl::PromptToEnableNfcSystemLevelSetting(
- content::WebContents* web_contents,
- base::OnceClosure prompt_completed_callback) {
- JNIEnv* env = base::android::AttachCurrentThread();
- // Transfers the ownership of the callback to the Java callback. The Java
- // callback is guaranteed to be called unless the user never replies to the
- // dialog, and the callback pointer will be destroyed in
- // NfcSystemLevelPrompt.onDismiss.
- auto* callback_ptr =
- new base::OnceClosure(std::move(prompt_completed_callback));
- Java_NfcSystemLevelSetting_promptToEnableNfcSystemLevelSetting(
- env, web_contents->GetJavaWebContents(),
- reinterpret_cast<jlong>(callback_ptr));
-}
-
-static void JNI_NfcSystemLevelSetting_OnNfcSystemLevelPromptCompleted(
- JNIEnv* env,
- jlong callback_ptr) {
- auto* callback = reinterpret_cast<base::OnceClosure*>(callback_ptr);
- std::move(*callback).Run();
- // Destroy the callback whose ownership was transferred in
- // PromptToEnableNfcSystemLevelSetting.
- delete callback;
-}
diff --git a/chrome/browser/nfc/android/nfc_system_level_setting_impl.h b/chrome/browser/nfc/android/nfc_system_level_setting_impl.h
deleted file mode 100644
index f19c05f..0000000
--- a/chrome/browser/nfc/android/nfc_system_level_setting_impl.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_NFC_ANDROID_NFC_SYSTEM_LEVEL_SETTING_IMPL_H_
-#define CHROME_BROWSER_NFC_ANDROID_NFC_SYSTEM_LEVEL_SETTING_IMPL_H_
-
-#include <memory>
-
-#include "base/android/jni_weak_ref.h"
-#include "base/android/scoped_java_ref.h"
-#include "base/macros.h"
-#include "chrome/browser/nfc/android/nfc_system_level_setting.h"
-
-class NfcSystemLevelSettingImpl : public NfcSystemLevelSetting {
- public:
- NfcSystemLevelSettingImpl();
- ~NfcSystemLevelSettingImpl() override;
-
- // NfcSystemLevelSetting implementation:
- bool IsNfcAccessPossible() override;
- bool IsNfcSystemLevelSettingEnabled() override;
- void PromptToEnableNfcSystemLevelSetting(
- content::WebContents* web_contents,
- base::OnceClosure prompt_completed_callback) override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NfcSystemLevelSettingImpl);
-};
-
-#endif // CHROME_BROWSER_NFC_ANDROID_NFC_SYSTEM_LEVEL_SETTING_IMPL_H_
diff --git a/chrome/browser/nfc/nfc_permission_context_android.cc b/chrome/browser/nfc/nfc_permission_context_android.cc
index fec77aa8..62771da 100644
--- a/chrome/browser/nfc/nfc_permission_context_android.cc
+++ b/chrome/browser/nfc/nfc_permission_context_android.cc
@@ -7,15 +7,15 @@
#include "base/android/jni_android.h"
#include "base/bind.h"
#include "chrome/browser/android/tab_android.h"
-#include "chrome/browser/nfc/android/nfc_system_level_setting_impl.h"
+#include "components/permissions/android/nfc/nfc_system_level_setting_impl.h"
#include "components/permissions/permission_request_id.h"
#include "content/public/browser/web_contents.h"
NfcPermissionContextAndroid::NfcPermissionContextAndroid(
content::BrowserContext* browser_context)
: NfcPermissionContext(browser_context),
- nfc_system_level_setting_(std::make_unique<NfcSystemLevelSettingImpl>()) {
-}
+ nfc_system_level_setting_(
+ std::make_unique<permissions::NfcSystemLevelSettingImpl>()) {}
NfcPermissionContextAndroid::~NfcPermissionContextAndroid() = default;
diff --git a/chrome/browser/nfc/nfc_permission_context_android.h b/chrome/browser/nfc/nfc_permission_context_android.h
index 584ec21..141fe96 100644
--- a/chrome/browser/nfc/nfc_permission_context_android.h
+++ b/chrome/browser/nfc/nfc_permission_context_android.h
@@ -5,8 +5,8 @@
#ifndef CHROME_BROWSER_NFC_NFC_PERMISSION_CONTEXT_ANDROID_H_
#define CHROME_BROWSER_NFC_NFC_PERMISSION_CONTEXT_ANDROID_H_
-#include "chrome/browser/nfc/android/nfc_system_level_setting.h"
#include "chrome/browser/nfc/nfc_permission_context.h"
+#include "components/permissions/android/nfc/nfc_system_level_setting.h"
namespace permissions {
class PermissionRequestID;
@@ -41,11 +41,12 @@
// Overrides the NfcSystemLevelSetting object used to determine whether NFC is
// enabled system-wide on the device.
void set_nfc_system_level_setting_for_testing(
- std::unique_ptr<NfcSystemLevelSetting> nfc_system_level_setting) {
+ std::unique_ptr<permissions::NfcSystemLevelSetting>
+ nfc_system_level_setting) {
nfc_system_level_setting_ = std::move(nfc_system_level_setting);
}
- std::unique_ptr<NfcSystemLevelSetting> nfc_system_level_setting_;
+ std::unique_ptr<permissions::NfcSystemLevelSetting> nfc_system_level_setting_;
base::WeakPtrFactory<NfcPermissionContextAndroid> weak_factory_{this};
};
diff --git a/chrome/browser/nfc/nfc_permission_context_unittest.cc b/chrome/browser/nfc/nfc_permission_context_unittest.cc
index 31d87fa18..7cdc98f2 100644
--- a/chrome/browser/nfc/nfc_permission_context_unittest.cc
+++ b/chrome/browser/nfc/nfc_permission_context_unittest.cc
@@ -17,8 +17,10 @@
#include "content/public/test/test_utils.h"
#if defined(OS_ANDROID)
-#include "chrome/browser/nfc/android/mock_nfc_system_level_setting.h"
#include "chrome/browser/nfc/nfc_permission_context_android.h"
+#include "components/permissions/android/nfc/mock_nfc_system_level_setting.h"
+
+using permissions::MockNfcSystemLevelSetting;
#endif
using content::MockRenderProcessHost;
@@ -121,7 +123,7 @@
#if defined(OS_ANDROID)
static_cast<NfcPermissionContextAndroid*>(nfc_permission_context_)
->set_nfc_system_level_setting_for_testing(
- std::unique_ptr<NfcSystemLevelSetting>(
+ std::unique_ptr<permissions::NfcSystemLevelSetting>(
new MockNfcSystemLevelSetting()));
MockNfcSystemLevelSetting::SetNfcSystemLevelSettingEnabled(true);
MockNfcSystemLevelSetting::SetNfcAccessIsPossible(true);
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings.grd b/chrome/browser/ui/android/strings/android_chrome_strings.grd
index b9b6ecf7..836b428 100644
--- a/chrome/browser/ui/android/strings/android_chrome_strings.grd
+++ b/chrome/browser/ui/android/strings/android_chrome_strings.grd
@@ -4089,12 +4089,6 @@
</message>
<!-- NFC prompt -->
- <message name="IDS_NFC_DISABLED_ON_DEVICE_MESSAGE" desc="Text shown in a prompt to turn on NFC after user granted NFC permission to a website.">
- To continue, turn on NFC in Android settings
- </message>
- <message name="IDS_NFC_PROMPT_TURN_ON" desc="Text on the positive button of the nfc prompt">
- Turn on
- </message>
<message name="IDS_ANDROID_NFC_OFF_GLOBALLY" desc="The message to show when NFC has been turned off globally in Android. Contains a link to the settings menu to enable NFC.">
NFC is off for this device. Turn it on in <ph name="BEGIN_LINK"><link></ph>Android Settings<ph name="END_LINK"></link></ph>.
</message>
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_NFC_DISABLED_ON_DEVICE_MESSAGE.png.sha1 b/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_NFC_DISABLED_ON_DEVICE_MESSAGE.png.sha1
deleted file mode 100644
index 65a473f..0000000
--- a/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_NFC_DISABLED_ON_DEVICE_MESSAGE.png.sha1
+++ /dev/null
@@ -1 +0,0 @@
-7ad46df7b303b90dc7f4627e6431729c97041627
\ No newline at end of file
diff --git a/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_NFC_PROMPT_TURN_ON.png.sha1 b/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_NFC_PROMPT_TURN_ON.png.sha1
deleted file mode 100644
index 36723f0..0000000
--- a/chrome/browser/ui/android/strings/android_chrome_strings_grd/IDS_NFC_PROMPT_TURN_ON.png.sha1
+++ /dev/null
@@ -1 +0,0 @@
-b61af89a20cbeaf1474ceb0bb4c3caa7494c517b
\ No newline at end of file